diff options
author | Rick Pasetto <rick@lindenlab.com> | 2009-10-07 12:26:42 -0700 |
---|---|---|
committer | Rick Pasetto <rick@lindenlab.com> | 2009-10-07 12:26:42 -0700 |
commit | df48e66f7cc6711f1738e3a2817cf3b9a810c088 (patch) | |
tree | c9a660eab1d800081547e644cd39c4cfc52d541f /indra | |
parent | d2464757c6fa86caa30a13071cb43047de2dd2ff (diff) |
DEV-39168 - bounce back to the current URL (or, the home URL if current URL is "") if the server denies navigation
This refactors some of the bounceBack code into LLVOVolume.
It also changes an important rule: the edit panel now *will* send the
current URL to the server when you hit "OK". This change was done so
that if autoplay is on, we make sure the server gets the right data.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llmediadataclient.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llmediadataclient.h | 3 | ||||
-rw-r--r-- | indra/newview/llpanelmediasettingsgeneral.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llvovolume.cpp | 73 | ||||
-rw-r--r-- | indra/newview/llvovolume.h | 13 |
5 files changed, 91 insertions, 28 deletions
diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index da5e68af71..4dde381e97 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -568,8 +568,10 @@ void LLObjectMediaNavigateClient::Responder::error(U32 status, const std::string } else { // bounce the face back - bounceBack(); LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: http code=" << status << LL_ENDL; + const LLSD &payload = getRequest()->getPayload(); + // bounce the face back + getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); } } @@ -586,8 +588,9 @@ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content) if (ERROR_PERMISSION_DENIED_CODE == error_code) { LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Navigation denied: bounce back" << LL_ENDL; + const LLSD &payload = getRequest()->getPayload(); // bounce the face back - bounceBack(); + getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); } else { LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << @@ -600,23 +603,3 @@ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content) LLMediaDataClient::Responder::result(content); } } - - -void LLObjectMediaNavigateClient::Responder::bounceBack() -{ - const LLSD &payload = getRequest()->getPayload(); - U8 texture_index = (U8)(LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]; - viewer_media_t impl = getRequest()->getObject()->getMediaImpl(texture_index); - // Find the media entry for this navigate - LLMediaEntry* mep = NULL; - LLTextureEntry *te = getRequest()->getObject()->getTE(texture_index); - if(te) - { - mep = te->getMediaData(); - } - - if (mep && impl) - { -// impl->navigateTo(mep->getCurrentURL(), "", false, true); - } -} diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index 59c4334251..949e7239be 100644 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -166,6 +166,7 @@ private: static F64 getObjectScore(const ll_vo_volume_ptr_t &obj); }; + // PriorityQueue class PriorityQueue : public std::priority_queue< request_ptr_t, std::vector<request_ptr_t>, @@ -254,7 +255,7 @@ protected: virtual void error(U32 status, const std::string& reason); virtual void result(const LLSD &content); private: - void bounceBack(); + void mediaNavigateBounceBack(); }; }; diff --git a/indra/newview/llpanelmediasettingsgeneral.cpp b/indra/newview/llpanelmediasettingsgeneral.cpp index be40d6fb5f..725aa6327f 100644 --- a/indra/newview/llpanelmediasettingsgeneral.cpp +++ b/indra/newview/llpanelmediasettingsgeneral.cpp @@ -393,8 +393,7 @@ void LLPanelMediaSettingsGeneral::getValues( LLSD &fill_me_in ) fill_me_in[LLMediaEntry::AUTO_SCALE_KEY] = mAutoScale->getValue(); fill_me_in[LLMediaEntry::AUTO_ZOOM_KEY] = mAutoZoom->getValue(); fill_me_in[LLMediaEntry::CONTROLS_KEY] = mControls->getCurrentIndex(); - // XXX Don't send current URL! - //fill_me_in[LLMediaEntry::CURRENT_URL_KEY] = mCurrentURL->getValue(); + fill_me_in[LLMediaEntry::CURRENT_URL_KEY] = mCurrentURL->getValue(); fill_me_in[LLMediaEntry::HEIGHT_PIXELS_KEY] = mHeightPixels->getValue(); fill_me_in[LLMediaEntry::HOME_URL_KEY] = mHomeURL->getValue(); fill_me_in[LLMediaEntry::FIRST_CLICK_INTERACT_KEY] = mFirstClick->getValue(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 428de078de..83e65af054 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1713,6 +1713,72 @@ void LLVOVolume::syncMediaData(S32 texture_index, const LLSD &media_data, bool m // << ((NULL == te->getMediaData()) ? "NULL MEDIA DATA" : ll_pretty_print_sd(te->getMediaData()->asLLSD())) << llendl; } +void LLVOVolume::mediaNavigateBounceBack(U8 texture_index) +{ + // Find the media entry for this navigate + const LLMediaEntry* mep = NULL; + viewer_media_t impl = getMediaImpl(texture_index); + LLTextureEntry *te = getTE(texture_index); + if(te) + { + mep = te->getMediaData(); + } + + if (mep && impl) + { + std::string url = mep->getCurrentURL(); + if (url.empty()) + { + url = mep->getHomeURL(); + } + if (! url.empty()) + { + LL_INFOS("LLMediaDataClient") << "bouncing back to URL: " << url << LL_ENDL; + impl->navigateTo(url, "", false, true); + } + } +} + +bool LLVOVolume::hasNavigatePermission(const LLMediaEntry* media_entry) +{ + // NOTE: This logic duplicates the logic in the server (in particular, in llmediaservice.cpp). + if (NULL == media_entry ) return false; // XXX should we assert here? + + // The agent has permissions to navigate if: + // - agent has edit permissions, or + // - world permissions are on, or + // - group permissions are on, and agent_id is in the group, or + // - agent permissions are on, and agent_id is the owner + + if (permModify()) + { + return true; + } + + U8 media_perms = media_entry->getPermsInteract(); + + // World permissions + if (0 != (media_perms & LLMediaEntry::PERM_ANYONE)) + { + return true; + } + + // Group permissions + else if (0 != (media_perms & LLMediaEntry::PERM_GROUP) && permGroupOwner()) + { + return true; + } + + // Owner permissions + else if (0 != (media_perms & LLMediaEntry::PERM_OWNER) && permYouOwner()) + { + return true; + } + + return false; + +} + void LLVOVolume::mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin, LLViewerMediaObserver::EMediaEvent event) { switch(event) @@ -1746,6 +1812,10 @@ void LLVOVolume::mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin, { block_navigation = true; } + if (!block_navigation && !hasNavigatePermission(mep)) + { + block_navigation = true; + } } else { @@ -1757,8 +1827,7 @@ void LLVOVolume::mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin, llinfos << "blocking navigate to URI " << new_location << llendl; // "bounce back" to the current URL from the media entry - // NOTE: the only way block_navigation can be true is if we found the media entry, so we're guaranteed here that mep is not NULL. - impl->navigateTo(mep->getCurrentURL()); + mediaNavigateBounceBack(face_index); } else { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 250c3ed917..bb2b890000 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -233,7 +233,18 @@ public: BOOL canBeFlexible() const; BOOL setIsFlexible(BOOL is_flexible); - void updateObjectMediaData(const LLSD &media_data_duples); + // Functions that deal with media, or media navigation + + // Update this object's media data with the given media data array + // (typically this is only called upon a response from a server request) + void updateObjectMediaData(const LLSD &media_data_array); + + // Bounce back media at the given index to its current URL (or home URL, if current URL is empty) + void mediaNavigateBounceBack(U8 texture_index); + + // Returns whether or not this object has permission to navigate the given media entry + bool hasNavigatePermission(const LLMediaEntry* media_entry); + void mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin, LLViewerMediaObserver::EMediaEvent event); // Sync the given media data with the impl and the given te |