aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanellandmedia.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llpanellandmedia.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llpanellandmedia.cpp')
-rw-r--r--linden/indra/newview/llpanellandmedia.cpp401
1 files changed, 401 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanellandmedia.cpp b/linden/indra/newview/llpanellandmedia.cpp
new file mode 100644
index 0000000..c8f79b5
--- /dev/null
+++ b/linden/indra/newview/llpanellandmedia.cpp
@@ -0,0 +1,401 @@
1/**
2 * @file llpanellandmedia.cpp
3 * @brief Allows configuration of "media" for a land parcel,
4 * for example movies, web pages, and audio.
5 *
6 * $LicenseInfo:firstyear=2007&license=viewergpl$
7 *
8 * Copyright (c) 2007-2008, Linden Research, Inc.
9 *
10 * Second Life Viewer Source Code
11 * The source code in this file ("Source Code") is provided by Linden Lab
12 * to you under the terms of the GNU General Public License, version 2.0
13 * ("GPL"), unless you have obtained a separate licensing agreement
14 * ("Other License"), formally executed by you and Linden Lab. Terms of
15 * the GPL can be found in doc/GPL-license.txt in this distribution, or
16 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
17 *
18 * There are special exceptions to the terms and conditions of the GPL as
19 * it is applied to this Source Code. View the full text of the exception
20 * in the file doc/FLOSS-exception.txt in this software distribution, or
21 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#include "llviewerprecompiledheaders.h"
34
35#include "llpanellandmedia.h"
36
37// viewer includes
38#include "llmimetypes.h"
39#include "llviewerparcelmgr.h"
40#include "llvieweruictrlfactory.h"
41
42// library includes
43#include "llcheckboxctrl.h"
44#include "llcombobox.h"
45#include "llfloaterurlentry.h"
46#include "llfocusmgr.h"
47#include "lllineeditor.h"
48#include "llparcel.h"
49#include "lltextbox.h"
50#include "llradiogroup.h"
51#include "llspinctrl.h"
52#include "llsdutil.h"
53#include "lltexturectrl.h"
54#include "roles_constants.h"
55
56// Values for the parcel voice settings radio group
57enum
58{
59 kRadioVoiceChatEstate = 0,
60 kRadioVoiceChatPrivate = 1,
61 kRadioVoiceChatDisable = 2
62};
63
64//---------------------------------------------------------------------------
65// LLPanelLandMedia
66//---------------------------------------------------------------------------
67
68LLPanelLandMedia::LLPanelLandMedia(LLParcelSelectionHandle& parcel)
69: LLPanel("land_media_panel"), mParcel(parcel)
70{
71}
72
73
74// virtual
75LLPanelLandMedia::~LLPanelLandMedia()
76{
77 // close LLFloaterURLEntry?
78}
79
80
81BOOL LLPanelLandMedia::postBuild()
82{
83 mCheckSoundLocal = LLUICtrlFactory::getCheckBoxByName(this, "check sound local");
84 childSetCommitCallback("check sound local", onCommitAny, this);
85
86 mRadioVoiceChat = LLUICtrlFactory::getRadioGroupByName(this, "parcel_voice_channel");
87 childSetCommitCallback("parcel_voice_channel", onCommitAny, this);
88
89 mMusicURLEdit = LLUICtrlFactory::getLineEditorByName(this, "music_url");
90 childSetCommitCallback("music_url", onCommitAny, this);
91
92 mMediaTextureCtrl = LLViewerUICtrlFactory::getTexturePickerByName(this, "media texture");
93 if (mMediaTextureCtrl)
94 {
95 mMediaTextureCtrl->setCommitCallback( onCommitAny );
96 mMediaTextureCtrl->setCallbackUserData( this );
97 mMediaTextureCtrl->setAllowNoTexture ( TRUE );
98 mMediaTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
99 mMediaTextureCtrl->setNonImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
100 }
101 else
102 {
103 llwarns << "LLViewerUICtrlFactory::getTexturePickerByName() returned NULL for 'media texure'" << llendl;
104 }
105
106 mMediaAutoScaleCheck = LLUICtrlFactory::getCheckBoxByName(this, "media_auto_scale");
107 childSetCommitCallback("media_auto_scale", onCommitAny, this);
108
109 mMediaLoopCheck = LLUICtrlFactory::getCheckBoxByName(this, "media_loop");
110 childSetCommitCallback("media_loop", onCommitAny, this);
111
112 mMediaUrlCheck = LLUICtrlFactory::getCheckBoxByName(this, "hide_media_url");
113 childSetCommitCallback("hide_media_url", onCommitAny, this);
114
115 mMusicUrlCheck = LLUICtrlFactory::getCheckBoxByName(this, "hide_music_url");
116 childSetCommitCallback("hide_music_url", onCommitAny, this);
117
118 mMediaURLEdit = LLUICtrlFactory::getLineEditorByName(this, "media_url");
119 childSetCommitCallback("media_url", onCommitAny, this);
120
121 mMediaDescEdit = LLUICtrlFactory::getLineEditorByName(this, "url_description");
122 childSetCommitCallback("url_description", onCommitAny, this);
123
124 mMediaTypeCombo = LLUICtrlFactory::getComboBoxByName(this, "media type");
125 childSetCommitCallback("media type", onCommitType, this);
126 populateMIMECombo();
127 mMediaTypeCombo->sortByName();
128
129 mMediaWidthCtrl = LLUICtrlFactory::getSpinnerByName(this, "media_size_width");
130 childSetCommitCallback("media_size_width", onCommitAny, this);
131 mMediaHeightCtrl = LLUICtrlFactory::getSpinnerByName(this, "media_size_height");
132 childSetCommitCallback("media_size_height", onCommitAny, this);
133 mMediaSizeCtrlLabel = LLUICtrlFactory::getTextBoxByName(this, "media_size");
134
135 mSetURLButton = LLUICtrlFactory::getButtonByName(this, "set_media_url");
136 childSetAction("set_media_url", onSetBtn, this);
137
138 return TRUE;
139}
140
141
142// public
143void LLPanelLandMedia::refresh()
144{
145 LLParcel *parcel = mParcel->getParcel();
146
147 if (!parcel)
148 {
149 clearCtrls();
150 }
151 else
152 {
153 // something selected, hooray!
154
155 // Display options
156 BOOL can_change_media = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_MEDIA);
157
158 mCheckSoundLocal->set( parcel->getSoundLocal() );
159 mCheckSoundLocal->setEnabled( can_change_media );
160
161 if(parcel->getVoiceEnabled())
162 {
163 if(parcel->getVoiceUseEstateChannel())
164 mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatEstate);
165 else
166 mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatPrivate);
167 }
168 else
169 {
170 mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatDisable);
171 }
172
173 mRadioVoiceChat->setEnabled( can_change_media );
174
175 mMusicURLEdit->setText(parcel->getMusicURL());
176 mMusicURLEdit->setEnabled( can_change_media );
177
178 mMediaURLEdit->setText(parcel->getMediaURL());
179 mMediaURLEdit->setEnabled( FALSE );
180
181 mMediaDescEdit->setText(LLString(parcel->getMediaDesc()));
182 mMediaDescEdit->setEnabled( can_change_media );
183
184 std::string mime_type = parcel->getMediaType();
185 if (mime_type.empty())
186 {
187 mime_type = "none/none";
188 }
189 setMediaType(mime_type);
190 mMediaTypeCombo->setEnabled( can_change_media );
191 childSetText("mime_type", mime_type);
192
193 mMediaUrlCheck->set( parcel->getObscureMedia() );
194 mMediaUrlCheck->setEnabled( can_change_media );
195
196 mMusicUrlCheck->set( parcel->getObscureMusic() );
197 mMusicUrlCheck->setEnabled( can_change_media );
198
199 // don't display urls if you're not able to change it
200 // much requested change in forums so people can't 'steal' urls
201 // NOTE: bug#2009 means this is still vunerable - however, bug
202 // should be closed since this bug opens up major security issues elsewhere.
203 bool obscure_media = ! can_change_media && parcel->getObscureMedia();
204 bool obscure_music = ! can_change_media && parcel->getObscureMusic();
205
206 // Special code to disable asterixes for html type
207 if(mime_type == "text/html")
208 {
209 obscure_media = false;
210 mMediaUrlCheck->set( 0 );
211 mMediaUrlCheck->setEnabled( false );
212 }
213
214 mMusicURLEdit->setDrawAsterixes( obscure_music );
215 mMediaURLEdit->setDrawAsterixes( obscure_media );
216
217 mMediaAutoScaleCheck->set( parcel->getMediaAutoScale () );
218 mMediaAutoScaleCheck->setEnabled ( can_change_media );
219
220 // Special code to disable looping checkbox for HTML MIME type
221 // (DEV-10042 -- Parcel Media: "Loop Media" should be disabled for static media types)
222 bool allow_looping = LLMIMETypes::findAllowLooping( mime_type );
223 if ( allow_looping )
224 mMediaLoopCheck->set( parcel->getMediaLoop () );
225 else
226 mMediaLoopCheck->set( false );
227 mMediaLoopCheck->setEnabled ( can_change_media && allow_looping );
228
229 // disallow media size change for mime types that don't allow it
230 bool allow_resize = LLMIMETypes::findAllowResize( mime_type );
231 if ( allow_resize )
232 mMediaWidthCtrl->setValue( parcel->getMediaWidth() );
233 else
234 mMediaWidthCtrl->setValue( 0 );
235 mMediaWidthCtrl->setEnabled ( can_change_media && allow_resize );
236
237 if ( allow_resize )
238 mMediaHeightCtrl->setValue( parcel->getMediaHeight() );
239 else
240 mMediaHeightCtrl->setValue( 0 );
241 mMediaHeightCtrl->setEnabled ( can_change_media && allow_resize );
242
243 // enable/disable for text label for completeness
244 mMediaSizeCtrlLabel->setEnabled( can_change_media && allow_resize );
245
246 LLUUID tmp = parcel->getMediaID();
247 mMediaTextureCtrl->setImageAssetID ( parcel->getMediaID() );
248 mMediaTextureCtrl->setEnabled( can_change_media );
249
250 mSetURLButton->setEnabled( can_change_media );
251
252 #if 0
253 // there is a media url and a media texture selected
254 if ( ( ! ( std::string ( parcel->getMediaURL() ).empty () ) ) && ( ! ( parcel->getMediaID ().isNull () ) ) )
255 {
256 // turn on transport controls if allowed for this parcel
257 mMediaStopButton->setEnabled ( editable );
258 mMediaStartButton->setEnabled ( editable );
259 }
260 else
261 {
262 // no media url or no media texture
263 mMediaStopButton->setEnabled ( FALSE );
264 mMediaStartButton->setEnabled ( FALSE );
265 };
266 #endif
267
268 LLFloaterURLEntry* floater_url_entry = (LLFloaterURLEntry*)mURLEntryFloater.get();
269 if (floater_url_entry)
270 {
271 floater_url_entry->updateFromLandMediaPanel();
272 }
273 }
274}
275
276void LLPanelLandMedia::populateMIMECombo()
277{
278 LLMIMETypes::mime_widget_set_map_t::const_iterator it;
279 for (it = LLMIMETypes::sWidgetMap.begin(); it != LLMIMETypes::sWidgetMap.end(); ++it)
280 {
281 const LLString& mime_type = it->first;
282 const LLMIMETypes::LLMIMEWidgetSet& info = it->second;
283 mMediaTypeCombo->add(info.mLabel, mime_type);
284 }
285}
286void LLPanelLandMedia::setMediaType(const LLString& mime_type)
287{
288 LLParcel *parcel = mParcel->getParcel();
289 if(parcel)
290 parcel->setMediaType(mime_type.c_str());
291
292 LLString media_key = LLMIMETypes::widgetType(mime_type);
293 mMediaTypeCombo->setValue(media_key);
294 childSetText("mime_type", mime_type);
295}
296
297void LLPanelLandMedia::setMediaURL(const LLString& media_url)
298{
299 mMediaURLEdit->setText(media_url);
300 mMediaURLEdit->onCommit();
301
302}
303
304// static
305void LLPanelLandMedia::onCommitType(LLUICtrl *ctrl, void *userdata)
306{
307 LLPanelLandMedia *self = (LLPanelLandMedia *)userdata;
308 std::string current_type = LLMIMETypes::widgetType(self->childGetText("mime_type"));
309 std::string new_type = self->mMediaTypeCombo->getValue();
310 if(current_type != new_type)
311 {
312 self->childSetText("mime_type", LLMIMETypes::findDefaultMimeType(new_type));
313 }
314 onCommitAny(ctrl, userdata);
315
316}
317// static
318void LLPanelLandMedia::onCommitAny(LLUICtrl *ctrl, void *userdata)
319{
320 LLPanelLandMedia *self = (LLPanelLandMedia *)userdata;
321
322 LLParcel* parcel = self->mParcel->getParcel();
323 if (!parcel)
324 {
325 return;
326 }
327
328 // Extract data from UI
329 BOOL sound_local = self->mCheckSoundLocal->get();
330 int voice_setting = self->mRadioVoiceChat->getSelectedIndex();
331 std::string music_url = self->mMusicURLEdit->getText();
332 std::string media_url = self->mMediaURLEdit->getText();
333 std::string media_desc = self->mMediaDescEdit->getText();
334 std::string mime_type = self->childGetText("mime_type");
335 U8 media_auto_scale = self->mMediaAutoScaleCheck->get();
336 U8 media_loop = self->mMediaLoopCheck->get();
337 U8 obscure_media = self->mMediaUrlCheck->get();
338 U8 obscure_music = self->mMusicUrlCheck->get();
339 S32 media_width = (S32)self->mMediaWidthCtrl->get();
340 S32 media_height = (S32)self->mMediaHeightCtrl->get();
341 LLUUID media_id = self->mMediaTextureCtrl->getImageAssetID();
342
343 self->childSetText("mime_type", mime_type);
344
345 BOOL voice_enabled;
346 BOOL voice_estate_chan;
347
348 switch(voice_setting)
349 {
350 default:
351 case kRadioVoiceChatEstate:
352 voice_enabled = TRUE;
353 voice_estate_chan = TRUE;
354 break;
355 case kRadioVoiceChatPrivate:
356 voice_enabled = TRUE;
357 voice_estate_chan = FALSE;
358 break;
359 case kRadioVoiceChatDisable:
360 voice_enabled = FALSE;
361 voice_estate_chan = FALSE;
362 break;
363 }
364
365 // Remove leading/trailing whitespace (common when copying/pasting)
366 LLString::trim(music_url);
367 LLString::trim(media_url);
368
369 // Push data into current parcel
370 parcel->setParcelFlag(PF_ALLOW_VOICE_CHAT, voice_enabled);
371 parcel->setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, voice_estate_chan);
372 parcel->setParcelFlag(PF_SOUND_LOCAL, sound_local);
373 parcel->setMusicURL(music_url.c_str());
374 parcel->setMediaURL(media_url.c_str());
375 parcel->setMediaType(mime_type.c_str());
376 parcel->setMediaDesc(media_desc.c_str());
377 parcel->setMediaWidth(media_width);
378 parcel->setMediaHeight(media_height);
379 parcel->setMediaID(media_id);
380 parcel->setMediaAutoScale ( media_auto_scale );
381 parcel->setMediaLoop ( media_loop );
382 parcel->setObscureMedia( obscure_media );
383 parcel->setObscureMusic( obscure_music );
384
385 // Send current parcel data upstream to server
386 gParcelMgr->sendParcelPropertiesUpdate( parcel );
387
388 // Might have changed properties, so let's redraw!
389 self->refresh();
390}
391// static
392void LLPanelLandMedia::onSetBtn(void *userdata)
393{
394 LLPanelLandMedia *self = (LLPanelLandMedia *)userdata;
395 self->mURLEntryFloater = LLFloaterURLEntry::show( self->getHandle() );
396 LLFloater* parent_floater = gFloaterView->getParentFloater(self);
397 if (parent_floater)
398 {
399 parent_floater->addDependentFloater(self->mURLEntryFloater.get());
400 }
401}