From f44742f75f6ea8b9e641a3f319f63afcfdbe26b9 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 21 Oct 2008 22:54:31 +0000 Subject: Pare the groups module down to basics. Adjust dependent files so that a real groups module can even be implemented. --- OpenSim/Framework/GroupData.cs | 57 ++++++ OpenSim/Framework/IClientAPI.cs | 2 +- OpenSim/Framework/LLGroup.cs | 80 -------- .../Region/ClientStack/LindenUDP/LLClientView.cs | 8 +- .../Modules/Avatar/Groups/GroupsModule.cs | 217 ++++++++------------- .../Environment/Modules/World/NPC/NPCAvatar.cs | 2 +- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 2 +- 7 files changed, 146 insertions(+), 222 deletions(-) create mode 100644 OpenSim/Framework/GroupData.cs delete mode 100644 OpenSim/Framework/LLGroup.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/GroupData.cs b/OpenSim/Framework/GroupData.cs new file mode 100644 index 0000000..66b1875 --- /dev/null +++ b/OpenSim/Framework/GroupData.cs @@ -0,0 +1,57 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +using System; +using System.Collections; +using OpenMetaverse; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework +{ + public class GroupMembershipData + { + // Group base data + // + public UUID GroupID; + public string GroupName; + public bool AllowPublish = true; + public bool MaturePublish = true; + public UUID Charter = UUID.Zero; + public UUID FounderID = UUID.Zero; + public UUID GroupPicture = UUID.Zero; + public int MembershipFee = 0; + public bool OpenEnrollment = true; + + // Per user data + // + public bool AcceptNotices = true; + public int Contribution = 0; + public uint GroupPowers = 0; + } +} diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index bf31a78..a8813c9 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -845,7 +845,7 @@ namespace OpenSim.Framework void SendAdminResponse(UUID Token, uint AdminLevel); - void SendGroupMembership(GroupData[] GroupMembership); + void SendGroupMembership(GroupMembershipData[] GroupMembership); void SendGroupNameReply(UUID groupLLUID, string GroupName); diff --git a/OpenSim/Framework/LLGroup.cs b/OpenSim/Framework/LLGroup.cs deleted file mode 100644 index 7405b97..0000000 --- a/OpenSim/Framework/LLGroup.cs +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -using System; -using System.Collections; -using OpenMetaverse; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Framework -{ - public class GroupData - { - public string ActiveGroupTitle; - public UUID GroupID; - public List GroupMembers; - public string groupName; - public uint groupPowers = (uint)(GroupPowers.AllowLandmark | GroupPowers.AllowSetHome); - public List GroupTitles; - public bool AcceptNotices = true; - public bool AllowPublish = true; - public string Charter = "Cool Group Yeah!"; - public int contribution = 0; - public UUID FounderID = UUID.Zero; - public int groupMembershipCost = 0; - public int groupRollsCount = 1; - public UUID GroupPicture = UUID.Zero; - public bool MaturePublish = true; - public int MembershipFee = 0; - public bool OpenEnrollment = true; - public bool ShowInList = true; - - public GroupData() - { - GroupTitles = new List(); - GroupMembers = new List(); - } - - public GroupPowers ActiveGroupPowers - { - set { groupPowers = (uint)value; } - get { return (GroupPowers)groupPowers; } - } - } - - public class GroupList - { - public List m_GroupList; - - public GroupList() - { - m_GroupList = new List(); - } - } -} diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 19983dc..6801310 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -6632,7 +6632,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(respondPacket, ThrottleOutPacketType.Task); } - public void SendGroupMembership(GroupData[] GroupMembership) + public void SendGroupMembership(GroupMembershipData[] GroupMembership) { AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket(); AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length]; @@ -6640,11 +6640,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP { AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock(); Group.AcceptNotices = GroupMembership[i].AcceptNotices; - Group.Contribution = GroupMembership[i].contribution; + Group.Contribution = GroupMembership[i].Contribution; Group.GroupID = GroupMembership[i].GroupID; Group.GroupInsigniaID = GroupMembership[i].GroupPicture; - Group.GroupName = Utils.StringToBytes(GroupMembership[i].groupName); - Group.GroupPowers = GroupMembership[i].groupPowers; + Group.GroupName = Utils.StringToBytes(GroupMembership[i].GroupName); + Group.GroupPowers = GroupMembership[i].GroupPowers; Groups[i] = Group; Groupupdate.GroupData = Groups; diff --git a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs index 5495f5a..0bb3c32 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs @@ -39,15 +39,22 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups { public class GroupsModule : IRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Dictionary m_grouplistmap = new Dictionary(); - private Dictionary m_groupmap = new Dictionary(); - private Dictionary m_iclientmap = new Dictionary(); - private Dictionary m_groupUUIDGroup = new Dictionary(); - private UUID opensimulatorGroupID = new UUID("00000000-68f9-1111-024e-222222111123"); + private Dictionary m_GroupMap = + new Dictionary(); - private List m_scene = new List(); + private Dictionary m_ClientMap = + new Dictionary(); + + private UUID opensimulatorGroupID = + new UUID("00000000-68f9-1111-024e-222222111123"); + + private List m_SceneList = new List(); + + private static GroupMembershipData osGroup = + new GroupMembershipData(); #region IRegionModule Members @@ -73,26 +80,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups m_log.Info("[GROUPS] Activated default groups module"); - lock (m_scene) + lock (m_SceneList) { - m_scene.Add(scene); + if (!m_SceneList.Contains(scene)) + { + if (m_SceneList.Count == 0) + { + osGroup.GroupID = opensimulatorGroupID; + osGroup.GroupName = "OpenSimulator Testing"; + osGroup.GroupPowers = + (uint)(GroupPowers.AllowLandmark | + GroupPowers.AllowSetHome); + m_GroupMap[opensimulatorGroupID] = osGroup; + } + m_SceneList.Add(scene); + } } + scene.EventManager.OnNewClient += OnNewClient; scene.EventManager.OnClientClosed += OnClientClosed; - scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage; - lock (m_groupUUIDGroup) - { - - GroupData OpenSimulatorGroup = new GroupData(); - OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester"; - OpenSimulatorGroup.GroupID = opensimulatorGroupID; - OpenSimulatorGroup.groupName = "OpenSimulator Testing"; - OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.AllowSetHome; - OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester"); - if (!m_groupUUIDGroup.ContainsKey(opensimulatorGroupID)) - m_groupUUIDGroup.Add(opensimulatorGroupID, OpenSimulatorGroup); - } - //scene.EventManager. + scene.EventManager.OnGridInstantMessageToGroupsModule += + OnGridInstantMessage; } public void PostInitialise() @@ -102,21 +110,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups public void Close() { m_log.Info("[GROUP]: Shutting down group module."); - lock (m_iclientmap) + lock (m_ClientMap) { - m_iclientmap.Clear(); + m_ClientMap.Clear(); } - lock (m_groupmap) + lock (m_GroupMap) { - m_groupmap.Clear(); + m_GroupMap.Clear(); } - - lock (m_grouplistmap) - { - m_grouplistmap.Clear(); - } - GC.Collect(); } public string Name @@ -138,159 +140,104 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups client.OnInstantMessage += OnInstantMessage; client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; - lock (m_iclientmap) - { - if (!m_iclientmap.ContainsKey(client.AgentId)) - { - m_iclientmap.Add(client.AgentId, client); - } - } - GroupData OpenSimulatorGroup = null; - lock (m_groupUUIDGroup) + lock (m_ClientMap) { - OpenSimulatorGroup = m_groupUUIDGroup[opensimulatorGroupID]; - if (!OpenSimulatorGroup.GroupMembers.Contains(client.AgentId)) + if (!m_ClientMap.ContainsKey(client.AgentId)) { - OpenSimulatorGroup.GroupMembers.Add(client.AgentId); - m_groupUUIDGroup[opensimulatorGroupID] = OpenSimulatorGroup; + m_ClientMap.Add(client.AgentId, client); } - } - lock (m_groupmap) - { - if (!m_groupmap.ContainsKey(client.AgentId)) - { - m_groupmap.Add(client.AgentId, OpenSimulatorGroup); - } - } - GroupList testGroupList = new GroupList(); - testGroupList.m_GroupList.Add(OpenSimulatorGroup.GroupID); + m_log.Info("[GROUP]: Adding " + client.Name + " to " + + osGroup.GroupName + " "); - lock (m_grouplistmap) - { - if (!m_grouplistmap.ContainsKey(client.AgentId)) - { - m_grouplistmap.Add(client.AgentId, testGroupList); - } - } - m_log.Info("[GROUP]: Adding " + client.Name + " to " + OpenSimulatorGroup.groupName + " "); - GroupData[] updateGroups = new GroupData[1]; - updateGroups[0] = OpenSimulatorGroup; + GroupMembershipData[] updateGroups = new GroupMembershipData[1]; + updateGroups[0] = osGroup; client.SendGroupMembership(updateGroups); } - private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID AgentID, UUID SessionID) + private void OnAgentDataUpdateRequest(IClientAPI remoteClient, + UUID AgentID, UUID SessionID) { - // Adam, this is one of those impossible to refactor items without resorting to .Split hackery + UUID ActiveGroupID; + string ActiveGroupName; + uint ActiveGroupPowers; + string firstname = remoteClient.FirstName; string lastname = remoteClient.LastName; - UUID ActiveGroupID = UUID.Zero; - uint ActiveGroupPowers = 0; - string ActiveGroupName = "OpenSimulator Tester"; string ActiveGroupTitle = "I IZ N0T"; - bool foundUser = false; + ActiveGroupID = osGroup.GroupID; + ActiveGroupName = osGroup.GroupName; + ActiveGroupPowers = osGroup.GroupPowers; - lock (m_iclientmap) - { - if (m_iclientmap.ContainsKey(remoteClient.AgentId)) - { - foundUser = true; - } - } - if (foundUser) - { - lock (m_groupmap) - { - if (m_groupmap.ContainsKey(remoteClient.AgentId)) - { - GroupData grp = m_groupmap[remoteClient.AgentId]; - if (grp != null) - { - ActiveGroupID = grp.GroupID; - ActiveGroupName = grp.groupName; - ActiveGroupPowers = grp.groupPowers; - ActiveGroupTitle = grp.ActiveGroupTitle; - } - - remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); - } - } - } + remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, + lastname, ActiveGroupPowers, ActiveGroupName, + ActiveGroupTitle); } private void OnInstantMessage(IClientAPI client, UUID fromAgentID, - UUID fromAgentSession, UUID toAgentID, - UUID imSessionID, uint timestamp, string fromAgentName, - string message, byte dialog, bool fromGroup, byte offline, - uint ParentEstateID, Vector3 Position, UUID RegionID, - byte[] binaryBucket) + UUID fromAgentSession, UUID toAgentID, + UUID imSessionID, uint timestamp, string fromAgentName, + string message, byte dialog, bool fromGroup, byte offline, + uint ParentEstateID, Vector3 Position, UUID RegionID, + byte[] binaryBucket) { } private void OnGridInstantMessage(GridInstantMessage msg) { // Trigger the above event handler - OnInstantMessage(null, new UUID(msg.fromAgentID), new UUID(msg.fromAgentSession), - new UUID(msg.toAgentID), new UUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, - msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, - new Vector3(msg.Position.X, msg.Position.Y, msg.Position.Z), new UUID(msg.RegionID), - msg.binaryBucket); + OnInstantMessage(null, new UUID(msg.fromAgentID), + new UUID(msg.fromAgentSession), + new UUID(msg.toAgentID), new UUID(msg.imSessionID), + msg.timestamp, msg.fromAgentName, + msg.message, msg.dialog, msg.fromGroup, msg.offline, + msg.ParentEstateID, + new Vector3(msg.Position.X, msg.Position.Y, msg.Position.Z), + new UUID(msg.RegionID), + msg.binaryBucket); } + private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client) { string groupnamereply = "Unknown"; UUID groupUUID = UUID.Zero; - lock (m_groupUUIDGroup) + lock (m_GroupMap) { - if (m_groupUUIDGroup.ContainsKey(id)) + if (m_GroupMap.ContainsKey(id)) { - GroupData grp = m_groupUUIDGroup[id]; - groupnamereply = grp.groupName; + GroupMembershipData grp = m_GroupMap[id]; + groupnamereply = grp.GroupName; groupUUID = grp.GroupID; } } remote_client.SendGroupNameReply(groupUUID, groupnamereply); } + private void OnClientClosed(UUID agentID) { - lock (m_iclientmap) + lock (m_ClientMap) { - if (m_iclientmap.ContainsKey(agentID)) + if (m_ClientMap.ContainsKey(agentID)) { - IClientAPI cli = m_iclientmap[agentID]; + IClientAPI cli = m_ClientMap[agentID]; if (cli != null) { - m_log.Info("[GROUP]: Removing all reference to groups for " + cli.Name); + m_log.Info("[GROUP]: Removing all reference to groups "+ + "for " + cli.Name); } else { - m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString()); + m_log.Info("[GROUP]: Removing all reference to groups "+ + "for " + agentID.ToString()); } - m_iclientmap.Remove(agentID); - } - } - - lock (m_groupmap) - { - if (m_groupmap.ContainsKey(agentID)) - { - m_groupmap.Remove(agentID); - } - } - - lock (m_grouplistmap) - { - if (m_grouplistmap.ContainsKey(agentID)) - { - m_grouplistmap.Remove(agentID); + m_ClientMap.Remove(agentID); } } - GC.Collect(); } } } diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 9aa0403..8617605 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC } - public void SendGroupMembership(GroupData[] GroupMembership) + public void SendGroupMembership(GroupMembershipData[] GroupMembership) { } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 5e7523f..2d479be 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -667,7 +667,7 @@ namespace OpenSim.Region.Examples.SimpleModule } - public void SendGroupMembership(GroupData[] GroupMembership) + public void SendGroupMembership(GroupMembershipData[] GroupMembership) { } -- cgit v1.1