aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloateractivespeakers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llfloateractivespeakers.cpp')
-rw-r--r--linden/indra/newview/llfloateractivespeakers.cpp97
1 files changed, 59 insertions, 38 deletions
diff --git a/linden/indra/newview/llfloateractivespeakers.cpp b/linden/indra/newview/llfloateractivespeakers.cpp
index ed2f9f8..2352be3 100644
--- a/linden/indra/newview/llfloateractivespeakers.cpp
+++ b/linden/indra/newview/llfloateractivespeakers.cpp
@@ -46,13 +46,15 @@
46#include "llimpanel.h" // LLVoiceChannel 46#include "llimpanel.h" // LLVoiceChannel
47#include "llsdutil.h" 47#include "llsdutil.h"
48#include "llimview.h" 48#include "llimview.h"
49#include "llviewerwindow.h"
49 50
50const F32 SPEAKER_TIMEOUT = 10.f; // seconds of not being on voice channel before removed from list of active speakers 51const F32 SPEAKER_TIMEOUT = 10.f; // seconds of not being on voice channel before removed from list of active speakers
52const F32 RESORT_TIMEOUT = 5.f; // seconds of mouse inactivity before it's ok to sort regardless of mouse-in-view.
51const LLColor4 INACTIVE_COLOR(0.3f, 0.3f, 0.3f, 0.5f); 53const LLColor4 INACTIVE_COLOR(0.3f, 0.3f, 0.3f, 0.5f);
52const LLColor4 ACTIVE_COLOR(0.5f, 0.5f, 0.5f, 1.f); 54const LLColor4 ACTIVE_COLOR(0.5f, 0.5f, 0.5f, 1.f);
53const F32 TYPING_ANIMATION_FPS = 2.5f; 55const F32 TYPING_ANIMATION_FPS = 2.5f;
54 56
55LLSpeaker::LLSpeaker(const LLUUID& id, const LLString& name, const ESpeakerType type) : 57LLSpeaker::LLSpeaker(const LLUUID& id, const std::string& name, const ESpeakerType type) :
56 mStatus(LLSpeaker::STATUS_TEXT_ONLY), 58 mStatus(LLSpeaker::STATUS_TEXT_ONLY),
57 mLastSpokeTime(0.f), 59 mLastSpokeTime(0.f),
58 mSpeechVolume(0.f), 60 mSpeechVolume(0.f),
@@ -87,14 +89,14 @@ void LLSpeaker::lookupName()
87} 89}
88 90
89//static 91//static
90void LLSpeaker::onAvatarNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* user_data) 92void LLSpeaker::onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* user_data)
91{ 93{
92 LLSpeaker* speaker_ptr = ((LLHandle<LLSpeaker>*)user_data)->get(); 94 LLSpeaker* speaker_ptr = ((LLHandle<LLSpeaker>*)user_data)->get();
93 delete (LLHandle<LLSpeaker>*)user_data; 95 delete (LLHandle<LLSpeaker>*)user_data;
94 96
95 if (speaker_ptr) 97 if (speaker_ptr)
96 { 98 {
97 speaker_ptr->mDisplayName = llformat("%s %s", first, last); 99 speaker_ptr->mDisplayName = first + " " + last;
98 } 100 }
99} 101}
100 102
@@ -105,7 +107,7 @@ LLSpeakerTextModerationEvent::LLSpeakerTextModerationEvent(LLSpeaker* source)
105 107
106LLSD LLSpeakerTextModerationEvent::getValue() 108LLSD LLSpeakerTextModerationEvent::getValue()
107{ 109{
108 return LLString("text"); 110 return std::string("text");
109} 111}
110 112
111 113
@@ -116,7 +118,7 @@ LLSpeakerVoiceModerationEvent::LLSpeakerVoiceModerationEvent(LLSpeaker* source)
116 118
117LLSD LLSpeakerVoiceModerationEvent::getValue() 119LLSD LLSpeakerVoiceModerationEvent::getValue()
118{ 120{
119 return LLString("voice"); 121 return std::string("voice");
120} 122}
121 123
122LLSpeakerListChangeEvent::LLSpeakerListChangeEvent(LLSpeakerMgr* source, const LLUUID& speaker_id) 124LLSpeakerListChangeEvent::LLSpeakerListChangeEvent(LLSpeakerMgr* source, const LLUUID& speaker_id)
@@ -287,8 +289,8 @@ LLPanelActiveSpeakers::LLPanelActiveSpeakers(LLSpeakerMgr* data_source, BOOL sho
287 289
288BOOL LLPanelActiveSpeakers::postBuild() 290BOOL LLPanelActiveSpeakers::postBuild()
289{ 291{
290 std::string sort_column = gSavedSettings.getString(LLString("FloaterActiveSpeakersSortColumn")); 292 std::string sort_column = gSavedSettings.getString(std::string("FloaterActiveSpeakersSortColumn"));
291 BOOL sort_ascending = gSavedSettings.getBOOL( LLString("FloaterActiveSpeakersSortAscending")); 293 BOOL sort_ascending = gSavedSettings.getBOOL( std::string("FloaterActiveSpeakersSortAscending"));
292 294
293 mSpeakerList = getChild<LLScrollListCtrl>("speakers_list"); 295 mSpeakerList = getChild<LLScrollListCtrl>("speakers_list");
294 mSpeakerList->sortByColumn(sort_column, sort_ascending); 296 mSpeakerList->sortByColumn(sort_column, sort_ascending);
@@ -334,7 +336,7 @@ void LLPanelActiveSpeakers::addSpeaker(const LLUUID& speaker_id)
334 if (speakerp) 336 if (speakerp)
335 { 337 {
336 // since we are forced to sort by text, encode sort order as string 338 // since we are forced to sort by text, encode sort order as string
337 LLString speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex); 339 std::string speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex);
338 340
339 LLSD row; 341 LLSD row;
340 row["id"] = speaker_id; 342 row["id"] = speaker_id;
@@ -345,7 +347,7 @@ void LLPanelActiveSpeakers::addSpeaker(const LLUUID& speaker_id)
345 columns[0]["type"] = "icon"; 347 columns[0]["type"] = "icon";
346 columns[0]["value"] = "icn_active-speakers-dot-lvl0.tga"; 348 columns[0]["value"] = "icn_active-speakers-dot-lvl0.tga";
347 349
348 LLString speaker_name; 350 std::string speaker_name;
349 if (speakerp->mDisplayName.empty()) 351 if (speakerp->mDisplayName.empty())
350 { 352 {
351 speaker_name = LLCacheName::getDefaultName(); 353 speaker_name = LLCacheName::getDefaultName();
@@ -397,15 +399,25 @@ void LLPanelActiveSpeakers::refreshSpeakers()
397 LLUUID selected_id = mSpeakerList->getSelectedValue().asUUID(); 399 LLUUID selected_id = mSpeakerList->getSelectedValue().asUUID();
398 S32 scroll_pos = mSpeakerList->getScrollInterface()->getScrollPos(); 400 S32 scroll_pos = mSpeakerList->getScrollInterface()->getScrollPos();
399 401
400 mSpeakerMgr->update(); 402 // decide whether it's ok to resort the list then update the speaker manager appropriately.
401 403 // rapid resorting by activity makes it hard to interact with speakers in the list
402 const LLString icon_image_0 = "icn_active-speakers-dot-lvl0.tga"; 404 // so we freeze the sorting while the user appears to be interacting with the control.
403 const LLString icon_image_1 = "icn_active-speakers-dot-lvl1.tga"; 405 // we assume this is the case whenever the mouse pointer is within the active speaker
404 const LLString icon_image_2 = "icn_active-speakers-dot-lvl2.tga"; 406 // panel and hasn't been motionless for more than a few seconds. see DEV-6655 -MG
407 LLRect screen_rect;
408 localRectToScreen(getLocalRect(), &screen_rect);
409 BOOL mouse_in_view = screen_rect.pointInRect(gViewerWindow->getCurrentMouseX(), gViewerWindow->getCurrentMouseY());
410 F32 mouses_last_movement = gMouseIdleTimer.getElapsedTimeF32();
411 BOOL sort_ok = ! (mouse_in_view && mouses_last_movement<RESORT_TIMEOUT);
412 mSpeakerMgr->update(sort_ok);
413
414 const std::string icon_image_0 = "icn_active-speakers-dot-lvl0.tga";
415 const std::string icon_image_1 = "icn_active-speakers-dot-lvl1.tga";
416 const std::string icon_image_2 = "icn_active-speakers-dot-lvl2.tga";
405 417
406 std::vector<LLScrollListItem*> items = mSpeakerList->getAllData(); 418 std::vector<LLScrollListItem*> items = mSpeakerList->getAllData();
407 419
408 LLString mute_icon_image = "mute_icon.tga"; 420 std::string mute_icon_image = "mute_icon.tga";
409 421
410 LLSpeakerMgr::speaker_list_t speaker_list; 422 LLSpeakerMgr::speaker_list_t speaker_list;
411 mSpeakerMgr->getSpeakerList(&speaker_list, mShowTextChatters); 423 mSpeakerMgr->getSpeakerList(&speaker_list, mShowTextChatters);
@@ -423,13 +435,13 @@ void LLPanelActiveSpeakers::refreshSpeakers()
423 } 435 }
424 436
425 // since we are forced to sort by text, encode sort order as string 437 // since we are forced to sort by text, encode sort order as string
426 LLString speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex); 438 std::string speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex);
427 439
428 LLScrollListCell* icon_cell = itemp->getColumn(0); 440 LLScrollListCell* icon_cell = itemp->getColumn(0);
429 if (icon_cell) 441 if (icon_cell)
430 { 442 {
431 443
432 LLString icon_image_id; 444 std::string icon_image_id;
433 445
434 S32 icon_image_idx = llmin(2, llfloor((speakerp->mSpeechVolume / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f)); 446 S32 icon_image_idx = llmin(2, llfloor((speakerp->mSpeechVolume / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
435 switch(icon_image_idx) 447 switch(icon_image_idx)
@@ -494,7 +506,7 @@ void LLPanelActiveSpeakers::refreshSpeakers()
494 name_cell->setColor(LLColor4::black); 506 name_cell->setColor(LLColor4::black);
495 } 507 }
496 508
497 LLString speaker_name; 509 std::string speaker_name;
498 if (speakerp->mDisplayName.empty()) 510 if (speakerp->mDisplayName.empty())
499 { 511 {
500 speaker_name = LLCacheName::getDefaultName(); 512 speaker_name = LLCacheName::getDefaultName();
@@ -506,7 +518,7 @@ void LLPanelActiveSpeakers::refreshSpeakers()
506 518
507 if (speakerp->mIsModerator) 519 if (speakerp->mIsModerator)
508 { 520 {
509 speaker_name += LLString(" ") + getString("moderator_label"); 521 speaker_name += std::string(" ") + getString("moderator_label");
510 } 522 }
511 523
512 name_cell->setValue(speaker_name); 524 name_cell->setValue(speaker_name);
@@ -579,7 +591,7 @@ void LLPanelActiveSpeakers::refreshSpeakers()
579 } 591 }
580 else 592 else
581 { 593 {
582 mNameText->setValue(LLString::null); 594 mNameText->setValue(LLStringUtil::null);
583 } 595 }
584 } 596 }
585 597
@@ -595,7 +607,7 @@ void LLPanelActiveSpeakers::refreshSpeakers()
595 mSpeakerList->getScrollInterface()->setScrollPos(scroll_pos); 607 mSpeakerList->getScrollInterface()->setScrollPos(scroll_pos);
596} 608}
597 609
598void LLPanelActiveSpeakers::setSpeaker(const LLUUID& id, const LLString& name, LLSpeaker::ESpeakerStatus status, LLSpeaker::ESpeakerType type) 610void LLPanelActiveSpeakers::setSpeaker(const LLUUID& id, const std::string& name, LLSpeaker::ESpeakerStatus status, LLSpeaker::ESpeakerType type)
599{ 611{
600 mSpeakerMgr->setSpeaker(id, name, status, type); 612 mSpeakerMgr->setSpeaker(id, name, status, type);
601} 613}
@@ -729,8 +741,8 @@ void LLPanelActiveSpeakers::onSortChanged(void* user_data)
729 LLPanelActiveSpeakers* panelp = (LLPanelActiveSpeakers*)user_data; 741 LLPanelActiveSpeakers* panelp = (LLPanelActiveSpeakers*)user_data;
730 std::string sort_column = panelp->mSpeakerList->getSortColumnName(); 742 std::string sort_column = panelp->mSpeakerList->getSortColumnName();
731 BOOL sort_ascending = panelp->mSpeakerList->getSortAscending(); 743 BOOL sort_ascending = panelp->mSpeakerList->getSortAscending();
732 gSavedSettings.setString(LLString("FloaterActiveSpeakersSortColumn"), sort_column); 744 gSavedSettings.setString(std::string("FloaterActiveSpeakersSortColumn"), sort_column);
733 gSavedSettings.setBOOL( LLString("FloaterActiveSpeakersSortAscending"), sort_ascending); 745 gSavedSettings.setBOOL( std::string("FloaterActiveSpeakersSortAscending"), sort_ascending);
734} 746}
735 747
736 748
@@ -747,9 +759,9 @@ void LLPanelActiveSpeakers::onModeratorMuteVoice(LLUICtrl* ctrl, void* user_data
747 data["session-id"] = self->mSpeakerMgr->getSessionID(); 759 data["session-id"] = self->mSpeakerMgr->getSessionID();
748 data["params"] = LLSD::emptyMap(); 760 data["params"] = LLSD::emptyMap();
749 data["params"]["agent_id"] = speakers_list->getValue(); 761 data["params"]["agent_id"] = speakers_list->getValue();
750 data["params"]["mutes"] = LLSD::emptyMap(); 762 data["params"]["mute_info"] = LLSD::emptyMap();
751 // ctrl value represents ability to type, so invert 763 // ctrl value represents ability to type, so invert
752 data["params"]["mutes"]["voice"] = !ctrl->getValue(); 764 data["params"]["mute_info"]["voice"] = !ctrl->getValue();
753 765
754 class MuteVoiceResponder : public LLHTTPClient::Responder 766 class MuteVoiceResponder : public LLHTTPClient::Responder
755 { 767 {
@@ -812,9 +824,9 @@ void LLPanelActiveSpeakers::onModeratorMuteText(LLUICtrl* ctrl, void* user_data)
812 data["session-id"] = self->mSpeakerMgr->getSessionID(); 824 data["session-id"] = self->mSpeakerMgr->getSessionID();
813 data["params"] = LLSD::emptyMap(); 825 data["params"] = LLSD::emptyMap();
814 data["params"]["agent_id"] = speakers_list->getValue(); 826 data["params"]["agent_id"] = speakers_list->getValue();
815 data["params"]["mutes"] = LLSD::emptyMap(); 827 data["params"]["mute_info"] = LLSD::emptyMap();
816 // ctrl value represents ability to type, so invert 828 // ctrl value represents ability to type, so invert
817 data["params"]["mutes"]["text"] = !ctrl->getValue(); 829 data["params"]["mute_info"]["text"] = !ctrl->getValue();
818 830
819 class MuteTextResponder : public LLHTTPClient::Responder 831 class MuteTextResponder : public LLHTTPClient::Responder
820 { 832 {
@@ -875,14 +887,17 @@ void LLPanelActiveSpeakers::onChangeModerationMode(LLUICtrl* ctrl, void* user_da
875 data["method"] = "session update"; 887 data["method"] = "session update";
876 data["session-id"] = self->mSpeakerMgr->getSessionID(); 888 data["session-id"] = self->mSpeakerMgr->getSessionID();
877 data["params"] = LLSD::emptyMap(); 889 data["params"] = LLSD::emptyMap();
878 data["params"]["moderated_mode"] = LLSD::emptyMap(); 890
891 data["params"]["update_info"] = LLSD::emptyMap();
892
893 data["params"]["update_info"]["moderated_mode"] = LLSD::emptyMap();
879 if (ctrl->getValue().asString() == "unmoderated") 894 if (ctrl->getValue().asString() == "unmoderated")
880 { 895 {
881 data["params"]["moderated_mode"]["voice"] = false; 896 data["params"]["update_info"]["moderated_mode"]["voice"] = false;
882 } 897 }
883 else if (ctrl->getValue().asString() == "moderated") 898 else if (ctrl->getValue().asString() == "moderated")
884 { 899 {
885 data["params"]["moderated_mode"]["voice"] = true; 900 data["params"]["update_info"]["moderated_mode"]["voice"] = true;
886 } 901 }
887 902
888 struct ModerationModeResponder : public LLHTTPClient::Responder 903 struct ModerationModeResponder : public LLHTTPClient::Responder
@@ -909,7 +924,7 @@ LLSpeakerMgr::~LLSpeakerMgr()
909{ 924{
910} 925}
911 926
912LLPointer<LLSpeaker> LLSpeakerMgr::setSpeaker(const LLUUID& id, const LLString& name, LLSpeaker::ESpeakerStatus status, LLSpeaker::ESpeakerType type) 927LLPointer<LLSpeaker> LLSpeakerMgr::setSpeaker(const LLUUID& id, const std::string& name, LLSpeaker::ESpeakerStatus status, LLSpeaker::ESpeakerType type)
913{ 928{
914 if (id.isNull()) return NULL; 929 if (id.isNull()) return NULL;
915 930
@@ -944,7 +959,7 @@ LLPointer<LLSpeaker> LLSpeakerMgr::setSpeaker(const LLUUID& id, const LLString&
944 return speakerp; 959 return speakerp;
945} 960}
946 961
947void LLSpeakerMgr::update() 962void LLSpeakerMgr::update(BOOL resort_ok)
948{ 963{
949 if (!gVoiceClient) 964 if (!gVoiceClient)
950 { 965 {
@@ -954,7 +969,10 @@ void LLSpeakerMgr::update()
954 LLColor4 speaking_color = gSavedSettings.getColor4("SpeakingColor"); 969 LLColor4 speaking_color = gSavedSettings.getColor4("SpeakingColor");
955 LLColor4 overdriven_color = gSavedSettings.getColor4("OverdrivenColor"); 970 LLColor4 overdriven_color = gSavedSettings.getColor4("OverdrivenColor");
956 971
957 updateSpeakerList(); 972 if(resort_ok) // only allow list changes when user is not interacting with it
973 {
974 updateSpeakerList();
975 }
958 976
959 // update status of all current speakers 977 // update status of all current speakers
960 BOOL voice_channel_active = (!mVoiceChannel && gVoiceClient->inProximalChannel()) || (mVoiceChannel && mVoiceChannel->isActive()); 978 BOOL voice_channel_active = (!mVoiceChannel && gVoiceClient->inProximalChannel()) || (mVoiceChannel && mVoiceChannel->isActive());
@@ -1021,8 +1039,11 @@ void LLSpeakerMgr::update()
1021 } 1039 }
1022 } 1040 }
1023 1041
1024 // sort by status then time last spoken 1042 if(resort_ok) // only allow list changes when user is not interacting with it
1025 std::sort(mSpeakersSorted.begin(), mSpeakersSorted.end(), LLSortRecentSpeakers()); 1043 {
1044 // sort by status then time last spoken
1045 std::sort(mSpeakersSorted.begin(), mSpeakersSorted.end(), LLSortRecentSpeakers());
1046 }
1026 1047
1027 // for recent speakers who are not currently speaking, show "recent" color dot for most recent 1048 // for recent speakers who are not currently speaking, show "recent" color dot for most recent
1028 // fading to "active" color 1049 // fading to "active" color
@@ -1072,7 +1093,7 @@ void LLSpeakerMgr::updateSpeakerList()
1072 for (participant_it = participants->begin(); participant_it != participants->end(); ++participant_it) 1093 for (participant_it = participants->begin(); participant_it != participants->end(); ++participant_it)
1073 { 1094 {
1074 LLVoiceClient::participantState* participantp = participant_it->second; 1095 LLVoiceClient::participantState* participantp = participant_it->second;
1075 setSpeaker(participantp->mAvatarID, "", LLSpeaker::STATUS_VOICE_ACTIVE); 1096 setSpeaker(participantp->mAvatarID, LLStringUtil::null, LLSpeaker::STATUS_VOICE_ACTIVE);
1076 } 1097 }
1077 } 1098 }
1078} 1099}
@@ -1163,7 +1184,7 @@ void LLIMSpeakerMgr::setSpeakers(const LLSD& speakers)
1163 1184
1164 LLPointer<LLSpeaker> speakerp = setSpeaker( 1185 LLPointer<LLSpeaker> speakerp = setSpeaker(
1165 agent_id, 1186 agent_id,
1166 "", 1187 LLStringUtil::null,
1167 LLSpeaker::STATUS_TEXT_ONLY); 1188 LLSpeaker::STATUS_TEXT_ONLY);
1168 1189
1169 if ( speaker_it->second.isMap() ) 1190 if ( speaker_it->second.isMap() )
@@ -1187,7 +1208,7 @@ void LLIMSpeakerMgr::setSpeakers(const LLSD& speakers)
1187 1208
1188 LLPointer<LLSpeaker> speakerp = setSpeaker( 1209 LLPointer<LLSpeaker> speakerp = setSpeaker(
1189 agent_id, 1210 agent_id,
1190 "", 1211 LLStringUtil::null,
1191 LLSpeaker::STATUS_TEXT_ONLY); 1212 LLSpeaker::STATUS_TEXT_ONLY);
1192 } 1213 }
1193 } 1214 }