Skip to content

Commit

Permalink
Update llgroupmgr because why not.
Browse files Browse the repository at this point in the history
  • Loading branch information
LiruMouse committed Mar 29, 2016
1 parent 25937e4 commit 86a657f
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 8 deletions.
88 changes: 82 additions & 6 deletions indra/newview/llgroupmgr.cpp
Expand Up @@ -79,6 +79,7 @@ LLRoleActionSet::~LLRoleActionSet()
{
delete mActionSetData;
std::for_each(mActions.begin(), mActions.end(), DeletePointer());
mActions.clear();
}

//
Expand Down Expand Up @@ -237,7 +238,8 @@ LLGroupMgrGroupData::LLGroupMgrGroupData(const LLUUID& id) :
mRoleMemberDataComplete(false),
mGroupPropertiesDataComplete(false),
mPendingRoleMemberRequest(false),
mAccessTime(0.0f)
mAccessTime(0.0f),
mPendingBanRequest(false)
{
mMemberVersion.generate();
}
Expand Down Expand Up @@ -844,8 +846,69 @@ void LLGroupMgrGroupData::removeBanEntry(const LLUUID& ban_id)
mBanList.erase(ban_id);
}

void LLGroupMgrGroupData::banMemberById(const LLUUID& participant_uuid)
{
if (!mMemberDataComplete ||
!mRoleDataComplete ||
!(mRoleMemberDataComplete && mMembers.size()))
{
LL_WARNS() << "No Role-Member data yet, setting ban request to pending." << LL_ENDL;
mPendingBanRequest = true;
mPendingBanMemberID = participant_uuid;

if (!mMemberDataComplete)
{
LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mID);
}

if (!mRoleDataComplete)
{
LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mID);
}

return;
}

LLGroupMgrGroupData::member_list_t::iterator mi = mMembers.find((participant_uuid));
if (mi == mMembers.end())
{
if (!mPendingBanRequest)
{
mPendingBanRequest = true;
mPendingBanMemberID = participant_uuid;
LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mID); // member isn't in members list, request reloading
}
else
{
mPendingBanRequest = false;
}

return;
}

mPendingBanRequest = false;

LLGroupMemberData* member_data = (*mi).second;
if (member_data && member_data->isInRole(mOwnerRole))
{
return; // can't ban group owner
}

std::vector<LLUUID> ids;
ids.push_back(participant_uuid);

LLGroupBanData ban_data;
createBanEntry(participant_uuid, ban_data);
LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mID, LLGroupMgr::BAN_CREATE, ids);
LLGroupMgr::getInstance()->sendGroupMemberEjects(mID, ids);
LLGroupMgr::getInstance()->sendGroupMembersRequest(mID);
LLSD args;
std::string name;
LLAvatarNameCache::getNSName(participant_uuid, av_name);
args["AVATAR_NAME"] = name;
args["GROUP_NAME"] = mName;
LLNotifications::instance().add(LLNotification::Params("EjectAvatarFromGroup").substitutions(args));
}

//
// LLGroupMgr
Expand Down Expand Up @@ -1352,6 +1415,11 @@ void LLGroupMgr::processGroupRoleMembersReply(LLMessageSystem* msg, void** data)

group_datap->mChanged = TRUE;
LLGroupMgr::getInstance()->notifyObservers(GC_ROLE_MEMBER_DATA);

if (group_datap->mPendingBanRequest)
{
group_datap->banMemberById(group_datap->mPendingBanMemberID);
}
}

// static
Expand Down Expand Up @@ -2082,6 +2150,7 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content)
if (!gdatap)
return;

gdatap->clearBanList();
LLSD::map_const_iterator i = content["ban_list"].beginMap();
LLSD::map_const_iterator iEnd = content["ban_list"].endMap();
for(;i != iEnd; ++i)
Expand Down Expand Up @@ -2195,11 +2264,6 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content)
return;
}

// If we have no members, there's no reason to do anything else
S32 num_members = content["member_count"];
if (num_members < 1)
return;

LLUUID group_id = content["group_id"].asUUID();

LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id);
Expand All @@ -2209,6 +2273,18 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content)
return;
}

// If we have no members, there's no reason to do anything else
S32 num_members = content["member_count"];
if (num_members < 1)
{
LL_INFOS("GrpMgr") << "Received empty group members list for group id: " << group_id.asString() << LL_ENDL;
// Set mMemberDataComplete for correct handling of empty responses. See MAINT-5237
group_datap->mMemberDataComplete = true;
group_datap->mChanged = TRUE;
LLGroupMgr::getInstance()->notifyObservers(GC_MEMBER_DATA);
return;
}

group_datap->mMemberCount = num_members;

LLSD member_list = content["members"];
Expand Down
7 changes: 5 additions & 2 deletions indra/newview/llgroupmgr.h
Expand Up @@ -149,7 +149,7 @@ friend class LLGroupMgrGroupData;

const uuid_vec_t& getRoleMembers() const { return mMemberIDs; }
S32 getMembersInRole(uuid_vec_t members, BOOL needs_sort = TRUE);
S32 getTotalMembersInRole() { return mMemberIDs.size(); }
S32 getTotalMembersInRole() { return mMemberCount ? mMemberCount : mMemberIDs.size(); } //FIXME: Returns 0 for Everyone role when Member list isn't yet loaded, see MAINT-5225

LLRoleData getRoleData() const { return mRoleData; }
void setRoleData(LLRoleData data) { mRoleData = data; }
Expand Down Expand Up @@ -269,7 +269,7 @@ friend class LLGroupMgr;

void createBanEntry(const LLUUID& ban_id, const LLGroupBanData& ban_data = LLGroupBanData());
void removeBanEntry(const LLUUID& ban_id);

void banMemberById(const LLUUID& participant_uuid);

public:
typedef std::map<LLUUID,LLGroupMemberData*> member_list_t;
Expand Down Expand Up @@ -301,6 +301,9 @@ friend class LLGroupMgr;
S32 mMemberCount;
S32 mRoleCount;

bool mPendingBanRequest;
LLUUID mPendingBanMemberID;

protected:
void sendRoleChanges();
void cancelRoleChanges();
Expand Down

0 comments on commit 86a657f

Please sign in to comment.