llfloateractivespeakers.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:23k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llfloateractivespeakers.cpp
  3.  * @brief Management interface for muting and controlling volume of residents currently speaking
  4.  *
  5.  * $LicenseInfo:firstyear=2005&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2005-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * 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. #include "llviewerprecompiledheaders.h"
  33. #include "llfloateractivespeakers.h"
  34. #include "llagent.h"
  35. #include "llavataractions.h"
  36. #include "llimview.h"
  37. #include "llscrolllistctrl.h"
  38. #include "llscrolllistitem.h"
  39. #include "llscrolllistcell.h"
  40. #include "llbutton.h"
  41. #include "lltextbox.h"
  42. #include "llmutelist.h"
  43. #include "llviewerobjectlist.h"
  44. #include "llsdutil.h"
  45. #include "llspeakers.h"
  46. #include "llviewercontrol.h"
  47. #include "llviewerwindow.h"
  48. #include "llvoicechannel.h"
  49. #include "llimfloater.h"
  50. using namespace LLOldEvents;
  51. const F32 RESORT_TIMEOUT = 5.f; // seconds of mouse inactivity before it's ok to sort regardless of mouse-in-view.
  52. //
  53. // LLFloaterActiveSpeakers
  54. //
  55. LLFloaterActiveSpeakers::LLFloaterActiveSpeakers(const LLSD& seed)
  56. : LLFloater(seed),
  57.   mPanel(NULL)
  58. {
  59. mFactoryMap["active_speakers_panel"] = LLCallbackMap(createSpeakersPanel, NULL);
  60. // // do not automatically open singleton floaters (as result of getInstance())
  61. // BOOL no_open = FALSE;
  62. // LLUICtrlFactory::getInstance()->buildFloater(this, "floater_active_speakers.xml", no_open);
  63. }
  64. LLFloaterActiveSpeakers::~LLFloaterActiveSpeakers()
  65. {
  66. }
  67. void LLFloaterActiveSpeakers::draw()
  68. {
  69. // update state every frame to get live amplitude feedback
  70. mPanel->refreshSpeakers();
  71. LLFloater::draw();
  72. }
  73. BOOL LLFloaterActiveSpeakers::postBuild()
  74. {
  75. mPanel = findChild<LLPanelActiveSpeakers>("active_speakers_panel");
  76. if (!mPanel) return FALSE;
  77. //RN: for now, we poll voice client every frame to get voice amplitude feedback
  78. //gVoiceClient->addObserver(this);
  79. mPanel->refreshSpeakers();
  80. return TRUE;
  81. }
  82. void LLFloaterActiveSpeakers::onChange()
  83. {
  84. //refresh();
  85. }
  86. //static
  87. void* LLFloaterActiveSpeakers::createSpeakersPanel(void* data)
  88. {
  89. // don't show text only speakers
  90. return new LLPanelActiveSpeakers(LLActiveSpeakerMgr::getInstance(), FALSE);
  91. }
  92. //
  93. // LLPanelActiveSpeakers::SpeakerMuteListener
  94. //
  95. bool LLPanelActiveSpeakers::SpeakerMuteListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
  96. {
  97. LLPointer<LLSpeaker> speakerp = (LLSpeaker*)event->getSource();
  98. if (speakerp.isNull()) return false;
  99. // update UI on confirmation of moderator mutes
  100. if (event->getValue().asString() == "voice")
  101. {
  102. mPanel->childSetValue("moderator_allow_voice", !speakerp->mModeratorMutedVoice);
  103. }
  104. if (event->getValue().asString() == "text")
  105. {
  106. mPanel->childSetValue("moderator_allow_text", !speakerp->mModeratorMutedText);
  107. }
  108. return true;
  109. }
  110. //
  111. // LLPanelActiveSpeakers::SpeakerAddListener
  112. //
  113. bool LLPanelActiveSpeakers::SpeakerAddListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
  114. {
  115. mPanel->addSpeaker(event->getValue().asUUID());
  116. return true;
  117. }
  118. //
  119. // LLPanelActiveSpeakers::SpeakerRemoveListener
  120. //
  121. bool LLPanelActiveSpeakers::SpeakerRemoveListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
  122. {
  123. mPanel->removeSpeaker(event->getValue().asUUID());
  124. return true;
  125. }
  126. //
  127. // LLPanelActiveSpeakers::SpeakerClearListener
  128. //
  129. bool LLPanelActiveSpeakers::SpeakerClearListener::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
  130. {
  131. mPanel->mSpeakerList->clearRows();
  132. return true;
  133. }
  134. //
  135. // LLPanelActiveSpeakers
  136. //
  137. LLPanelActiveSpeakers::LLPanelActiveSpeakers(LLSpeakerMgr* data_source, BOOL show_text_chatters)
  138. :  LLPanel(),
  139. mSpeakerList(NULL),
  140. mMuteVoiceCtrl(NULL),
  141. mMuteTextCtrl(NULL),
  142. mNameText(NULL),
  143. mProfileBtn(NULL),
  144. mShowTextChatters(show_text_chatters),
  145. mSpeakerMgr(data_source)
  146. {
  147. setMouseOpaque(FALSE);
  148. mSpeakerMuteListener = new SpeakerMuteListener(this);
  149. mSpeakerAddListener = new SpeakerAddListener(this);
  150. mSpeakerRemoveListener = new SpeakerRemoveListener(this);
  151. mSpeakerClearListener = new SpeakerClearListener(this);
  152. mSpeakerMgr->addListener(mSpeakerAddListener, "add");
  153. mSpeakerMgr->addListener(mSpeakerRemoveListener, "remove");
  154. mSpeakerMgr->addListener(mSpeakerClearListener, "clear");
  155. }
  156. BOOL LLPanelActiveSpeakers::postBuild()
  157. {
  158. std::string sort_column = gSavedSettings.getString(std::string("FloaterActiveSpeakersSortColumn"));
  159. BOOL sort_ascending     = gSavedSettings.getBOOL(  std::string("FloaterActiveSpeakersSortAscending"));
  160. mSpeakerList = getChild<LLScrollListCtrl>("speakers_list");
  161. mSpeakerList->sortByColumn(sort_column, sort_ascending);
  162. mSpeakerList->setDoubleClickCallback(onDoubleClickSpeaker, this);
  163. mSpeakerList->setCommitOnSelectionChange(TRUE);
  164. mSpeakerList->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::handleSpeakerSelect, this, _2));
  165. mSpeakerList->setSortChangedCallback(boost::bind(&LLPanelActiveSpeakers::onSortChanged, this));
  166. mSpeakerList->setContextMenu(LLScrollListCtrl::MENU_AVATAR);
  167. mMuteTextCtrl = getChild<LLUICtrl>("mute_text_btn");
  168. mMuteTextCtrl->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::onClickMuteTextCommit, this, _2));
  169. mMuteVoiceCtrl = getChild<LLUICtrl>("mute_btn");
  170. mMuteVoiceCtrl->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::onClickMuteVoiceCommit, this, _2));
  171. getChild<LLUICtrl>("speaker_volume")->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::onVolumeChange, this, _2));
  172. mNameText = getChild<LLTextBox>("resident_name");
  173. mProfileBtn = getChild<LLButton>("profile_btn");
  174. childSetAction("profile_btn", onClickProfile, this);
  175. getChild<LLUICtrl>("moderator_allow_voice")->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::onModeratorMuteVoice, this, _1));
  176. getChild<LLUICtrl>("moderator_allow_text")->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::onModeratorMuteText, this, _1));
  177. getChild<LLUICtrl>("moderation_mode")->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::onChangeModerationMode, this, _1));
  178. // update speaker UI
  179. handleSpeakerSelect();
  180. return TRUE;
  181. }
  182. void LLPanelActiveSpeakers::addSpeaker(const LLUUID& speaker_id)
  183. {
  184. if (mSpeakerList->getItemIndex(speaker_id) >= 0)
  185. {
  186. // already have this speaker
  187. return;
  188. }
  189. LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id);
  190. if (speakerp)
  191. {
  192. // since we are forced to sort by text, encode sort order as string
  193. std::string speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex);
  194. LLSD row;
  195. row["id"] = speaker_id;
  196. LLSD& columns = row["columns"];
  197. columns[0]["column"] = "icon_speaking_status";
  198. columns[0]["type"] = "icon";
  199. columns[0]["value"] = "icn_active-speakers-dot-lvl0.tga";
  200. std::string speaker_name;
  201. if (speakerp->mDisplayName.empty())
  202. {
  203. speaker_name = LLCacheName::getDefaultName();
  204. }
  205. else
  206. {
  207. speaker_name = speakerp->mDisplayName;
  208. }
  209. columns[1]["column"] = "speaker_name";
  210. columns[1]["type"] = "text";
  211. columns[1]["value"] = speaker_name;
  212. columns[2]["column"] = "speaking_status";
  213. columns[2]["type"] = "text";
  214. // print speaking ordinal in a text-sorting friendly manner
  215. columns[2]["value"] = speaking_order_sort_string;
  216. mSpeakerList->addElement(row);
  217. }
  218. }
  219. void LLPanelActiveSpeakers::removeSpeaker(const LLUUID& speaker_id)
  220. {
  221. mSpeakerList->deleteSingleItem(mSpeakerList->getItemIndex(speaker_id));
  222. }
  223. void LLPanelActiveSpeakers::handleSpeakerSelect(const LLSD& data)
  224. {
  225. LLUUID speaker_id = mSpeakerList->getValue().asUUID();
  226. LLPointer<LLSpeaker> selected_speakerp = mSpeakerMgr->findSpeaker(speaker_id);
  227. if (selected_speakerp.notNull())
  228. {
  229. // since setting these values is delayed by a round trip to the Vivox servers
  230. // update them only when selecting a new speaker or
  231. // asynchronously when an update arrives
  232. childSetValue("moderator_allow_voice", selected_speakerp ? !selected_speakerp->mModeratorMutedVoice : TRUE);
  233. childSetValue("moderator_allow_text", selected_speakerp ? !selected_speakerp->mModeratorMutedText : TRUE);
  234. mSpeakerMuteListener->clearDispatchers();
  235. selected_speakerp->addListener(mSpeakerMuteListener);
  236. }
  237. }
  238. void LLPanelActiveSpeakers::refreshSpeakers()
  239. {
  240. // store off current selection and scroll state to preserve across list rebuilds
  241. LLUUID selected_id = mSpeakerList->getSelectedValue().asUUID();
  242. S32 scroll_pos = mSpeakerList->getScrollInterface()->getScrollPos();
  243. // decide whether it's ok to resort the list then update the speaker manager appropriately.
  244. // rapid resorting by activity makes it hard to interact with speakers in the list
  245. // so we freeze the sorting while the user appears to be interacting with the control.
  246. // we assume this is the case whenever the mouse pointer is within the active speaker
  247. // panel and hasn't been motionless for more than a few seconds. see DEV-6655 -MG
  248. LLRect screen_rect;
  249. localRectToScreen(getLocalRect(), &screen_rect);
  250. BOOL mouse_in_view = screen_rect.pointInRect(gViewerWindow->getCurrentMouseX(), gViewerWindow->getCurrentMouseY());
  251. F32 mouses_last_movement = LLUI::getMouseIdleTime();
  252. BOOL sort_ok = ! (mouse_in_view && mouses_last_movement<RESORT_TIMEOUT);
  253. mSpeakerMgr->update(sort_ok);
  254. const std::string icon_image_0 = "icn_active-speakers-dot-lvl0.tga";
  255. const std::string icon_image_1 = "icn_active-speakers-dot-lvl1.tga";
  256. const std::string icon_image_2 = "icn_active-speakers-dot-lvl2.tga";
  257. std::vector<LLScrollListItem*> items = mSpeakerList->getAllData();
  258. std::string mute_icon_image = "mute_icon.tga";
  259. LLSpeakerMgr::speaker_list_t speaker_list;
  260. mSpeakerMgr->getSpeakerList(&speaker_list, mShowTextChatters);
  261. for (std::vector<LLScrollListItem*>::iterator item_it = items.begin();
  262. item_it != items.end();
  263. ++item_it)
  264. {
  265. LLScrollListItem* itemp = (*item_it);
  266. LLUUID speaker_id = itemp->getUUID();
  267. LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id);
  268. if (!speakerp)
  269. {
  270. continue;
  271. }
  272. // since we are forced to sort by text, encode sort order as string
  273. std::string speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex);
  274. LLScrollListCell* icon_cell = itemp->getColumn(0);
  275. if (icon_cell)
  276. {
  277. std::string icon_image_id;
  278. S32 icon_image_idx = llmin(2, llfloor((speakerp->mSpeechVolume / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
  279. switch(icon_image_idx)
  280. {
  281. case 0:
  282. icon_image_id = icon_image_0;
  283. break;
  284. case 1:
  285. icon_image_id = icon_image_1;
  286. break;
  287. case 2:
  288. icon_image_id = icon_image_2;
  289. break;
  290. }
  291. LLColor4 icon_color;
  292. if (speakerp->mStatus == LLSpeaker::STATUS_MUTED)
  293. {
  294. icon_cell->setValue(mute_icon_image);
  295. if(speakerp->mModeratorMutedVoice)
  296. {
  297. icon_color.setVec(0.5f, 0.5f, 0.5f, 1.f);
  298. }
  299. else
  300. {
  301. icon_color.setVec(1.f, 71.f / 255.f, 71.f / 255.f, 1.f);
  302. }
  303. }
  304. else
  305. {
  306. icon_cell->setValue(icon_image_id);
  307. icon_color = speakerp->mDotColor;
  308. if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE) // if voice is disabled for this speaker
  309. {
  310. // non voice speakers have hidden icons, render as transparent
  311. icon_color.setVec(0.f, 0.f, 0.f, 0.f);
  312. }
  313. }
  314. icon_cell->setColor(icon_color);
  315. if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE && speakerp->mStatus != LLSpeaker::STATUS_MUTED) // if voice is disabled for this speaker
  316. {
  317. // non voice speakers have hidden icons, render as transparent
  318. icon_cell->setColor(LLColor4::transparent);
  319. }
  320. }
  321. // update name column
  322. LLScrollListCell* name_cell = itemp->getColumn(1);
  323. if (name_cell)
  324. {
  325. //FIXME: remove hard coding of font colors
  326. if (speakerp->mStatus == LLSpeaker::STATUS_NOT_IN_CHANNEL)
  327. {
  328. // draw inactive speakers in gray
  329. name_cell->setColor(LLColor4::grey4);
  330. }
  331. else
  332. {
  333. name_cell->setColor(LLColor4::black);
  334. }
  335. std::string speaker_name;
  336. if (speakerp->mDisplayName.empty())
  337. {
  338. speaker_name = LLCacheName::getDefaultName();
  339. }
  340. else
  341. {
  342. speaker_name = speakerp->mDisplayName;
  343. }
  344. if (speakerp->mIsModerator)
  345. {
  346. speaker_name += std::string(" ") + getString("moderator_label");
  347. }
  348. name_cell->setValue(speaker_name);
  349. ((LLScrollListText*)name_cell)->setFontStyle(speakerp->mIsModerator ? LLFontGL::BOLD : LLFontGL::NORMAL);
  350. }
  351. // update speaking order column
  352. LLScrollListCell* speaking_status_cell = itemp->getColumn(2);
  353. if (speaking_status_cell)
  354. {
  355. // print speaking ordinal in a text-sorting friendly manner
  356. speaking_status_cell->setValue(speaking_order_sort_string);
  357. }
  358. }
  359. // we potentially modified the sort order by touching the list items
  360. mSpeakerList->setNeedsSort();
  361. LLPointer<LLSpeaker> selected_speakerp = mSpeakerMgr->findSpeaker(selected_id);
  362. // update UI for selected participant
  363. if (mMuteVoiceCtrl)
  364. {
  365. mMuteVoiceCtrl->setValue(LLMuteList::getInstance()->isMuted(selected_id, LLMute::flagVoiceChat));
  366. mMuteVoiceCtrl->setEnabled(LLVoiceClient::voiceEnabled()
  367. && gVoiceClient->getVoiceEnabled(selected_id)
  368. && selected_id.notNull() 
  369. && selected_id != gAgent.getID() 
  370. && (selected_speakerp.notNull() && (selected_speakerp->mType == LLSpeaker::SPEAKER_AGENT || selected_speakerp->mType == LLSpeaker::SPEAKER_EXTERNAL)));
  371. }
  372. if (mMuteTextCtrl)
  373. {
  374. mMuteTextCtrl->setValue(LLMuteList::getInstance()->isMuted(selected_id, LLMute::flagTextChat));
  375. mMuteTextCtrl->setEnabled(selected_id.notNull() 
  376. && selected_id != gAgent.getID() 
  377. && selected_speakerp.notNull() 
  378. && selected_speakerp->mType != LLSpeaker::SPEAKER_EXTERNAL
  379. && !LLMuteList::getInstance()->isLinden(selected_speakerp->mDisplayName));
  380. }
  381. childSetValue("speaker_volume", gVoiceClient->getUserVolume(selected_id));
  382. childSetEnabled("speaker_volume", LLVoiceClient::voiceEnabled()
  383. && gVoiceClient->getVoiceEnabled(selected_id)
  384. && selected_id.notNull() 
  385. && selected_id != gAgent.getID() 
  386. && (selected_speakerp.notNull() && (selected_speakerp->mType == LLSpeaker::SPEAKER_AGENT || selected_speakerp->mType == LLSpeaker::SPEAKER_EXTERNAL)));
  387. childSetEnabled(
  388. "moderator_controls_label",
  389. selected_id.notNull());
  390. childSetEnabled(
  391. "moderator_allow_voice", 
  392. selected_id.notNull() 
  393. && mSpeakerMgr->isVoiceActive()
  394. && gVoiceClient->getVoiceEnabled(selected_id));
  395. childSetEnabled(
  396. "moderator_allow_text", 
  397. selected_id.notNull());
  398. if (mProfileBtn)
  399. {
  400. mProfileBtn->setEnabled(selected_id.notNull() && (selected_speakerp.notNull() && selected_speakerp->mType != LLSpeaker::SPEAKER_EXTERNAL) );
  401. }
  402. // show selected user name in large font
  403. if (mNameText)
  404. {
  405. if (selected_speakerp)
  406. {
  407. mNameText->setValue(selected_speakerp->mDisplayName);
  408. }
  409. else
  410. {
  411. mNameText->setValue(LLStringUtil::null);
  412. }
  413. }
  414. //update moderator capabilities
  415. LLPointer<LLSpeaker> self_speakerp = mSpeakerMgr->findSpeaker(gAgent.getID());
  416. if(self_speakerp)
  417. {
  418. childSetVisible("moderation_mode_panel", self_speakerp->mIsModerator && mSpeakerMgr->isVoiceActive());
  419. childSetVisible("moderator_controls", self_speakerp->mIsModerator);
  420. }
  421. // keep scroll value stable
  422. mSpeakerList->getScrollInterface()->setScrollPos(scroll_pos);
  423. }
  424. void LLPanelActiveSpeakers::setSpeaker(const LLUUID& id, const std::string& name, LLSpeaker::ESpeakerStatus status, LLSpeaker::ESpeakerType type)
  425. {
  426. mSpeakerMgr->setSpeaker(id, name, status, type);
  427. }
  428. void LLPanelActiveSpeakers::setVoiceModerationCtrlMode(
  429. const BOOL& moderated_voice)
  430. {
  431. LLUICtrl* voice_moderation_ctrl = getChild<LLUICtrl>("moderation_mode");
  432. if ( voice_moderation_ctrl )
  433. {
  434. std::string value;
  435. value = moderated_voice ? "moderated" : "unmoderated";
  436. voice_moderation_ctrl->setValue(value);
  437. }
  438. }
  439. void LLPanelActiveSpeakers::onClickMuteTextCommit(const LLSD& data)
  440. {
  441. LLUUID speaker_id = mSpeakerList->getValue().asUUID();
  442. BOOL is_muted = LLMuteList::getInstance()->isMuted(speaker_id, LLMute::flagTextChat);
  443. std::string name;
  444. //fill in name using voice client's copy of name cache
  445. LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id);
  446. if (speakerp.isNull())
  447. {
  448. return;
  449. }
  450. name = speakerp->mDisplayName;
  451. LLMute mute(speaker_id, name, speakerp->mType == LLSpeaker::SPEAKER_AGENT ? LLMute::AGENT : LLMute::OBJECT);
  452. if (!is_muted)
  453. {
  454. LLMuteList::getInstance()->add(mute, LLMute::flagTextChat);
  455. }
  456. else
  457. {
  458. LLMuteList::getInstance()->remove(mute, LLMute::flagTextChat);
  459. }
  460. }
  461. void LLPanelActiveSpeakers::onClickMuteVoiceCommit(const LLSD& data)
  462. {
  463. LLUUID speaker_id = mSpeakerList->getValue().asUUID();
  464. BOOL is_muted = LLMuteList::getInstance()->isMuted(speaker_id, LLMute::flagVoiceChat);
  465. std::string name;
  466. LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id);
  467. if (speakerp.isNull())
  468. {
  469. return;
  470. }
  471. name = speakerp->mDisplayName;
  472. // muting voice means we're dealing with an agent
  473. LLMute mute(speaker_id, name, LLMute::AGENT);
  474. if (!is_muted)
  475. {
  476. LLMuteList::getInstance()->add(mute, LLMute::flagVoiceChat);
  477. }
  478. else
  479. {
  480. LLMuteList::getInstance()->remove(mute, LLMute::flagVoiceChat);
  481. }
  482. }
  483. void LLPanelActiveSpeakers::onVolumeChange(const LLSD& data)
  484. {
  485. LLUUID speaker_id = mSpeakerList->getValue().asUUID();
  486. F32 new_volume = (F32)childGetValue("speaker_volume").asReal();
  487. gVoiceClient->setUserVolume(speaker_id, new_volume); 
  488. }
  489. //static 
  490. void LLPanelActiveSpeakers::onClickProfile(void* user_data)
  491. {
  492. LLPanelActiveSpeakers* panelp = (LLPanelActiveSpeakers*)user_data;
  493. LLUUID speaker_id = panelp->mSpeakerList->getValue().asUUID();
  494. LLAvatarActions::showProfile(speaker_id);
  495. }
  496. //static
  497. void LLPanelActiveSpeakers::onDoubleClickSpeaker(void* user_data)
  498. {
  499. LLPanelActiveSpeakers* panelp = (LLPanelActiveSpeakers*)user_data;
  500. LLUUID speaker_id = panelp->mSpeakerList->getValue().asUUID();
  501. LLPointer<LLSpeaker> speakerp = panelp->mSpeakerMgr->findSpeaker(speaker_id);
  502. if (speaker_id != gAgent.getID() && speakerp.notNull())
  503. {
  504. LLUUID session_id = gIMMgr->addSession(speakerp->mDisplayName,
  505. IM_NOTHING_SPECIAL, speaker_id);
  506. if (session_id != LLUUID::null)
  507. {
  508. LLIMFloater::show(session_id);
  509. }
  510. }
  511. }
  512. void LLPanelActiveSpeakers::onSortChanged()
  513. {
  514. std::string sort_column = mSpeakerList->getSortColumnName();
  515. BOOL sort_ascending = mSpeakerList->getSortAscending();
  516. gSavedSettings.setString(std::string("FloaterActiveSpeakersSortColumn"), sort_column);
  517. gSavedSettings.setBOOL(  std::string("FloaterActiveSpeakersSortAscending"), sort_ascending);
  518. }
  519. void LLPanelActiveSpeakers::onModeratorMuteVoice(LLUICtrl* ctrl)
  520. {
  521. LLUICtrl* speakers_list = getChild<LLUICtrl>("speakers_list");
  522. if (!speakers_list || !gAgent.getRegion())
  523. return;
  524. std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest");
  525. LLSD data;
  526. data["method"] = "mute update";
  527. data["session-id"] = mSpeakerMgr->getSessionID();
  528. data["params"] = LLSD::emptyMap();
  529. data["params"]["agent_id"] = speakers_list->getValue();
  530. data["params"]["mute_info"] = LLSD::emptyMap();
  531. // ctrl value represents ability to type, so invert
  532. data["params"]["mute_info"]["voice"] = !ctrl->getValue().asBoolean();
  533. class MuteVoiceResponder : public LLHTTPClient::Responder
  534. {
  535. public:
  536. MuteVoiceResponder(const LLUUID& session_id)
  537. {
  538. mSessionID = session_id;
  539. }
  540. virtual void error(U32 status, const std::string& reason)
  541. {
  542. llwarns << status << ": " << reason << llendl;
  543. if ( gIMMgr )
  544. {
  545. //403 == you're not a mod
  546. //should be disabled if you're not a moderator
  547. if ( 403 == status )
  548. {
  549. gIMMgr->showSessionEventError(
  550. "mute",
  551. "not_a_mod_error",
  552. mSessionID);
  553. }
  554. else
  555. {
  556. gIMMgr->showSessionEventError(
  557. "mute",
  558. "generic_request_error",
  559. mSessionID);
  560. }
  561. }
  562. }
  563. private:
  564. LLUUID mSessionID;
  565. };
  566. LLHTTPClient::post(
  567. url,
  568. data,
  569. new MuteVoiceResponder(mSpeakerMgr->getSessionID()));
  570. }
  571. void LLPanelActiveSpeakers::onModeratorMuteText(LLUICtrl* ctrl)
  572. {
  573. LLUICtrl* speakers_list = getChild<LLUICtrl>("speakers_list");
  574. if (!speakers_list || !gAgent.getRegion())
  575. return;
  576. std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest");
  577. LLSD data;
  578. data["method"] = "mute update";
  579. data["session-id"] = mSpeakerMgr->getSessionID();
  580. data["params"] = LLSD::emptyMap();
  581. data["params"]["agent_id"] = speakers_list->getValue();
  582. data["params"]["mute_info"] = LLSD::emptyMap();
  583. // ctrl value represents ability to type, so invert
  584. data["params"]["mute_info"]["text"] = !ctrl->getValue().asBoolean();
  585. class MuteTextResponder : public LLHTTPClient::Responder
  586. {
  587. public:
  588. MuteTextResponder(const LLUUID& session_id)
  589. {
  590. mSessionID = session_id;
  591. }
  592. virtual void error(U32 status, const std::string& reason)
  593. {
  594. llwarns << status << ": " << reason << llendl;
  595. if ( gIMMgr )
  596. {
  597. //403 == you're not a mod
  598. //should be disabled if you're not a moderator
  599. if ( 403 == status )
  600. {
  601. gIMMgr->showSessionEventError(
  602. "mute",
  603. "not_a_mod_error",
  604. mSessionID);
  605. }
  606. else
  607. {
  608. gIMMgr->showSessionEventError(
  609. "mute",
  610. "generic_request_error",
  611. mSessionID);
  612. }
  613. }
  614. }
  615. private:
  616. LLUUID mSessionID;
  617. };
  618. LLHTTPClient::post(
  619. url,
  620. data,
  621. new MuteTextResponder(mSpeakerMgr->getSessionID()));
  622. }
  623. void LLPanelActiveSpeakers::onChangeModerationMode(LLUICtrl* ctrl)
  624. {
  625. if (!gAgent.getRegion())
  626. return;
  627. std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest");
  628. LLSD data;
  629. data["method"] = "session update";
  630. data["session-id"] = mSpeakerMgr->getSessionID();
  631. data["params"] = LLSD::emptyMap();
  632. data["params"]["update_info"] = LLSD::emptyMap();
  633. data["params"]["update_info"]["moderated_mode"] = LLSD::emptyMap();
  634. std::string value = ctrl->getValue().asString();
  635. if (value == "unmoderated")
  636. {
  637. data["params"]["update_info"]["moderated_mode"]["voice"] = false;
  638. }
  639. else if (value == "moderated")
  640. {
  641. data["params"]["update_info"]["moderated_mode"]["voice"] = true;
  642. }
  643. struct ModerationModeResponder : public LLHTTPClient::Responder
  644. {
  645. virtual void error(U32 status, const std::string& reason)
  646. {
  647. llwarns << status << ": " << reason << llendl;
  648. }
  649. };
  650. LLHTTPClient::post(url, data, new ModerationModeResponder());
  651. }