From aa744eecf2bc474509a1703028d681b27111ce84 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 1 Jul 2016 18:19:09 +0100 Subject: [PATCH] add a few methods to modify clientview group powers --- OpenSim/Framework/IClientAPI.cs | 3 + .../ClientStack/Linden/UDP/LLClientView.cs | 89 ++++++++++++++----- .../Server/IRCClientView.cs | 16 ++++ .../OptionalModules/World/NPC/NPCAvatar.cs | 12 +++ OpenSim/Tests/Common/Mock/TestClient.cs | 12 +++ 5 files changed, 108 insertions(+), 24 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index c949c04194..d9932eb544 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1473,6 +1473,9 @@ namespace OpenSim.Framework void SendAgentDropGroup(UUID groupID); void RefreshGroupMembership(); + void UpdateGroupMembership(GroupMembershipData[] data); + void GroupMembershipRemove(UUID GroupID); + void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers); void SendAvatarNotesReply(UUID targetID, string text); void SendAvatarPicksReply(UUID targetID, Dictionary picks); void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 12f6fbd4cc..16cb4ac55b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -2755,29 +2755,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendGroupMembership(GroupMembershipData[] GroupMembership) { - m_groupPowers.Clear(); + // maybe removed in future, use SendAgentGroupDataUpdate instead ( but make sure to update groupPowers ) AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket(); AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length]; - for (int i = 0; i < GroupMembership.Length; i++) + + lock(m_groupPowers) { - m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; - - AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock(); - Group.AcceptNotices = GroupMembership[i].AcceptNotices; - Group.Contribution = GroupMembership[i].Contribution; - Group.GroupID = GroupMembership[i].GroupID; - Group.GroupInsigniaID = GroupMembership[i].GroupPicture; - Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName); - Group.GroupPowers = GroupMembership[i].GroupPowers; - Groups[i] = Group; + m_groupPowers.Clear(); + for (int i = 0; i < GroupMembership.Length; i++) + { + m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; + AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock(); + Group.AcceptNotices = GroupMembership[i].AcceptNotices; + Group.Contribution = GroupMembership[i].Contribution; + Group.GroupID = GroupMembership[i].GroupID; + Group.GroupInsigniaID = GroupMembership[i].GroupPicture; + Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName); + Group.GroupPowers = GroupMembership[i].GroupPowers; + Groups[i] = Group; + } } + Groupupdate.GroupData = Groups; Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock(); Groupupdate.AgentData.AgentID = AgentId; - + IEventQueue eq = Scene.RequestModuleInterface(); try { @@ -5639,9 +5644,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (groupID == ActiveGroupId) return ActiveGroupPowers; - if (m_groupPowers.ContainsKey(groupID)) - return m_groupPowers[groupID]; - + lock(m_groupPowers) + { + if (m_groupPowers.ContainsKey(groupID)) + return m_groupPowers[groupID]; + } return 0; } @@ -12952,23 +12959,57 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void RefreshGroupMembership() { - if (m_GroupsModule != null) + lock(m_groupPowers) { - GroupMembershipData[] GroupMembership = + if (m_GroupsModule != null) + { + GroupMembershipData[] GroupMembership = m_GroupsModule.GetMembershipData(AgentId); - m_groupPowers.Clear(); - - if (GroupMembership != null) - { - for (int i = 0; i < GroupMembership.Length; i++) + m_groupPowers.Clear(); + + if (GroupMembership != null) { - m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; + for (int i = 0; i < GroupMembership.Length; i++) + { + m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; + } } } } } + public void UpdateGroupMembership(GroupMembershipData[] data) + { + lock(m_groupPowers) + { + m_groupPowers.Clear(); + + if (data != null) + { + for (int i = 0; i < data.Length; i++) + m_groupPowers[data[i].GroupID] = data[i].GroupPowers; + } + } + } + + public void GroupMembershipRemove(UUID GroupID) + { + lock(m_groupPowers) + { + if(m_groupPowers.ContainsKey(GroupID)) + m_groupPowers.Remove(GroupID); + } + } + + public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers) + { + lock(m_groupPowers) + { + m_groupPowers[GroupID] = GroupPowers; + } + } + public string Report() { return m_udpClient.GetStats(); diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index f19cd4792f..f34dbe8b0c 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1626,6 +1626,22 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } + public void UpdateGroupMembership(GroupMembershipData[] data) + { + + } + + public void GroupMembershipRemove(UUID GroupID) + { + + } + + public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers) + { + + } + + public void SendAvatarNotesReply(UUID targetID, string text) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 43b4e0274c..bdac6aa6a1 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1255,6 +1255,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void UpdateGroupMembership(GroupMembershipData[] data) + { + } + + public void GroupMembershipRemove(UUID GroupID) + { + } + + public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers) + { + } + public void SendUseCachedMuteList() { } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 1d8e38f499..98a98c069c 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -1281,6 +1281,18 @@ namespace OpenSim.Tests.Common { } + public void UpdateGroupMembership(GroupMembershipData[] data) + { + } + + public void GroupMembershipRemove(UUID GroupID) + { + } + + public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers) + { + } + public void SendUseCachedMuteList() { }