From 4131069d0f517180a92e8ebda20b4760ecaeb855 Mon Sep 17 00:00:00 2001 From: thickbrick Date: Fri, 1 Apr 2011 15:28:48 +0300 Subject: Fix 829: Several changes to media filter - Adds a "less annoying" mode, which attempts to only filter scripted streaming events. On by default (should we change that?) - Adds UI to enable and disable the media filter, both from the filter floater and from the preferences floater. - Adds a button to launch the filter floater to prefences. - Some UI tweaks to the filter floater. --- linden/indra/newview/app_settings/settings.xml | 11 ++ linden/indra/newview/llfloaterpreference.cpp | 1 + linden/indra/newview/llpanelaudioprefs.cpp | 19 ++- linden/indra/newview/llpanelaudioprefs.h | 4 + linden/indra/newview/llviewerparcelmedia.cpp | 158 +++++++++++++++++---- linden/indra/newview/llviewerparcelmedia.h | 40 +++++- .../default/xui/en-us/floater_media_filter.xml | 26 +++- .../default/xui/en-us/panel_preferences_audio.xml | 15 +- linden/indra/newview/slfloatermediafilter.cpp | 116 ++++++++------- linden/indra/newview/slfloatermediafilter.h | 7 + 10 files changed, 308 insertions(+), 89 deletions(-) diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 2a508ee..5bd8c7e 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -8017,6 +8017,17 @@ 100 + MediaFilterOnlyRemoteCommands + + Comment + Whether Media Filter should only filter actions initiated remotely + Persist + 1 + Type + Boolean + Value + 1 + MediaOnAPrimUI Comment diff --git a/linden/indra/newview/llfloaterpreference.cpp b/linden/indra/newview/llfloaterpreference.cpp index 0f81be6..02c2014 100644 --- a/linden/indra/newview/llfloaterpreference.cpp +++ b/linden/indra/newview/llfloaterpreference.cpp @@ -365,6 +365,7 @@ void LLPreferenceCore::setPersonalInfo(const std::string& visibility, bool im_vi void LLPreferenceCore::updateIsLoggedIn(bool enable) { mPrefsIM->preparePerAccountPrefs(enable); + mAudioPanel->updateIsLoggedIn(enable); } void LLPreferenceCore::refreshEnabledGraphics() diff --git a/linden/indra/newview/llpanelaudioprefs.cpp b/linden/indra/newview/llpanelaudioprefs.cpp index 1acfcbb..fab2771 100644 --- a/linden/indra/newview/llpanelaudioprefs.cpp +++ b/linden/indra/newview/llpanelaudioprefs.cpp @@ -55,12 +55,14 @@ #include "llslider.h" #include "llsliderctrl.h" #include "llspinctrl.h" +#include "llstartup.h" #include "lltextbox.h" #include "llui.h" #include "llviewerparcelmgr.h" #include "lluictrlfactory.h" #include "llviewerwindow.h" #include "llviewercontrol.h" +#include "slfloatermediafilter.h" #include "hippogridmanager.h" @@ -92,6 +94,8 @@ BOOL LLPanelAudioPrefs::postBuild() refreshValues(); // initialize member data from saved settings childSetLabelArg("L$ Change Threshold", "[CURRENCY]", gHippoGridManager->getConnectedGrid()->getCurrencySymbol()); childSetValue("mute_wind_check", !gSavedSettings.getBOOL("MuteWind")); + childSetAction("show_media_filter", onShowMediaFilter, this); + updateIsLoggedIn(LLStartUp::isLoggedIn()); return TRUE; } @@ -112,7 +116,7 @@ void LLPanelAudioPrefs::refreshValues() mPreviousStreamingMusic = gSavedSettings.getBOOL("AudioStreamingMusic"); mPreviousStreamingVideo = gSavedSettings.getBOOL("AudioStreamingVideo"); - + mPreviousEnableMediaFilter = gSavedSettings.getBOOL("MediaEnableFilter"); mPreviousMuteAudio = gSavedSettings.getBOOL("MuteAudio"); mPreviousMuteWhenMinimized = gSavedSettings.getBOOL("MuteWhenMinimized"); } @@ -140,8 +144,19 @@ void LLPanelAudioPrefs::cancel() gSavedSettings.setBOOL("AudioStreamingMusic", mPreviousStreamingMusic ); gSavedSettings.setBOOL("AudioStreamingVideo", mPreviousStreamingVideo ); + gSavedSettings.setBOOL("MediaEnableFilter", mPreviousEnableMediaFilter ); - gSavedSettings.setBOOL("MuteAudio", mPreviousMuteAudio ); gSavedSettings.setBOOL("MuteWhenMinimized", mPreviousMuteWhenMinimized ); } + +//static +void LLPanelAudioPrefs::onShowMediaFilter(void* data) +{ + SLFloaterMediaFilter::toggleInstance(); +} + +void LLPanelAudioPrefs::updateIsLoggedIn(const bool enable) +{ + childSetEnabled("show_media_filter", enable); +} diff --git a/linden/indra/newview/llpanelaudioprefs.h b/linden/indra/newview/llpanelaudioprefs.h index 21d2f59..a0733ba 100644 --- a/linden/indra/newview/llpanelaudioprefs.h +++ b/linden/indra/newview/llpanelaudioprefs.h @@ -54,6 +54,9 @@ public: virtual BOOL postBuild(); static void* createVolumePanel(void* data); + static void onShowMediaFilter(void* data); + + void updateIsLoggedIn(const bool); private: void refreshValues(); @@ -75,6 +78,7 @@ private: BOOL mPreviousStreamingMusic; BOOL mPreviousStreamingVideo; + BOOL mPreviousEnableMediaFilter; BOOL mPreviousMuteAudio; BOOL mPreviousMuteWhenMinimized; }; diff --git a/linden/indra/newview/llviewerparcelmedia.cpp b/linden/indra/newview/llviewerparcelmedia.cpp index 01e86e2..386a86e 100644 --- a/linden/indra/newview/llviewerparcelmedia.cpp +++ b/linden/indra/newview/llviewerparcelmedia.cpp @@ -49,6 +49,7 @@ #include "llpluginclassmedia.h" #include "llnotify.h" #include "llsdserialize.h" +#include "llmemory.h" #include "lloverlaybar.h" #include "slfloatermediafilter.h" @@ -64,6 +65,7 @@ LLSD LLViewerParcelMedia::sMediaFilterList; std::set LLViewerParcelMedia::sMediaQueries; std::set LLViewerParcelMedia::sAllowedMedia; std::set LLViewerParcelMedia::sDeniedMedia; +LLPointer LLViewerParcelMedia::sSavedMediaInfo; // Local functions bool callback_play_media(const LLSD& notification, const LLSD& response, LLParcel* parcel); @@ -186,7 +188,7 @@ void LLViewerParcelMedia::update(LLParcel* parcel) } // static -void LLViewerParcelMedia::play(LLParcel* parcel, bool filter) +void LLViewerParcelMedia::play(LLParcel* parcel, bool filter, const ECommandOrigin origin) { lldebugs << "LLViewerParcelMedia::play" << llendl; @@ -198,12 +200,13 @@ void LLViewerParcelMedia::play(LLParcel* parcel, bool filter) std::string media_url = parcel->getMediaURL(); LLStringUtil::trim(media_url); - if (!media_url.empty() && gSavedSettings.getBOOL("MediaEnableFilter") && (filter || !allowedMedia(media_url))) + if (!media_url.empty() && gSavedSettings.getBOOL("MediaEnableFilter") && filter + && (!allowedMedia(media_url) || origin == COMMAND_ORIGIN_REMOTE)) { // If filtering is needed or in case media_url just changed // to something we did not yet approve. LLViewerParcelMediaAutoPlay::playStarted(); - filterMedia(parcel, 0); + filterMedia(parcel, 0, origin); return; } @@ -384,7 +387,7 @@ void LLViewerParcelMedia::processParcelMediaCommandMessage( LLMessageSystem *msg else { LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - play(parcel); + play(parcel, true, COMMAND_ORIGIN_REMOTE); } } else @@ -400,7 +403,7 @@ void LLViewerParcelMedia::processParcelMediaCommandMessage( LLMessageSystem *msg if(sMediaImpl.isNull()) { LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - play(parcel); + play(parcel, true, COMMAND_ORIGIN_REMOTE); } seek(time); } @@ -437,33 +440,38 @@ void LLViewerParcelMedia::processParcelMediaUpdate( LLMessageSystem *msg, void * } LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - BOOL same = FALSE; if (parcel) { - same = ((parcel->getMediaURL() == media_url) && - (parcel->getMediaType() == media_type) && - (parcel->getMediaID() == media_id) && - (parcel->getMediaWidth() == media_width) && - (parcel->getMediaHeight() == media_height) && - (parcel->getMediaAutoScale() == media_auto_scale) && - (parcel->getMediaLoop() == media_loop)); - - if (!same) + LLViewerParcelMediaInfo* new_info = new LLViewerParcelMediaInfo(media_url, media_type, media_id, media_width, media_height, media_auto_scale, media_loop); + LLViewerParcelMediaInfo* current_info = new LLViewerParcelMediaInfo(parcel); + if (new_info != current_info) { + if (!sSavedMediaInfo || (sSavedMediaInfo && !sSavedMediaInfo->sameParcel(parcel))) + { + // only save if no previously saved media info, because + // we want to remeber the original parcel media info. + sSavedMediaInfo = current_info; + } // temporarily store these new values in the parcel - parcel->setMediaURL(media_url); - parcel->setMediaType(media_type); - parcel->setMediaID(media_id); - parcel->setMediaWidth(media_width); - parcel->setMediaHeight(media_height); - parcel->setMediaAutoScale(media_auto_scale); - parcel->setMediaLoop(media_loop); - - play(parcel); + new_info->applyToParcel(parcel); + + play(parcel, true, COMMAND_ORIGIN_REMOTE); } } } + +//static +void LLViewerParcelMedia::undoParcelMediaUpdate() +{ + LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); + if (sSavedMediaInfo.notNull() && parcel) + { + sSavedMediaInfo->applyToParcel(parcel); + } + sSavedMediaInfo = NULL; +} + // Static ///////////////////////////////////////////////////////////////////////////////////////// void LLViewerParcelMedia::sendMediaNavigateMessage(const std::string& url) @@ -619,7 +627,7 @@ void LLViewerParcelMedia::playStreamingMusic(LLParcel* parcel, bool filter) { // If filtering is needed or in case music_url just changed // to something we did not yet approve. - filterMedia(parcel, 1); + filterMedia(parcel, 1, COMMAND_ORIGIN_LOCAL); } else if (gAudioStream) { @@ -675,13 +683,13 @@ bool LLViewerParcelMedia::allowedMedia(std::string media_url) return false; } -void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type) +void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type, const ECommandOrigin origin) { std::string media_action; std::string media_url; std::string domain; std::string ip; - + if (parcel != LLViewerParcelMgr::getInstance()->getAgentParcel()) { // The parcel just changed (may occur right out after a TP) @@ -775,12 +783,33 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type) } if (media_action == "ignore") { - if (type == 1) + if (type == 0) + { + undoParcelMediaUpdate(); + } + else if (type == 1) { LLViewerParcelMedia::stopStreamingMusic(); } return; } + // skip local-originating play commands, unless the url is blacklisted. + if (gSavedSettings.getBOOL("MediaFilterOnlyRemoteCommands") + && (origin != COMMAND_ORIGIN_REMOTE) + && (media_action != "ignore")) + { + sAllowedMedia.insert(domain); + SLFloaterMediaFilter::setDirty(); + if (type == 0) + { + play(parcel, false); + } + else + { + playStreamingMusic(parcel, false); + } + return; + } LLSD args; if (ip != domain && domain.find('/') == std::string::npos) @@ -795,6 +824,10 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type) if (media_action == "deny") { LLNotifications::instance().add("MediaBlocked", args); + if (type == 0) + { + undoParcelMediaUpdate(); + } if (type == 1) { LLViewerParcelMedia::stopStreamingMusic(); @@ -873,10 +906,15 @@ void callback_media_alert(const LLSD ¬ification, const LLSD &response, LLParc { LLViewerParcelMedia::sDeniedMedia.insert(ip); } - if (type == 1) + if (type == 0) + { + LLViewerParcelMedia::undoParcelMediaUpdate(); + } + else if (type == 1) { LLViewerParcelMedia::stopStreamingMusic(); } + if (option == 1) // Deny { LLNotifications::instance().add("MediaBlocked", args); @@ -1040,3 +1078,65 @@ std::string LLViewerParcelMedia::extractDomain(std::string url) return url; } +LLViewerParcelMediaInfo::LLViewerParcelMediaInfo(const std::string url, + const std::string type, + const LLUUID media_id, + const S32 width, + const S32 height, + const U8 scale, + const U8 loop) + : + mMediaURL(url), + mMediaType(type), + mMediaID(media_id), + mMediaWidth(width), + mMediaHeight(height), + mMediaAutoScale(scale), + mMediaLoop(loop) +{ + LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); + mParcelLocalID = parcel ? parcel->getLocalID() : 0; +} + +LLViewerParcelMediaInfo::LLViewerParcelMediaInfo(const LLParcel* parcel) +{ + mMediaURL = parcel->getMediaURL(); + mMediaType = parcel->getMediaType(); + mMediaID = parcel->getMediaID(); + mMediaWidth = parcel->getMediaWidth(); + mMediaHeight = parcel->getMediaHeight(); + mMediaAutoScale = parcel->getMediaAutoScale(); + mMediaLoop = parcel->getMediaLoop(); + mParcelLocalID = parcel->getLocalID(); +} + +void LLViewerParcelMediaInfo::applyToParcel(LLParcel* parcel) +{ + if (parcel && sameParcel(parcel)) + { + parcel->setMediaURL(mMediaURL); + parcel->setMediaType(mMediaType); + parcel->setMediaID(mMediaID); + parcel->setMediaWidth(mMediaWidth); + parcel->setMediaHeight(mMediaHeight); + parcel->setMediaAutoScale(mMediaAutoScale); + parcel->setMediaLoop(mMediaLoop); + } +} + +bool LLViewerParcelMediaInfo::sameParcel(const LLParcel* parcel) const +{ + return parcel && (parcel->getLocalID() == mParcelLocalID); +} + +bool LLViewerParcelMediaInfo::operator==(const LLViewerParcelMediaInfo &rhs) const +{ + return (mMediaURL == rhs.mMediaURL) && + (mMediaType == rhs.mMediaType) && + (mMediaID == rhs.mMediaID) && + (mMediaWidth == rhs.mMediaWidth) && + (mMediaHeight == rhs.mMediaHeight) && + (mMediaAutoScale == rhs.mMediaAutoScale) && + (mMediaLoop == rhs.mMediaLoop) && + (mParcelLocalID == rhs.mParcelLocalID); +} \ No newline at end of file diff --git a/linden/indra/newview/llviewerparcelmedia.h b/linden/indra/newview/llviewerparcelmedia.h index 7531a0f..f4c4312 100644 --- a/linden/indra/newview/llviewerparcelmedia.h +++ b/linden/indra/newview/llviewerparcelmedia.h @@ -34,6 +34,7 @@ #define LLVIEWERPARCELMEDIA_H #include "llviewermedia.h" +#include "llmemory.h" // For use by other patches so they know that media filtering is implemented. #define MEDIA_FILTERING 1 @@ -41,6 +42,7 @@ class LLMessageSystem; class LLParcel; class LLViewerParcelMediaNavigationObserver; +class LLViewerParcelMediaInfo; // This class understands land parcels, network traffic, LSL media @@ -49,6 +51,13 @@ class LLViewerParcelMediaNavigationObserver; class LLViewerParcelMedia : public LLViewerMediaObserver { LOG_CLASS(LLViewerParcelMedia); + private: + typedef enum e_command_origin + { + COMMAND_ORIGIN_LOCAL, + COMMAND_ORIGIN_REMOTE + } ECommandOrigin; + public: static void initClass(); static void cleanupClass(); @@ -57,14 +66,14 @@ class LLViewerParcelMedia : public LLViewerMediaObserver // called when the agent's parcel has a new URL, or the agent has // walked on to a new parcel with media - static void play(LLParcel* parcel, bool filter = true); + static void play(LLParcel* parcel, bool filter = true, const ECommandOrigin origin = COMMAND_ORIGIN_LOCAL); // user clicked play button in media transport controls static void playStreamingMusic(LLParcel* parcel, bool filter = true); // play the parcel music stream static void stopStreamingMusic(); // stop the parcel music stream - static void filterMedia(LLParcel* parcel, U32 type); // type: 0 = media, 1 = streaming music + static void filterMedia(LLParcel* parcel, U32 type, const ECommandOrigin origin); // type: 0 = media, 1 = streaming music static bool allowedMedia(std::string media_url); static bool loadDomainFilterList(); @@ -90,6 +99,7 @@ class LLViewerParcelMedia : public LLViewerMediaObserver static void processParcelMediaCommandMessage( LLMessageSystem *msg, void ** ); static void processParcelMediaUpdate( LLMessageSystem *msg, void ** ); + static void undoParcelMediaUpdate(); // reset the parcel's media to what it was before ParcelMediaUpdate static void sendMediaNavigateMessage(const std::string& url); // inherited from LLViewerMediaObserver @@ -107,6 +117,7 @@ class LLViewerParcelMedia : public LLViewerMediaObserver static std::set sMediaQueries; static std::set sAllowedMedia; static std::set sDeniedMedia; + static LLPointer sSavedMediaInfo; // The parcel original media (before a remote command is applied) }; @@ -120,4 +131,29 @@ public: }; +class LLViewerParcelMediaInfo : public LLRefCount +{ +public: + LLViewerParcelMediaInfo(const std::string url, + const std::string type, + const LLUUID media_id, + const S32 width, + const S32 height, + const U8 scale, + const U8 loop); + LLViewerParcelMediaInfo(const LLParcel* parcel); + ~LLViewerParcelMediaInfo() {} + void applyToParcel(LLParcel* parcel); + bool sameParcel(const LLParcel* parcel) const; + bool operator==(const LLViewerParcelMediaInfo &rhs) const; +private: + std::string mMediaURL; + std::string mMediaType; + LLUUID mMediaID; + S32 mMediaWidth; + S32 mMediaHeight; + U8 mMediaAutoScale; + U8 mMediaLoop; + S32 mParcelLocalID; +}; #endif diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml b/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml index 5faaf1a..f0fb3a3 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml @@ -1,9 +1,22 @@ + height="410" width="600" min_height="350" min_width="600"> + + + + + + bottom_delta="-40" left="20" height="20" width="560" follows="left|right|top"> Domains in bold are in the persistent list (i.e. they are whitelisted or blacklisted). + bottom_delta="-200" left="15" height="200" width="280"> @@ -69,10 +82,13 @@ tool_tip="Enter the new URL, domain name, IP or scripted object HTTP server path here" select_all_on_focus_received="true" select_on_focus="true" bevel_style="in" border_style="line" border_thickness="1" - bottom_delta="-22" right="-100" height="20" left="15" follows="left|bottom|right"/> + bottom_delta="-22" right="-180" height="20" left="15" follows="left|bottom|right"/> +