llpanellandaudio.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /**
  2. * @file llpanellandaudio.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-2009, 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
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #include "llviewerprecompiledheaders.h"
  34. #include "llpanellandaudio.h"
  35. #include "llcheckboxctrl.h"
  36. #include "lllineeditor.h"
  37. #include "llmimetypes.h"
  38. #include "llparcel.h"
  39. #include "llsdutil.h"
  40. #include "llradiogroup.h"
  41. #include "llfloaterurlentry.h"
  42. #include "lltexturectrl.h"
  43. #include "llviewerparcelmgr.h"
  44. #include "llviewerregion.h"
  45. #include "roles_constants.h"
  46. // Values for the parcel voice settings radio group
  47. enum
  48. {
  49. kRadioVoiceChatEstate = 0,
  50. kRadioVoiceChatPrivate = 1,
  51. kRadioVoiceChatDisable = 2
  52. };
  53. //---------------------------------------------------------------------------
  54. // LLPanelLandAudio
  55. //---------------------------------------------------------------------------
  56. LLPanelLandAudio::LLPanelLandAudio(LLParcelSelectionHandle& parcel)
  57. : LLPanel(),
  58. mParcel(parcel),
  59. mCheckSoundLocal(NULL),
  60. mRadioVoiceChat(NULL),
  61. mMusicURLEdit(NULL)
  62. {
  63. }
  64. //virtual
  65. bool LLPanelLandAudio::postBuild()
  66. {
  67. mCheckSoundLocal = getChild<LLCheckBoxCtrl>("check_sound_local");
  68. mCheckSoundLocal->setCommitCallback(onCommitAny);
  69. mCheckSoundLocal->setCallbackUserData(this);
  70. mRadioVoiceChat = getChild<LLRadioGroup>("parcel_voice_channel");
  71. mRadioVoiceChat->setCommitCallback(onCommitAny);
  72. mRadioVoiceChat->setCallbackUserData(this);
  73. mMusicURLEdit = getChild<LLLineEditor>("music_url");
  74. mMusicURLEdit->setCommitCallback(onCommitAny);
  75. mMusicURLEdit->setCallbackUserData(this);
  76. mCheckAVSoundAny = getChild<LLCheckBoxCtrl>("all av sound check");
  77. mCheckAVSoundAny->setCommitCallback(onCommitAny);
  78. mCheckAVSoundAny->setCallbackUserData(this);
  79. mCheckAVSoundGroup = getChild<LLCheckBoxCtrl>("group av sound check");
  80. mCheckAVSoundGroup->setCommitCallback(onCommitAny);
  81. mCheckAVSoundGroup->setCallbackUserData(this);
  82. return true;
  83. }
  84. //virtual
  85. void LLPanelLandAudio::refresh()
  86. {
  87. LLParcel* parcel = mParcel->getParcel();
  88. if (!parcel)
  89. {
  90. clearCtrls();
  91. }
  92. else // Something selected, hooray !
  93. {
  94. // Display options
  95. bool can_change_media =
  96. LLViewerParcelMgr::isParcelModifiableByAgent(parcel,
  97. GP_LAND_CHANGE_MEDIA);
  98. mMusicURLEdit->setText(parcel->getMusicURL());
  99. mMusicURLEdit->setEnabled(can_change_media);
  100. mCheckSoundLocal->set(parcel->getSoundLocal());
  101. mCheckSoundLocal->setEnabled(can_change_media);
  102. if (parcel->getParcelFlagAllowVoice())
  103. {
  104. if (parcel->getParcelFlagUseEstateVoiceChannel())
  105. {
  106. mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatEstate);
  107. }
  108. else
  109. {
  110. mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatPrivate);
  111. }
  112. }
  113. else
  114. {
  115. mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatDisable);
  116. }
  117. LLViewerRegion* region = gViewerParcelMgr.getSelectionRegion();
  118. mRadioVoiceChat->setEnabled(region && region->isVoiceEnabled() &&
  119. can_change_media);
  120. bool new_limits = parcel->getHaveNewParcelLimitData();
  121. bool can_change_av_sounds = new_limits &&
  122. LLViewerParcelMgr::isParcelModifiableByAgent(parcel,
  123. GP_LAND_OPTIONS);
  124. mCheckAVSoundAny->set(parcel->getAllowAnyAVSounds() || !new_limits);
  125. mCheckAVSoundAny->setEnabled(can_change_av_sounds);
  126. // On if "Everyone" is on
  127. mCheckAVSoundGroup->set(!new_limits ||
  128. parcel->getAllowGroupAVSounds() ||
  129. parcel->getAllowAnyAVSounds());
  130. // Enabled if "Everyone" is off
  131. mCheckAVSoundGroup->setEnabled(can_change_av_sounds &&
  132. !parcel->getAllowAnyAVSounds());
  133. }
  134. }
  135. //static
  136. void LLPanelLandAudio::onCommitAny(LLUICtrl*, void* userdata)
  137. {
  138. LLPanelLandAudio* self = (LLPanelLandAudio*)userdata;
  139. if (!self)
  140. {
  141. return;
  142. }
  143. LLParcel* parcel = self->mParcel->getParcel();
  144. if (!parcel)
  145. {
  146. return;
  147. }
  148. // Extract data from UI
  149. bool sound_local = self->mCheckSoundLocal->get();
  150. S32 voice_setting = self->mRadioVoiceChat->getSelectedIndex();
  151. std::string music_url = self->mMusicURLEdit->getText();
  152. bool voice_enabled, voice_estate_chan;
  153. switch (voice_setting)
  154. {
  155. default:
  156. case kRadioVoiceChatEstate:
  157. voice_enabled = true;
  158. voice_estate_chan = true;
  159. break;
  160. case kRadioVoiceChatPrivate:
  161. voice_enabled = true;
  162. voice_estate_chan = false;
  163. break;
  164. case kRadioVoiceChatDisable:
  165. voice_enabled = false;
  166. voice_estate_chan = false;
  167. break;
  168. }
  169. bool any_av_sound = self->mCheckAVSoundAny->get();
  170. // If set to "Everyone" then group is checked as well:
  171. bool group_av_sound = true;
  172. if (!any_av_sound)
  173. { // If "Everyone" is off, use the value from the checkbox
  174. group_av_sound = self->mCheckAVSoundGroup->get();
  175. }
  176. // Remove leading/trailing whitespace (common when copying/pasting)
  177. LLStringUtil::trim(music_url);
  178. // Push data into current parcel
  179. parcel->setParcelFlag(PF_ALLOW_VOICE_CHAT, voice_enabled);
  180. parcel->setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, voice_estate_chan);
  181. parcel->setParcelFlag(PF_SOUND_LOCAL, sound_local);
  182. parcel->setMusicURL(music_url);
  183. parcel->setAllowAnyAVSounds(any_av_sound);
  184. parcel->setAllowGroupAVSounds(group_av_sound);
  185. // Send current parcel data upstream to server
  186. gViewerParcelMgr.sendParcelPropertiesUpdate(parcel);
  187. // Might have changed properties, so let's redraw!
  188. self->refresh();
  189. }