PageRenderTime 183ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llpanellandaudio.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 203 lines | 117 code | 40 blank | 46 comment | 9 complexity | a728b0b8f8cbab0e1fff1b3d36a464c5 MD5 | raw file
Possible License(s): LGPL-2.1
  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=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "llviewerprecompiledheaders.h"
  28. #include "llpanellandaudio.h"
  29. // viewer includes
  30. #include "llmimetypes.h"
  31. #include "llviewerparcelmgr.h"
  32. #include "llviewerregion.h"
  33. #include "lluictrlfactory.h"
  34. // library includes
  35. #include "llcheckboxctrl.h"
  36. #include "llcombobox.h"
  37. #include "llfloaterurlentry.h"
  38. #include "llfocusmgr.h"
  39. #include "lllineeditor.h"
  40. #include "llparcel.h"
  41. #include "lltextbox.h"
  42. #include "llradiogroup.h"
  43. #include "llspinctrl.h"
  44. #include "llsdutil.h"
  45. #include "lltexturectrl.h"
  46. #include "roles_constants.h"
  47. #include "llscrolllistctrl.h"
  48. // Values for the parcel voice settings radio group
  49. enum
  50. {
  51. kRadioVoiceChatEstate = 0,
  52. kRadioVoiceChatPrivate = 1,
  53. kRadioVoiceChatDisable = 2
  54. };
  55. //---------------------------------------------------------------------------
  56. // LLPanelLandAudio
  57. //---------------------------------------------------------------------------
  58. LLPanelLandAudio::LLPanelLandAudio(LLParcelSelectionHandle& parcel)
  59. : LLPanel(/*std::string("land_media_panel")*/), mParcel(parcel)
  60. {
  61. }
  62. // virtual
  63. LLPanelLandAudio::~LLPanelLandAudio()
  64. {
  65. }
  66. BOOL LLPanelLandAudio::postBuild()
  67. {
  68. mCheckSoundLocal = getChild<LLCheckBoxCtrl>("check sound local");
  69. childSetCommitCallback("check sound local", onCommitAny, this);
  70. mCheckParcelEnableVoice = getChild<LLCheckBoxCtrl>("parcel_enable_voice_channel");
  71. childSetCommitCallback("parcel_enable_voice_channel", onCommitAny, this);
  72. // This one is always disabled so no need for a commit callback
  73. mCheckEstateDisabledVoice = getChild<LLCheckBoxCtrl>("parcel_enable_voice_channel_is_estate_disabled");
  74. mCheckParcelVoiceLocal = getChild<LLCheckBoxCtrl>("parcel_enable_voice_channel_local");
  75. childSetCommitCallback("parcel_enable_voice_channel_local", onCommitAny, this);
  76. mMusicURLEdit = getChild<LLLineEditor>("music_url");
  77. childSetCommitCallback("music_url", onCommitAny, this);
  78. mCheckAVSoundAny = getChild<LLCheckBoxCtrl>("all av sound check");
  79. childSetCommitCallback("all av sound check", onCommitAny, this);
  80. mCheckAVSoundGroup = getChild<LLCheckBoxCtrl>("group av sound check");
  81. childSetCommitCallback("group av sound check", onCommitAny, this);
  82. return TRUE;
  83. }
  84. // public
  85. void LLPanelLandAudio::refresh()
  86. {
  87. LLParcel *parcel = mParcel->getParcel();
  88. if (!parcel)
  89. {
  90. clearCtrls();
  91. }
  92. else
  93. {
  94. // something selected, hooray!
  95. // Display options
  96. BOOL can_change_media = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_MEDIA);
  97. mCheckSoundLocal->set( parcel->getSoundLocal() );
  98. mCheckSoundLocal->setEnabled( can_change_media );
  99. bool allow_voice = parcel->getParcelFlagAllowVoice();
  100. LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion();
  101. if (region && region->isVoiceEnabled())
  102. {
  103. mCheckEstateDisabledVoice->setVisible(false);
  104. mCheckParcelEnableVoice->setVisible(true);
  105. mCheckParcelEnableVoice->setEnabled( can_change_media );
  106. mCheckParcelEnableVoice->set(allow_voice);
  107. mCheckParcelVoiceLocal->setEnabled( can_change_media && allow_voice );
  108. }
  109. else
  110. {
  111. // Voice disabled at estate level, overrides parcel settings
  112. // Replace the parcel voice checkbox with a disabled one
  113. // labelled with an explanatory message
  114. mCheckEstateDisabledVoice->setVisible(true);
  115. mCheckParcelEnableVoice->setVisible(false);
  116. mCheckParcelEnableVoice->setEnabled(false);
  117. mCheckParcelVoiceLocal->setEnabled(false);
  118. }
  119. mCheckParcelEnableVoice->set(allow_voice);
  120. mCheckParcelVoiceLocal->set(!parcel->getParcelFlagUseEstateVoiceChannel());
  121. mMusicURLEdit->setText(parcel->getMusicURL());
  122. mMusicURLEdit->setEnabled( can_change_media );
  123. BOOL can_change_av_sounds = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS) && parcel->getHaveNewParcelLimitData();
  124. mCheckAVSoundAny->set(parcel->getAllowAnyAVSounds());
  125. mCheckAVSoundAny->setEnabled(can_change_av_sounds);
  126. mCheckAVSoundGroup->set(parcel->getAllowGroupAVSounds() || parcel->getAllowAnyAVSounds()); // On if "Everyone" is on
  127. mCheckAVSoundGroup->setEnabled(can_change_av_sounds && !parcel->getAllowAnyAVSounds()); // Enabled if "Everyone" is off
  128. }
  129. }
  130. // static
  131. void LLPanelLandAudio::onCommitAny(LLUICtrl*, void *userdata)
  132. {
  133. LLPanelLandAudio *self = (LLPanelLandAudio *)userdata;
  134. LLParcel* parcel = self->mParcel->getParcel();
  135. if (!parcel)
  136. {
  137. return;
  138. }
  139. // Extract data from UI
  140. BOOL sound_local = self->mCheckSoundLocal->get();
  141. std::string music_url = self->mMusicURLEdit->getText();
  142. BOOL voice_enabled = self->mCheckParcelEnableVoice->get();
  143. BOOL voice_estate_chan = !self->mCheckParcelVoiceLocal->get();
  144. BOOL any_av_sound = self->mCheckAVSoundAny->get();
  145. BOOL group_av_sound = TRUE; // If set to "Everyone" then group is checked as well
  146. if (!any_av_sound)
  147. { // If "Everyone" is off, use the value from the checkbox
  148. group_av_sound = self->mCheckAVSoundGroup->get();
  149. }
  150. // Remove leading/trailing whitespace (common when copying/pasting)
  151. LLStringUtil::trim(music_url);
  152. // Push data into current parcel
  153. parcel->setParcelFlag(PF_ALLOW_VOICE_CHAT, voice_enabled);
  154. parcel->setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, voice_estate_chan);
  155. parcel->setParcelFlag(PF_SOUND_LOCAL, sound_local);
  156. parcel->setMusicURL(music_url);
  157. parcel->setAllowAnyAVSounds(any_av_sound);
  158. parcel->setAllowGroupAVSounds(group_av_sound);
  159. // Send current parcel data upstream to server
  160. LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel );
  161. // Might have changed properties, so let's redraw!
  162. self->refresh();
  163. }