// propagate actual relationship to UI. // Does not resort the UI list because it can be called frequently. JC BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationship* info) { if (!info) return FALSE; LLScrollListItem* itemp = mFriendsList->getItem(agent_id); if (!itemp) return FALSE; bool isOnlineSIP = LLVoiceClient::getInstance()->isOnlineSIP(itemp->getUUID()); bool isOnline = info->isOnline(); std::string fullname; // [Ansariel: Display name support] //BOOL have_name = gCacheName->getFullName(agent_id, fullname); LLAvatarName avatar_name; BOOL have_name; if (LLAvatarNameCache::get(agent_id, &avatar_name)) { static const LLCachedControl<S32> phoenix_name_system("PhoenixNameSystem", 0); switch (phoenix_name_system) { case 0 : fullname = avatar_name.getLegacyName(); break; case 1 : fullname = (avatar_name.mIsDisplayNameDefault ? avatar_name.mDisplayName : avatar_name.getCompleteName()); break; case 2 : fullname = avatar_name.mDisplayName; break; default : fullname = avatar_name.getCompleteName(); break; } have_name = TRUE; } else have_name = FALSE; // [/Ansariel: Display name support] // Name of the status icon to use std::string statusIcon; if(isOnline) { mNumOnline++; statusIcon = "icon_avatar_online.tga"; } else if(isOnlineSIP) { mNumOnline++; statusIcon = ONLINE_SIP_ICON_NAME; } else { mNumOnline--; } itemp->getColumn(LIST_ONLINE_STATUS)->setValue(statusIcon); itemp->getColumn(LIST_FRIEND_NAME)->setValue(fullname); // render name of online friends in bold text ((LLScrollListText*)itemp->getColumn(LIST_FRIEND_NAME))->setFontStyle((isOnline || isOnlineSIP) ? LLFontGL::BOLD : LLFontGL::NORMAL); itemp->getColumn(LIST_VISIBLE_ONLINE)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS)); itemp->getColumn(LIST_VISIBLE_MAP)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION)); itemp->getColumn(LIST_EDIT_MINE)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_MODIFY_OBJECTS)); //Notes in the original code imply this may not always work. Good to know. -HgB itemp->getColumn(LIST_VISIBLE_ONLINE_THEIRS)->setValue(info->isRightGrantedFrom(LLRelationship::GRANT_ONLINE_STATUS)); itemp->getColumn(LIST_VISIBLE_MAP_THEIRS)->setValue(info->isRightGrantedFrom(LLRelationship::GRANT_MAP_LOCATION)); itemp->getColumn(LIST_EDIT_THEIRS)->setValue(info->isRightGrantedFrom(LLRelationship::GRANT_MODIFY_OBJECTS)); S32 change_generation = have_name ? info->getChangeSerialNum() : -1; itemp->getColumn(LIST_FRIEND_UPDATE_GEN)->setValue(change_generation); // enable this item, in case it was disabled after user input itemp->setEnabled(TRUE); // Do not resort, this function can be called frequently. return have_name; }
void LLPanelActiveSpeakers::refreshSpeakers() { // store off current selection and scroll state to preserve across list rebuilds LLUUID selected_id = mSpeakerList->getSelectedValue().asUUID(); S32 scroll_pos = mSpeakerList->getScrollInterface()->getScrollPos(); // decide whether it's ok to resort the list then update the speaker manager appropriately. // rapid resorting by activity makes it hard to interact with speakers in the list // so we freeze the sorting while the user appears to be interacting with the control. // we assume this is the case whenever the mouse pointer is within the active speaker // panel and hasn't been motionless for more than a few seconds. see DEV-6655 -MG LLRect screen_rect; localRectToScreen(getLocalRect(), &screen_rect); BOOL mouse_in_view = screen_rect.pointInRect(gViewerWindow->getCurrentMouseX(), gViewerWindow->getCurrentMouseY()); F32 mouses_last_movement = gMouseIdleTimer.getElapsedTimeF32(); BOOL sort_ok = ! (mouse_in_view && mouses_last_movement<RESORT_TIMEOUT); mSpeakerMgr->update(sort_ok); const std::string icon_image_0 = "icn_active-speakers-dot-lvl0.tga"; const std::string icon_image_1 = "icn_active-speakers-dot-lvl1.tga"; const std::string icon_image_2 = "icn_active-speakers-dot-lvl2.tga"; std::vector<LLScrollListItem*> items = mSpeakerList->getAllData(); std::string mute_icon_image = "mute_icon.tga"; LLSpeakerMgr::speaker_list_t speaker_list; mSpeakerMgr->getSpeakerList(&speaker_list, mShowTextChatters); for (std::vector<LLScrollListItem*>::iterator item_it = items.begin(); item_it != items.end(); ++item_it) { LLScrollListItem* itemp = (*item_it); LLUUID speaker_id = itemp->getUUID(); LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(speaker_id); if (!speakerp) { continue; } // since we are forced to sort by text, encode sort order as string std::string speaking_order_sort_string = llformat("%010d", speakerp->mSortIndex); LLScrollListCell* icon_cell = itemp->getColumn(0); if (icon_cell) { std::string icon_image_id; S32 icon_image_idx = llmin(2, llfloor((speakerp->mSpeechVolume / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f)); switch(icon_image_idx) { case 0: icon_image_id = icon_image_0; break; case 1: icon_image_id = icon_image_1; break; case 2: icon_image_id = icon_image_2; break; } LLColor4 icon_color; if (speakerp->mStatus == LLSpeaker::STATUS_MUTED) { icon_cell->setValue(mute_icon_image); if(speakerp->mModeratorMutedVoice) { icon_color.setVec(0.5f, 0.5f, 0.5f, 1.f); } else { icon_color.setVec(1.f, 71.f / 255.f, 71.f / 255.f, 1.f); } } else { icon_cell->setValue(icon_image_id); icon_color = speakerp->mDotColor; if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE) // if voice is disabled for this speaker { // non voice speakers have hidden icons, render as transparent icon_color.setVec(0.f, 0.f, 0.f, 0.f); } } icon_cell->setColor(icon_color); if (speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE && speakerp->mStatus != LLSpeaker::STATUS_MUTED) // if voice is disabled for this speaker { // non voice speakers have hidden icons, render as transparent icon_cell->setColor(LLColor4::transparent); } } // update name column LLScrollListCell* name_cell = itemp->getColumn(1); if (name_cell) { //FIXME: remove hard coding of font colors if (speakerp->mStatus == LLSpeaker::STATUS_NOT_IN_CHANNEL) { // draw inactive speakers in gray name_cell->setColor(LLColor4::grey4); } else { name_cell->setColor(LLColor4::black); } std::string speaker_name; if (speakerp->mDisplayName.empty()) { speaker_name = LLCacheName::getDefaultName(); } else { speaker_name = speakerp->mDisplayName; } if (speakerp->mIsModerator) { speaker_name += std::string(" ") + getString("moderator_label"); } name_cell->setValue(speaker_name); ((LLScrollListText*)name_cell)->setFontStyle(speakerp->mIsModerator ? LLFontGL::BOLD : LLFontGL::NORMAL); } // update speaking order column LLScrollListCell* speaking_status_cell = itemp->getColumn(2); if (speaking_status_cell) { // print speaking ordinal in a text-sorting friendly manner speaking_status_cell->setValue(speaking_order_sort_string); } } // we potentially modified the sort order by touching the list items mSpeakerList->setSorted(FALSE); LLPointer<LLSpeaker> selected_speakerp = mSpeakerMgr->findSpeaker(selected_id); // update UI for selected participant if (mMuteVoiceCtrl) { mMuteVoiceCtrl->setValue(LLMuteList::getInstance()->isMuted(selected_id, LLMute::flagVoiceChat)); mMuteVoiceCtrl->setEnabled(LLVoiceClient::voiceEnabled() && gVoiceClient->getVoiceEnabled(selected_id) && selected_id.notNull() && selected_id != gAgent.getID() && (selected_speakerp.notNull() && selected_speakerp->mType == LLSpeaker::SPEAKER_AGENT)); } if (mMuteTextCtrl) { mMuteTextCtrl->setValue(LLMuteList::getInstance()->isMuted(selected_id, LLMute::flagTextChat)); mMuteTextCtrl->setEnabled(selected_id.notNull() && selected_id != gAgent.getID() && selected_speakerp.notNull() && !LLMuteList::getInstance()->isLinden(selected_speakerp->mDisplayName)); } childSetValue("speaker_volume", gVoiceClient->getUserVolume(selected_id)); childSetEnabled("speaker_volume", LLVoiceClient::voiceEnabled() && gVoiceClient->getVoiceEnabled(selected_id) && selected_id.notNull() && selected_id != gAgent.getID() && (selected_speakerp.notNull() && selected_speakerp->mType == LLSpeaker::SPEAKER_AGENT)); childSetEnabled( "moderator_controls_label", selected_id.notNull()); childSetEnabled( "moderator_allow_voice", selected_id.notNull() && mSpeakerMgr->isVoiceActive() && gVoiceClient->getVoiceEnabled(selected_id)); childSetEnabled( "moderator_allow_text", selected_id.notNull()); if (mProfileBtn) { mProfileBtn->setEnabled(selected_id.notNull()); } // show selected user name in large font if (mNameText) { if (selected_speakerp) { mNameText->setValue(selected_speakerp->mDisplayName); } else { mNameText->setValue(LLStringUtil::null); } } //update moderator capabilities LLPointer<LLSpeaker> self_speakerp = mSpeakerMgr->findSpeaker(gAgent.getID()); if(self_speakerp) { childSetVisible("moderation_mode_panel", self_speakerp->mIsModerator && mSpeakerMgr->isVoiceActive()); childSetVisible("moderator_controls", self_speakerp->mIsModerator); } // keep scroll value stable mSpeakerList->getScrollInterface()->setScrollPos(scroll_pos); }
void LLParticipantList::refreshSpeakers() { // store off current selection and scroll state to preserve across list rebuilds const S32 scroll_pos = mAvatarList->getScrollInterface()->getScrollPos(); // decide whether it's ok to resort the list then update the speaker manager appropriately. // rapid resorting by activity makes it hard to interact with speakers in the list // so we freeze the sorting while the user appears to be interacting with the control. // we assume this is the case whenever the mouse pointer is within the active speaker // panel and hasn't been motionless for more than a few seconds. see DEV-6655 -MG LLRect screen_rect; localRectToScreen(getLocalRect(), &screen_rect); mSpeakerMgr->update(!(screen_rect.pointInRect(gViewerWindow->getCurrentMouseX(), gViewerWindow->getCurrentMouseY()) && gMouseIdleTimer.getElapsedTimeF32() < 5.f)); std::vector<LLScrollListItem*> items = mAvatarList->getAllData(); for (std::vector<LLScrollListItem*>::iterator item_it = items.begin(); item_it != items.end(); ++item_it) { LLScrollListItem* itemp = (*item_it); LLPointer<LLSpeaker> speakerp = mSpeakerMgr->findSpeaker(itemp->getUUID()); if (speakerp.isNull()) continue; if (LLScrollListCell* icon_cell = itemp->getColumn(0)) { if (speakerp->mStatus == LLSpeaker::STATUS_MUTED) { icon_cell->setValue("mute_icon.tga"); static const LLCachedControl<LLColor4> sAscentMutedColor("AscentMutedColor"); icon_cell->setColor(speakerp->mModeratorMutedVoice ? /*LLColor4::grey*/sAscentMutedColor : LLColor4(1.f, 71.f / 255.f, 71.f / 255.f, 1.f)); } else { switch(llmin(2, llfloor((speakerp->mSpeechVolume / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f))) { case 0: icon_cell->setValue("icn_active-speakers-dot-lvl0.tga"); break; case 1: icon_cell->setValue("icn_active-speakers-dot-lvl1.tga"); break; case 2: icon_cell->setValue("icn_active-speakers-dot-lvl2.tga"); break; } // non voice speakers have hidden icons, render as transparent icon_cell->setColor(speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE ? LLColor4::transparent : speakerp->mDotColor); } } // update name column if (LLScrollListCell* name_cell = itemp->getColumn(1)) { if (speakerp->mStatus == LLSpeaker::STATUS_NOT_IN_CHANNEL) { // draw inactive speakers in different color static const LLCachedControl<LLColor4> sSpeakersInactive(gColors, "SpeakersInactive"); name_cell->setColor(sSpeakersInactive); } else { // <edit> bool found = mShowTextChatters || speakerp->mID == gAgentID; const LLWorld::region_list_t& regions = LLWorld::getInstance()->getRegionList(); for (LLWorld::region_list_t::const_iterator iter = regions.begin(); !found && iter != regions.end(); ++iter) { // Are they in this sim? if (const LLViewerRegion* regionp = *iter) if (regionp->mMapAvatarIDs.find(speakerp->mID) != -1) found = true; } if (!found) { static const LLCachedControl<LLColor4> sSpeakersGhost(gColors, "SpeakersGhost"); name_cell->setColor(sSpeakersGhost); } else // </edit> { static const LLCachedControl<LLColor4> sDefaultListText(gColors, "DefaultListText"); name_cell->setColor(sDefaultListText); } } std::string speaker_name = speakerp->mDisplayName.empty() ? LLCacheName::getDefaultName() : speakerp->mDisplayName; if (speakerp->mIsModerator) speaker_name += " " + getString("moderator_label"); name_cell->setValue(speaker_name); static_cast<LLScrollListText*>(name_cell)->setFontStyle(speakerp->mIsModerator ? LLFontGL::BOLD : LLFontGL::NORMAL); } // update speaking order column if (LLScrollListCell* speaking_status_cell = itemp->getColumn(2)) { // since we are forced to sort by text, encode sort order as string // print speaking ordinal in a text-sorting friendly manner speaking_status_cell->setValue(llformat("%010d", speakerp->mSortIndex)); } } // we potentially modified the sort order by touching the list items mAvatarList->setNeedsSort(); // keep scroll value stable mAvatarList->getScrollInterface()->setScrollPos(scroll_pos); }
void LLPanelGroupVoting::impl::setEnableVoteProposal() { if (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE)) return; LLScrollListItem *item = mProposals->getFirstSelected(); if (item) { std::string already_voted; std::string vote_cast; mProposalID = item->getUUID(); // col 0: index id LLScrollListCell * proposal_cell = item->getColumn(1); if ( proposal_cell ) { //proposal text mProposalText->setText(proposal_cell->getValue().asString()); } else { // Something's wrong... should have some text mProposalText->setText(LLStringUtil::null); } proposal_cell = item->getColumn(2); if (proposal_cell) { //end date mEndDate->setText(proposal_cell->getValue().asString()); } else { // Something's wrong... should have some text mEndDate->setText(LLStringUtil::null); } // col 3: Vote Type proposal_cell = item->getColumn(3); if (proposal_cell) { //already voted already_voted = proposal_cell->getValue().asString(); } else { // Something's wrong... should have some text already_voted = ""; } proposal_cell = item->getColumn(5); if (proposal_cell) { //start date mStartDate->setText(proposal_cell->getValue().asString()); } else { // Something's wrong... should have some text mStartDate->setText(LLStringUtil::null); } proposal_cell = item->getColumn(6); if (proposal_cell) { // Vote Cast vote_cast = proposal_cell->getValue().asString(); } // col 8: Vote Initiator proposal_cell = item->getColumn(8); if (proposal_cell) { //quorum mQuorum->set( (F32)atoi(proposal_cell->getValue().asString().c_str())); } else { mQuorum->set(0); } F32 majority = 0.0f; proposal_cell = item->getColumn(9); if (proposal_cell) { //majority majority = (F32)atof(proposal_cell->getValue().asString().c_str()); } if(majority == 0.0f) { // Select the Simple Majority mMajority->setSelectedIndex(0); } else if (majority == 1.0f) { //Select Unanimous mMajority->setSelectedIndex(2); } else { //Select 2/3 Majority mMajority->setSelectedIndex(1); } if (already_voted == "Yes") { LLUIString votestr = mPanel.getString("proposals_header_voted_inst"); votestr.setArg("[VOTE]", vote_cast); mPanel.childSetText("proposal_instructions", votestr.getString()); mBtnYes->setEnabled(FALSE); mBtnNo->setEnabled(FALSE); mBtnAbstain->setEnabled(FALSE); } else { mPanel.childSetText("proposal_instructions", mPanel.getString("proposals_header_vote_inst")); mBtnYes->setEnabled(TRUE); mBtnNo->setEnabled(TRUE); mBtnAbstain->setEnabled(TRUE); } mPanel.childSetText("proposal_header", mPanel.getString("proposals_header_vote_txt")); mPanel.childSetVisible("proposal_lbl", TRUE); mPanel.childSetVisible("proposal_voting_lbl", FALSE); mProposals->setVisible(FALSE); mProposalText->setEnabled(FALSE); mProposalText->setVisible(TRUE); mBtnYes->setVisible(TRUE); mBtnNo->setVisible(TRUE); mBtnAbstain->setVisible(TRUE); mBtnSubmitProposal->setEnabled(FALSE); mBtnSubmitProposal->setVisible(FALSE); mBtnCreateProposal->setEnabled(FALSE); mBtnCreateProposal->setVisible(FALSE); mBtnCancelProposal->setEnabled(FALSE); mBtnCancelProposal->setVisible(FALSE); mBtnViewProposalItem->setEnabled(FALSE); mBtnViewProposalItem->setVisible(FALSE); mBtnViewProposalList->setEnabled(TRUE); mBtnViewProposalList->setVisible(TRUE); mQuorumLbl->setVisible(TRUE); mQuorum->setEnabled(FALSE); mQuorum->setVisible(TRUE); mPanel.childSetVisible("quorum_text", TRUE); mDurationLbl->setVisible(FALSE); mDuration->setEnabled(FALSE); mDuration->setVisible(FALSE); mDurationText->setVisible(FALSE); mMajorityLbl->setVisible(TRUE); mMajority->setEnabled(FALSE); mMajority->setVisible(TRUE); mStartLbl->setVisible(TRUE); mStartDate->setVisible(TRUE); mEndLbl->setVisible(TRUE); mEndDate->setVisible(TRUE); } }
LLScrollListItem* LLNameListCtrl::addNameItemRow(const LLSD& value, EAddPosition pos, void* userdata) { LLScrollListItem* item = LLScrollListCtrl::addElement(value, pos, userdata); if (!item) return NULL; LLUUID id = item->getUUID(); // use supplied name by default std::string fullname = value["name"].asString(); switch(value["target"].asInteger()) { case GROUP: gCacheName->getGroupName(id, fullname); // fullname will be "nobody" if group not found break; case SPECIAL: // just use supplied name break; case INDIVIDUAL: { LLAvatarName av_name; if (id.isNull()) { fullname = LLTrans::getString("AvatarNameNobody"); } else if (LLAvatarNameCache::get(id, &av_name)) { if (mShortNames) fullname = av_name.mDisplayName; else fullname = av_name.getCompleteName(); } else { fullname = " ( " + LLTrans::getString("LoadingData") + " ) "; // ...schedule a callback LLAvatarNameCache::get(id, boost::bind(&LLNameListCtrl::onAvatarNameCache, this, _1, _2, item->getHandle())); } break; } default: break; } // Append optional suffix. std::string suffix = value["suffix"]; if(!suffix.empty()) { fullname.append(suffix); } LLScrollListCell* cell = item->getColumn(mNameColumnIndex); if (cell && !fullname.empty() && cell->getValue().asString().empty()) { cell->setValue(fullname); } dirtyColumns(); // this column is resizable LLScrollListColumn* columnp = getColumn(mNameColumnIndex); if (columnp && columnp->mHeader) { columnp->mHeader->setHasResizableElement(TRUE); } return item; }
void LLPanelNearByMedia::refreshList() { bool all_items_deleted = false; if(!mMediaList) { // None of this makes any sense if the media list isn't there. return; } // Check whether the debug column has been shown/hidden. bool debug_info_visible = gSavedSettings.getBOOL("MediaPerformanceManagerDebug"); if(debug_info_visible != mDebugInfoVisible) { mDebugInfoVisible = debug_info_visible; // Clear all items so the list gets regenerated. mMediaList->deleteAllItems(); mParcelAudioItem = NULL; mParcelMediaItem = NULL; all_items_deleted = true; updateColumns(); } refreshParcelItems(); // Get the canonical list from LLViewerMedia LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList(); LLViewerMedia::impl_list::iterator priority_iter; U32 enabled_count = 0; U32 disabled_count = 0; // iterate over the impl list, creating rows as necessary. for(priority_iter = impls.begin(); priority_iter != impls.end(); priority_iter++) { LLViewerMediaImpl *impl = *priority_iter; // If we just emptied out the list, every flag needs to be reset. if(all_items_deleted) { impl->setInNearbyMediaList(false); } if (!impl->isParcelMedia()) { LLUUID media_id = impl->getMediaTextureID(); S32 proximity = impl->getProximity(); // This is expensive (i.e. a linear search) -- don't use it here. We now use mInNearbyMediaList instead. //S32 index = mMediaList->getItemIndex(media_id); if (proximity < 0 || !shouldShow(impl)) { if (impl->getInNearbyMediaList()) { // There's a row for this impl -- remove it. removeListItem(media_id); impl->setInNearbyMediaList(false); } } else { if (!impl->getInNearbyMediaList()) { // We don't have a row for this impl -- add one. addListItem(media_id); impl->setInNearbyMediaList(true); } } // Update counts if (impl->isMediaDisabled()) { disabled_count++; } else { enabled_count++; } } } mDisableAllCtrl->setEnabled((gSavedSettings.getBOOL("AudioStreamingMusic") || gSavedSettings.getBOOL("AudioStreamingMedia")) && (LLViewerMedia::isAnyMediaShowing() || LLViewerMedia::isParcelMediaPlaying() || LLViewerMedia::isParcelAudioPlaying())); mEnableAllCtrl->setEnabled( (gSavedSettings.getBOOL("AudioStreamingMusic") || gSavedSettings.getBOOL("AudioStreamingMedia")) && (disabled_count > 0 || // parcel media (if we have it, and it isn't playing, enable "start") (LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) || // parcel audio (if we have it, and it isn't playing, enable "start") (LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying()))); // Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away. std::vector<LLScrollListItem*> items = mMediaList->getAllData(); for (std::vector<LLScrollListItem*>::iterator item_it = items.begin(); item_it != items.end(); ++item_it) { LLScrollListItem* item = (*item_it); LLUUID row_id = item->getUUID(); if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID && row_id != PARCEL_AUDIO_LIST_ITEM_UUID) { LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); if(impl) { updateListItem(item, impl); } else { // This item's impl has been deleted -- remove the row. // Removing the row won't throw off our iteration, since we have a local copy of the array. // We just need to make sure we don't access this item after the delete. removeListItem(row_id); } } } // Set the selection to whatever media impl the media focus/hover is on. // This is an experiment, and can be removed by ifdefing out these 4 lines. LLUUID media_target = LLViewerMediaFocus::getInstance()->getControlsMediaID(); if(media_target.notNull()) { mMediaList->selectByID(media_target); } }
void LLPanelGroupBulkBan::submit() { if (!gAgent.hasPowerInGroup(mImplementation->mGroupID, GP_GROUP_BAN_ACCESS)) { // Fail! Agent no longer have ban rights. Permissions could have changed after button was pressed. LLSD msg; msg["MESSAGE"] = mImplementation->mBanNotPermitted; LLNotificationsUtil::add("GenericAlert", msg); (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); return; } LLGroupMgrGroupData * group_datap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); if (group_datap && group_datap->mBanList.size() >= GB_MAX_BANNED_AGENTS) { // Fail! Size limit exceeded. List could have updated after button was pressed. LLSD msg; msg["MESSAGE"] = mImplementation->mBanLimitFail; LLNotificationsUtil::add("GenericAlert", msg); (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); return; } std::vector<LLUUID> banned_agent_list; std::vector<LLScrollListItem*> agents = mImplementation->mBulkAgentList->getAllData(); std::vector<LLScrollListItem*>::iterator iter = agents.begin(); for(;iter != agents.end(); ++iter) { LLScrollListItem* agent = *iter; banned_agent_list.push_back(agent->getUUID()); } const S32 MAX_BANS_PER_REQUEST = 100; // Max bans per request. 100 to match server cap. if (banned_agent_list.size() > MAX_BANS_PER_REQUEST) { // Fail! LLSD msg; msg["MESSAGE"] = mImplementation->mTooManySelected; LLNotificationsUtil::add("GenericAlert", msg); (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); return; } // remove already banned users and yourself from request. std::vector<LLAvatarName> banned_avatar_names; std::vector<LLAvatarName> out_of_limit_names; bool banning_self = FALSE; std::vector<LLUUID>::iterator conflict = std::find(banned_agent_list.begin(), banned_agent_list.end(), gAgent.getID()); if (conflict != banned_agent_list.end()) { banned_agent_list.erase(conflict); banning_self = TRUE; } if (group_datap) { BOOST_FOREACH(const LLGroupMgrGroupData::ban_list_t::value_type& group_ban_pair, group_datap->mBanList) { const LLUUID& group_ban_agent_id = group_ban_pair.first; std::vector<LLUUID>::iterator conflict = std::find(banned_agent_list.begin(), banned_agent_list.end(), group_ban_agent_id); if (conflict != banned_agent_list.end()) { LLAvatarName av_name; LLAvatarNameCache::get(group_ban_agent_id, &av_name); banned_avatar_names.push_back(av_name); banned_agent_list.erase(conflict); if (banned_agent_list.size() == 0) { break; } } } // this check should always be the last one before we send the request. // Otherwise we have a possibility of cutting more then we need to. if (banned_agent_list.size() > GB_MAX_BANNED_AGENTS - group_datap->mBanList.size()) { std::vector<LLUUID>::iterator exeedes_limit = banned_agent_list.begin() + GB_MAX_BANNED_AGENTS - group_datap->mBanList.size(); for (std::vector<LLUUID>::iterator itor = exeedes_limit ; itor != banned_agent_list.end(); ++itor) { LLAvatarName av_name; LLAvatarNameCache::get(*itor, &av_name); out_of_limit_names.push_back(av_name); } banned_agent_list.erase(exeedes_limit,banned_agent_list.end()); } } // sending request and ejecting members if (banned_agent_list.size() != 0) { LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mImplementation->mGroupID, LLGroupMgr::BAN_CREATE | LLGroupMgr::BAN_UPDATE, banned_agent_list); LLGroupMgr::getInstance()->sendGroupMemberEjects(mImplementation->mGroupID, banned_agent_list); } // building notification if (banned_avatar_names.size() > 0 || banning_self || out_of_limit_names.size() > 0) { std::string reasons; if(banned_avatar_names.size() > 0) { reasons = "\n " + buildResidentsArgument(banned_avatar_names, "residents_already_banned"); } if(banning_self) { reasons += "\n " + mImplementation->mCannotBanYourself; } if(out_of_limit_names.size() > 0) { reasons += "\n " + buildResidentsArgument(out_of_limit_names, "ban_limit_reached"); } LLStringUtil::format_map_t msg_args; msg_args["[REASONS]"] = reasons; LLSD msg; if (banned_agent_list.size() == 0) { msg["MESSAGE"] = getString("ban_failed", msg_args); } else { msg["MESSAGE"] = getString("partial_ban", msg_args); } LLNotificationsUtil::add("GenericAlert", msg); } //then close (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); }