Sync up llgroupactions with v-r/rlv.

This commit is contained in:
Inusaito Sayori
2014-06-20 15:53:54 -04:00
parent 2075042ba7
commit e0746fca12
3 changed files with 134 additions and 16 deletions

View File

@@ -90,7 +90,6 @@ public:
// CP_TODO: get the value we pass in via the XUI name
// of the tab instead of using a literal like this
LLFloaterMyFriends::showInstance( 1 );
return true;
}
return false;
@@ -123,6 +122,80 @@ public:
};
LLGroupHandler gGroupHandler;
// This object represents a pending request for specified group member information
// which is needed to check whether avatar can leave group
class LLFetchGroupMemberData : public LLGroupMgrObserver
{
public:
LLFetchGroupMemberData(const LLUUID& group_id) :
mGroupId(group_id),
mRequestProcessed(false),
LLGroupMgrObserver(group_id)
{
llinfos << "Sending new group member request for group_id: "<< group_id << llendl;
LLGroupMgr* mgr = LLGroupMgr::getInstance();
// register ourselves as an observer
mgr->addObserver(this);
// send a request
mgr->sendGroupPropertiesRequest(group_id);
mgr->sendCapGroupMembersRequest(group_id);
}
~LLFetchGroupMemberData()
{
if (!mRequestProcessed)
{
// Request is pending
llwarns << "Destroying pending group member request for group_id: "
<< mGroupId << llendl;
}
// Remove ourselves as an observer
LLGroupMgr::getInstance()->removeObserver(this);
}
void changed(LLGroupChange gc)
{
if (gc == GC_MEMBER_DATA && !mRequestProcessed)
{
LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupId);
if (!gdatap)
{
llwarns << "LLGroupMgr::getInstance()->getGroupData() was NULL" << llendl;
}
else if (!gdatap->isMemberDataComplete())
{
llwarns << "LLGroupMgr::getInstance()->getGroupData()->isMemberDataComplete() was FALSE" << llendl;
}
else
{
processGroupData();
mRequestProcessed = true;
}
}
}
LLUUID getGroupId() { return mGroupId; }
virtual void processGroupData() = 0;
protected:
LLUUID mGroupId;
private:
bool mRequestProcessed;
};
class LLFetchLeaveGroupData : public LLFetchGroupMemberData
{
public:
LLFetchLeaveGroupData(const LLUUID& group_id)
: LLFetchGroupMemberData(group_id)
{}
void processGroupData()
{
LLGroupActions::processLeaveGroupDataResponse(mGroupId);
}
};
LLFetchLeaveGroupData* gFetchLeaveGroupData = NULL;
// static
void LLGroupActions::search()
{
@@ -226,27 +299,55 @@ bool LLGroupActions::onJoinGroup(const LLSD& notification, const LLSD& response)
void LLGroupActions::leave(const LLUUID& group_id)
{
// if (group_id.isNull())
// return;
// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.4.1a) | Added: RLVa-1.3.0f
if ( (group_id.isNull()) || ((gAgent.getGroupID() == group_id) && (gRlvHandler.hasBehaviour(RLV_BHVR_SETGROUP))) )
return;
// [/RLVa:KB]
{
return;
}
S32 count = gAgent.mGroups.count();
S32 i;
for (i = 0; i < count; ++i)
LLGroupData group_data;
if (gAgent.getGroupData(group_id, group_data))
{
if(gAgent.mGroups.get(i).mID == group_id)
break;
LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(group_id);
if (!gdatap || !gdatap->isMemberDataComplete())
{
if (gFetchLeaveGroupData != NULL)
{
delete gFetchLeaveGroupData;
gFetchLeaveGroupData = NULL;
}
gFetchLeaveGroupData = new LLFetchLeaveGroupData(group_id);
}
if (i < count)
else
{
processLeaveGroupDataResponse(group_id);
}
}
}
//static
void LLGroupActions::processLeaveGroupDataResponse(const LLUUID group_id)
{
LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(group_id);
LLUUID agent_id = gAgent.getID();
LLGroupMgrGroupData::member_list_t::iterator mit = gdatap->mMembers.find(agent_id);
//get the member data for the group
if ( mit != gdatap->mMembers.end() )
{
LLSD args;
args["GROUP"] = gAgent.mGroups.get(i).mName;
LLSD payload;
payload["group_id"] = group_id;
LLNotificationsUtil::add("GroupLeaveConfirmMember", args, payload, onLeaveGroup);
LLGroupMemberData* member_data = (*mit).second;
if ( member_data && member_data->isOwner() && gdatap->mMemberCount == 1)
{
LLNotificationsUtil::add("OwnerCannotLeaveGroup");
return;
}
}
LLSD args;
args["GROUP"] = gdatap->mName;
LLSD payload;
payload["group_id"] = group_id;
LLNotificationsUtil::add("GroupLeaveConfirmMember", args, payload, onLeaveGroup);
}
// static
@@ -287,7 +388,6 @@ void LLGroupActions::inspect(const LLUUID& group_id)
openGroupProfile(group_id);
}
// static
void LLGroupActions::show(const LLUUID& group_id)
{

View File

@@ -124,8 +124,15 @@ public:
private:
static bool onJoinGroup(const LLSD& notification, const LLSD& response);
static bool onLeaveGroup(const LLSD& notification, const LLSD& response);
/**
* This function is called by LLFetchLeaveGroupData upon receiving a response to a group
* members data request.
*/
static void processLeaveGroupDataResponse(const LLUUID group_id);
static LLFloaterGroupInfo* openGroupProfile(const LLUUID& group_id);
friend class LLFetchLeaveGroupData;
};
#endif // LL_LLGROUPACTIONS_H

View File

@@ -3313,6 +3313,17 @@ Leave Group?
yestext="OK"/>
</notification>
<notification
icon="alertmodal.tga"
name="OwnerCannotLeaveGroup"
type="alertmodal">
Unable to leave group. You cannot leave the group because you are the last owner of the group. Please assign another member to the owner role first.
<tag>group</tag>
<usetemplate
name="okbutton"
yestext="OK"/>
</notification>
<notification
icon="alert.tga"
name="ConfirmKick"