summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelnearbymedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelnearbymedia.cpp')
-rw-r--r--indra/newview/llpanelnearbymedia.cpp83
1 files changed, 69 insertions, 14 deletions
diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp
index c911f102a1..83f0fca1be 100644
--- a/indra/newview/llpanelnearbymedia.cpp
+++ b/indra/newview/llpanelnearbymedia.cpp
@@ -29,6 +29,7 @@
#include "llpanelnearbymedia.h"
#include "llaudioengine.h"
+#include "llbase64.h"
#include "llcheckboxctrl.h"
#include "llclipboard.h"
#include "llcombobox.h"
@@ -107,6 +108,11 @@ LLPanelNearByMedia::LLPanelNearByMedia()
{
onMenuAction(data);
});
+ mEnableCallbackRegistrar.add("SelectedMediaCtrl.Visible",
+ [this](LLUICtrl* ctrl, const LLSD& data)
+ {
+ return onMenuVisible(data);
+ });
buildFromFile( "panel_nearby_media.xml");
}
@@ -270,6 +276,16 @@ BOOL LLPanelNearByMedia::handleRightMouseDown(S32 x, S32 y, MASK mask)
return LLPanelPulldown::handleRightMouseDown(x, y, mask);
}
+
+void LLPanelNearByMedia::onVisibilityChange(BOOL new_visibility)
+{
+ if (!new_visibility && mContextMenu->getVisible())
+ {
+ gMenuHolder->hideMenus();
+ }
+ LLPanelPulldown::onVisibilityChange(new_visibility);
+}
+
bool LLPanelNearByMedia::getParcelAudioAutoStart()
{
return mParcelAudioAutoStart;
@@ -1213,34 +1229,49 @@ void LLPanelNearByMedia::onClickSelectedMediaUnzoom()
void LLPanelNearByMedia::onMenuAction(const LLSD& userdata)
{
const std::string command_name = userdata.asString();
- if ("copy" == command_name)
+ if ("copy_url" == command_name)
{
LLClipboard::instance().reset();
- LLUUID selected_media_id = mMediaList->getValue().asUUID();
- std::string url;
+ std::string url = getSelectedUrl();
- if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
+ if (!url.empty())
{
- url = LLViewerMedia::getInstance()->getParcelAudioURL();
+ LLClipboard::instance().copyToClipboard(utf8str_to_wstring(url), 0, url.size());
}
- else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID)
+ }
+ else if ("copy_data" == command_name)
+ {
+ LLClipboard::instance().reset();
+ std::string url = getSelectedUrl();
+ static const std::string encoding_specifier = "base64,";
+ size_t pos = url.find(encoding_specifier);
+ if (pos != std::string::npos)
{
- url = LLViewerParcelMedia::getInstance()->getURL();
+ pos += encoding_specifier.size();
+ std::string res = LLBase64::decodeAsString(url.substr(pos));
+ LLClipboard::instance().copyToClipboard(utf8str_to_wstring(res), 0, res.size());
}
else
{
- LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(selected_media_id);
- if (NULL != impl)
- {
- url = impl->getCurrentMediaURL();
- }
+ url = LLURI::unescape(url);
+ LLClipboard::instance().copyToClipboard(utf8str_to_wstring(url), 0, url.size());
}
+ }
+}
- if (!url.empty())
+bool LLPanelNearByMedia::onMenuVisible(const LLSD& userdata)
+{
+ const std::string command_name = userdata.asString();
+ if ("copy_data" == command_name)
+ {
+ std::string url = getSelectedUrl();
+ if (url.rfind("data:", 0) == 0)
{
- LLClipboard::instance().copyToClipboard(utf8str_to_wstring(url), 0, url.size());
+ // might be a a good idea to permit text/html only
+ return true;
}
}
+ return false;
}
// static
@@ -1268,3 +1299,27 @@ void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::strin
}
}
+std::string LLPanelNearByMedia::getSelectedUrl()
+{
+ std::string url;
+ LLUUID selected_media_id = mMediaList->getValue().asUUID();
+ if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
+ {
+ url = LLViewerMedia::getInstance()->getParcelAudioURL();
+ }
+ else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID)
+ {
+ url = LLViewerParcelMedia::getInstance()->getURL();
+ }
+ else
+ {
+ LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(selected_media_id);
+ if (NULL != impl)
+ {
+ std::string name;
+ getNameAndUrlHelper(impl, name, url, mEmptyNameString);
+ }
+ }
+ return url;
+}
+