/// <summary> /// Get the title of the agent's current role. /// </summary> public string GetGroupTitle(UUID avatarID) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); UUID activeGroupID; // Check if they have an active group listing if (m_AgentActiveGroup.TryGetValue(avatarID, out activeGroupID)) { // See if they have any group memberships if (m_GroupMemberInfo.ContainsKey(avatarID)) { // See if the have a group membership for the group they have marked active if (m_GroupMemberInfo[avatarID].ContainsKey(activeGroupID)) { osGroupMemberInfo membership = m_GroupMemberInfo[avatarID][activeGroupID]; // Return the title of the role they currently have marked as their selected active role/title return(membership.Roles[membership.SelectedTitleRole].Title); } } } return(string.Empty); }
private osGroupMemberInfo AddAgentToGroup(UUID AgentID, osGroup existingGroup) { if (existingGroup.Members.ContainsKey(AgentID)) { return(existingGroup.Members[AgentID]); } osGroupMemberInfo newMembership = new osGroupMemberInfo(); newMembership.AgentID = AgentID; newMembership.AcceptNotices = true; newMembership.Contribution = 0; newMembership.ListInProfile = true; newMembership.SelectedTitleRole = UUID.Zero; // Everyone Role newMembership.Roles.Add(UUID.Zero, existingGroup.Roles[UUID.Zero]); existingGroup.Roles[UUID.Zero].RoleMembers.Add(AgentID, newMembership); // Make sure the member is in the big Group Membership lookup dictionary if (!m_GroupMemberInfo.ContainsKey(AgentID)) { m_GroupMemberInfo.Add(AgentID, new Dictionary <UUID, osGroupMemberInfo>()); } // Add this particular membership to the lookup m_GroupMemberInfo[AgentID].Add(existingGroup.GroupID, newMembership); // Add member to group's local list of members existingGroup.Members.Add(AgentID, newMembership); return(newMembership); }
public void ActivateGroup(IClientAPI remoteClient, UUID groupID) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); string Title = ""; if (groupID == UUID.Zero) { // Setting to no group active, "None" m_AgentActiveGroup[remoteClient.AgentId] = groupID; } else if (m_Groups.ContainsKey(groupID)) { osGroup group = m_Groups[groupID]; if (group.Members.ContainsKey(remoteClient.AgentId)) { m_AgentActiveGroup[remoteClient.AgentId] = groupID; osGroupMemberInfo member = group.Members[remoteClient.AgentId]; Title = group.Roles[member.SelectedTitleRole].Title; } } UpdateScenePresenceWithTitle(remoteClient.AgentId, Title); UpdateClientWithGroupInfo(remoteClient); }
public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); foreach (osGroup existingGroup in m_Groups.Values) { if (existingGroup.Name.ToLower().Trim().Equals(name.ToLower().Trim())) { remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); return(UUID.Zero); } } osGroup newGroup = new osGroup(); newGroup.GroupID = UUID.Random(); newGroup.Name = name; newGroup.Charter = charter; newGroup.ShowInList = showInList; newGroup.InsigniaID = insigniaID; newGroup.MembershipFee = membershipFee; newGroup.OpenEnrollment = openEnrollment; newGroup.AllowPublish = allowPublish; newGroup.MaturePublish = maturePublish; newGroup.PowersMask = AllGroupPowers; newGroup.FounderID = remoteClient.AgentId; // Setup members role osgRole everyoneRole = AddRole2Group(newGroup, "Everyone", "Everyone in the group is in the everyone role.", "Everyone Title", m_DefaultEveryonePowers, UUID.Zero); // Setup owners role osgRole ownerRole = AddRole2Group(newGroup, "Owners", "Owners of " + newGroup.Name, "Owner of " + newGroup.Name, AllGroupPowers); osGroupMemberInfo Member = AddAgentToGroup(remoteClient.AgentId, newGroup); // Put the founder in the owner and everyone role Member.Roles.Add(ownerRole.RoleID, ownerRole); // Add founder to owner & everyone's local lists of members ownerRole.RoleMembers.Add(Member.AgentID, Member); // Add group to module m_Groups.Add(newGroup.GroupID, newGroup); remoteClient.SendCreateGroupReply(newGroup.GroupID, true, "Group created successfullly"); // Set this as the founder's active group ActivateGroup(remoteClient, newGroup.GroupID); // The above sends this out too as of 4/3/09 // UpdateClientWithGroupInfo(remoteClient); return(newGroup.GroupID); }
/// <summary> /// Change the current Active Group Role for Agent /// </summary> public void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); // See if they have any group memberships if (m_GroupMemberInfo.ContainsKey(remoteClient.AgentId)) { // See if the have a group membership for the group whose title they want to change if (m_GroupMemberInfo[remoteClient.AgentId].ContainsKey(GroupID)) { osGroupMemberInfo membership = m_GroupMemberInfo[remoteClient.AgentId][GroupID]; // make sure they're a member of the role they're trying to mark active if (membership.Roles.ContainsKey(TitleRoleID)) { membership.SelectedTitleRole = TitleRoleID; UpdateClientWithGroupInfo(remoteClient); } } } }
private void UpdateClientWithGroupInfo(IClientAPI client) { OnAgentDataUpdateRequest(client, client.AgentId, UUID.Zero); // Need to send a group membership update to the client // UDP version doesn't seem to behave nicely // client.SendGroupMembership(GetMembershipData(client.AgentId)); GroupMembershipData[] membershipData = GetMembershipData(client.AgentId); foreach (GroupMembershipData membership in membershipData) { osGroupMemberInfo memberInfo = m_GroupMemberInfo[client.AgentId][membership.GroupID]; osgRole roleInfo = memberInfo.Roles[membership.ActiveRole]; m_log.InfoFormat("[Groups] {0} member of {1} title active (2)", client.FirstName, membership.GroupName, roleInfo.Name, membership.Active); } SendGroupMembershipInfoViaCaps(client, membershipData); client.SendAvatarGroupsReply(client.AgentId, membershipData); }
public void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID) { osGroup group; if (m_Groups.TryGetValue(GroupID, out group)) { if (group.Members.ContainsKey(remoteClient.AgentId)) { osGroupMemberInfo member = group.Members[remoteClient.AgentId]; // Remove out of each role in group foreach (osgRole role in member.Roles.Values) { role.RoleMembers.Remove(member.AgentID); } // Remove member from Group's list of members group.Members.Remove(member.AgentID); // Make sure this group isn't the user's current active group if (m_AgentActiveGroup.ContainsKey(member.AgentID) && (m_AgentActiveGroup[member.AgentID] == group.GroupID)) { ActivateGroup(remoteClient, UUID.Zero); } // Remove from global lookup index if (m_GroupMemberInfo.ContainsKey(member.AgentID)) { m_GroupMemberInfo[member.AgentID].Remove(group.GroupID); } UpdateClientWithGroupInfo(remoteClient); remoteClient.SendLeaveGroupReply(GroupID, true); } } remoteClient.SendLeaveGroupReply(GroupID, false); }
public List <GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); List <GroupTitlesData> groupTitles = new List <GroupTitlesData>(); Dictionary <UUID, osGroupMemberInfo> memberships; if (m_GroupMemberInfo.TryGetValue(remoteClient.AgentId, out memberships)) { if (memberships.ContainsKey(groupID)) { osGroupMemberInfo member = memberships[groupID]; foreach (osgRole role in member.Roles.Values) { GroupTitlesData data; data.Name = role.Title; data.UUID = role.RoleID; if (role.RoleID == member.SelectedTitleRole) { data.Selected = true; } else { data.Selected = false; } groupTitles.Add(data); } } } return(groupTitles); }
private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID AgentID, UUID SessionID) { m_log.InfoFormat("[Groups] {0} called with SessionID :: {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, SessionID); UUID ActiveGroupID; string ActiveGroupTitle = string.Empty; string ActiveGroupName = string.Empty; ulong ActiveGroupPowers = (ulong)GroupPowers.None; if (m_AgentActiveGroup.TryGetValue(AgentID, out ActiveGroupID)) { if ((ActiveGroupID != null) && (ActiveGroupID != UUID.Zero)) { osGroup group = m_Groups[ActiveGroupID]; osGroupMemberInfo membership = m_GroupMemberInfo[AgentID][ActiveGroupID]; ActiveGroupName = group.Name; if (membership.SelectedTitleRole != UUID.Zero) { ActiveGroupTitle = membership.Roles[membership.SelectedTitleRole].Title; } // Gather up all the powers from agent's roles, then mask them with group mask foreach (osgRole role in membership.Roles.Values) { ActiveGroupPowers |= (ulong)role.Powers; } ActiveGroupPowers &= (ulong)group.PowersMask; } else { ActiveGroupID = UUID.Zero; } } else { // I think this is needed bcasue the TryGetValue() will set this to null ActiveGroupID = UUID.Zero; } string firstname, lastname; IClientAPI agent; if (m_ActiveClients.TryGetValue(AgentID, out agent)) { firstname = agent.FirstName; lastname = agent.LastName; } else { firstname = "Unknown"; lastname = "Unknown"; } m_log.InfoFormat("[Groups] Active Powers {0}, Group {1}, Title {2}", ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); }