aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs544
1 files changed, 272 insertions, 272 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
index c4906d2..6edc44d 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
@@ -1,273 +1,273 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using libsecondlife; 31using libsecondlife;
32using log4net; 32using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37 37
38namespace OpenSim.Region.Environment.Modules.Avatar.Groups 38namespace OpenSim.Region.Environment.Modules.Avatar.Groups
39{ 39{
40 public class GroupsModule : IRegionModule 40 public class GroupsModule : IRegionModule
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>(); 44 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
45 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>(); 45 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
46 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>(); 46 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
47 private List<Scene> m_scene = new List<Scene>(); 47 private List<Scene> m_scene = new List<Scene>();
48 48
49 #region IRegionModule Members 49 #region IRegionModule Members
50 50
51 public void Initialise(Scene scene, IConfigSource config) 51 public void Initialise(Scene scene, IConfigSource config)
52 { 52 {
53 lock (m_scene) 53 lock (m_scene)
54 { 54 {
55 m_scene.Add(scene); 55 m_scene.Add(scene);
56 } 56 }
57 scene.EventManager.OnNewClient += OnNewClient; 57 scene.EventManager.OnNewClient += OnNewClient;
58 scene.EventManager.OnClientClosed += OnClientClosed; 58 scene.EventManager.OnClientClosed += OnClientClosed;
59 scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage; 59 scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage;
60 //scene.EventManager. 60 //scene.EventManager.
61 } 61 }
62 62
63 public void PostInitialise() 63 public void PostInitialise()
64 { 64 {
65 } 65 }
66 66
67 public void Close() 67 public void Close()
68 { 68 {
69 m_log.Info("[GROUP]: Shutting down group module."); 69 m_log.Info("[GROUP]: Shutting down group module.");
70 lock (m_iclientmap) 70 lock (m_iclientmap)
71 { 71 {
72 m_iclientmap.Clear(); 72 m_iclientmap.Clear();
73 } 73 }
74 74
75 lock (m_groupmap) 75 lock (m_groupmap)
76 { 76 {
77 m_groupmap.Clear(); 77 m_groupmap.Clear();
78 } 78 }
79 79
80 lock (m_grouplistmap) 80 lock (m_grouplistmap)
81 { 81 {
82 m_grouplistmap.Clear(); 82 m_grouplistmap.Clear();
83 } 83 }
84 GC.Collect(); 84 GC.Collect();
85 } 85 }
86 86
87 public string Name 87 public string Name
88 { 88 {
89 get { return "GroupsModule"; } 89 get { return "GroupsModule"; }
90 } 90 }
91 91
92 public bool IsSharedModule 92 public bool IsSharedModule
93 { 93 {
94 get { return true; } 94 get { return true; }
95 } 95 }
96 96
97 #endregion 97 #endregion
98 98
99 private void OnNewClient(IClientAPI client) 99 private void OnNewClient(IClientAPI client)
100 { 100 {
101 // All friends establishment protocol goes over instant message 101 // All friends establishment protocol goes over instant message
102 // There's no way to send a message from the sim 102 // There's no way to send a message from the sim
103 // to a user to 'add a friend' without causing dialog box spam 103 // to a user to 'add a friend' without causing dialog box spam
104 // 104 //
105 // The base set of friends are added when the user signs on in their XMLRPC response 105 // The base set of friends are added when the user signs on in their XMLRPC response
106 // Generated by LoginService. The friends are retreived from the database by the UserManager 106 // Generated by LoginService. The friends are retreived from the database by the UserManager
107 107
108 // Subscribe to instant messages 108 // Subscribe to instant messages
109 client.OnInstantMessage += OnInstantMessage; 109 client.OnInstantMessage += OnInstantMessage;
110 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; 110 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
111 lock (m_iclientmap) 111 lock (m_iclientmap)
112 { 112 {
113 if (!m_iclientmap.ContainsKey(client.AgentId)) 113 if (!m_iclientmap.ContainsKey(client.AgentId))
114 { 114 {
115 m_iclientmap.Add(client.AgentId, client); 115 m_iclientmap.Add(client.AgentId, client);
116 } 116 }
117 } 117 }
118 GroupData OpenSimulatorGroup = new GroupData(); 118 GroupData OpenSimulatorGroup = new GroupData();
119 OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester"; 119 OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester";
120 OpenSimulatorGroup.GroupID = new LLUUID("00000000-68f9-1111-024e-222222111120"); 120 OpenSimulatorGroup.GroupID = new LLUUID("00000000-68f9-1111-024e-222222111120");
121 OpenSimulatorGroup.GroupMembers.Add(client.AgentId); 121 OpenSimulatorGroup.GroupMembers.Add(client.AgentId);
122 OpenSimulatorGroup.groupName = "OpenSimulator Testing"; 122 OpenSimulatorGroup.groupName = "OpenSimulator Testing";
123 OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.LandAllowSetHome; 123 OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.LandAllowSetHome;
124 OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester"); 124 OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester");
125 lock (m_groupmap) 125 lock (m_groupmap)
126 { 126 {
127 if (!m_groupmap.ContainsKey(client.AgentId)) 127 if (!m_groupmap.ContainsKey(client.AgentId))
128 { 128 {
129 m_groupmap.Add(client.AgentId, OpenSimulatorGroup); 129 m_groupmap.Add(client.AgentId, OpenSimulatorGroup);
130 } 130 }
131 } 131 }
132 GroupList testGroupList = new GroupList(); 132 GroupList testGroupList = new GroupList();
133 testGroupList.m_GroupList.Add(new LLUUID("00000000-68f9-1111-024e-222222111120")); 133 testGroupList.m_GroupList.Add(new LLUUID("00000000-68f9-1111-024e-222222111120"));
134 134
135 lock (m_grouplistmap) 135 lock (m_grouplistmap)
136 { 136 {
137 if (!m_grouplistmap.ContainsKey(client.AgentId)) 137 if (!m_grouplistmap.ContainsKey(client.AgentId))
138 { 138 {
139 m_grouplistmap.Add(client.AgentId, testGroupList); 139 m_grouplistmap.Add(client.AgentId, testGroupList);
140 } 140 }
141 } 141 }
142 m_log.Info("[GROUP]: Adding " + client.FirstName + " " + client.LastName + " to OpenSimulator Tester group"); 142 m_log.Info("[GROUP]: Adding " + client.FirstName + " " + client.LastName + " to OpenSimulator Tester group");
143 } 143 }
144 144
145 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, LLUUID AgentID, LLUUID SessionID) 145 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, LLUUID AgentID, LLUUID SessionID)
146 { 146 {
147 string firstname = remoteClient.FirstName; 147 string firstname = remoteClient.FirstName;
148 string lastname = remoteClient.LastName; 148 string lastname = remoteClient.LastName;
149 149
150 LLUUID ActiveGroupID = LLUUID.Zero; 150 LLUUID ActiveGroupID = LLUUID.Zero;
151 uint ActiveGroupPowers = 0; 151 uint ActiveGroupPowers = 0;
152 string ActiveGroupName = ""; 152 string ActiveGroupName = "";
153 string ActiveGroupTitle = ""; 153 string ActiveGroupTitle = "";
154 154
155 bool foundUser = false; 155 bool foundUser = false;
156 156
157 lock (m_iclientmap) 157 lock (m_iclientmap)
158 { 158 {
159 if (m_iclientmap.ContainsKey(remoteClient.AgentId)) 159 if (m_iclientmap.ContainsKey(remoteClient.AgentId))
160 { 160 {
161 foundUser = true; 161 foundUser = true;
162 } 162 }
163 } 163 }
164 if (foundUser) 164 if (foundUser)
165 { 165 {
166 lock (m_groupmap) 166 lock (m_groupmap)
167 { 167 {
168 if (m_groupmap.ContainsKey(remoteClient.AgentId)) 168 if (m_groupmap.ContainsKey(remoteClient.AgentId))
169 { 169 {
170 GroupData grp = m_groupmap[remoteClient.AgentId]; 170 GroupData grp = m_groupmap[remoteClient.AgentId];
171 if (grp != null) 171 if (grp != null)
172 { 172 {
173 ActiveGroupID = grp.GroupID; 173 ActiveGroupID = grp.GroupID;
174 ActiveGroupName = grp.groupName; 174 ActiveGroupName = grp.groupName;
175 ActiveGroupPowers = grp.groupPowers; 175 ActiveGroupPowers = grp.groupPowers;
176 ActiveGroupTitle = grp.ActiveGroupTitle; 176 ActiveGroupTitle = grp.ActiveGroupTitle;
177 } 177 }
178 178
179 //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); 179 //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle);
180 } 180 }
181 } 181 }
182 } 182 }
183 } 183 }
184 184
185 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, 185 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
186 LLUUID fromAgentSession, LLUUID toAgentID, 186 LLUUID fromAgentSession, LLUUID toAgentID,
187 LLUUID imSessionID, uint timestamp, string fromAgentName, 187 LLUUID imSessionID, uint timestamp, string fromAgentName,
188 string message, byte dialog, bool fromGroup, byte offline, 188 string message, byte dialog, bool fromGroup, byte offline,
189 uint ParentEstateID, LLVector3 Position, LLUUID RegionID, 189 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
190 byte[] binaryBucket) 190 byte[] binaryBucket)
191 { 191 {
192 } 192 }
193 193
194 private void OnGridInstantMessage(GridInstantMessage msg) 194 private void OnGridInstantMessage(GridInstantMessage msg)
195 { 195 {
196 // Trigger the above event handler 196 // Trigger the above event handler
197 OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), 197 OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
198 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, 198 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
199 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, 199 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
200 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID), 200 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
201 msg.binaryBucket); 201 msg.binaryBucket);
202 } 202 }
203 203
204 private void OnClientClosed(LLUUID agentID) 204 private void OnClientClosed(LLUUID agentID)
205 { 205 {
206 lock (m_iclientmap) 206 lock (m_iclientmap)
207 { 207 {
208 if (m_iclientmap.ContainsKey(agentID)) 208 if (m_iclientmap.ContainsKey(agentID))
209 { 209 {
210 IClientAPI cli = m_iclientmap[agentID]; 210 IClientAPI cli = m_iclientmap[agentID];
211 if (cli != null) 211 if (cli != null)
212 { 212 {
213 m_log.Info("[GROUP]: Removing all reference to groups for " + cli.FirstName + " " + cli.LastName); 213 m_log.Info("[GROUP]: Removing all reference to groups for " + cli.FirstName + " " + cli.LastName);
214 } 214 }
215 else 215 else
216 { 216 {
217 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString()); 217 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString());
218 } 218 }
219 m_iclientmap.Remove(agentID); 219 m_iclientmap.Remove(agentID);
220 } 220 }
221 } 221 }
222 222
223 lock (m_groupmap) 223 lock (m_groupmap)
224 { 224 {
225 if (m_groupmap.ContainsKey(agentID)) 225 if (m_groupmap.ContainsKey(agentID))
226 { 226 {
227 m_groupmap.Remove(agentID); 227 m_groupmap.Remove(agentID);
228 } 228 }
229 } 229 }
230 230
231 lock (m_grouplistmap) 231 lock (m_grouplistmap)
232 { 232 {
233 if (m_grouplistmap.ContainsKey(agentID)) 233 if (m_grouplistmap.ContainsKey(agentID))
234 { 234 {
235 m_grouplistmap.Remove(agentID); 235 m_grouplistmap.Remove(agentID);
236 } 236 }
237 } 237 }
238 GC.Collect(); 238 GC.Collect();
239 } 239 }
240 } 240 }
241 241
242 public class GroupData 242 public class GroupData
243 { 243 {
244 public string ActiveGroupTitle; 244 public string ActiveGroupTitle;
245 public LLUUID GroupID; 245 public LLUUID GroupID;
246 public List<LLUUID> GroupMembers; 246 public List<LLUUID> GroupMembers;
247 public string groupName; 247 public string groupName;
248 public uint groupPowers = (uint) (GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome); 248 public uint groupPowers = (uint) (GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome);
249 public List<string> GroupTitles; 249 public List<string> GroupTitles;
250 250
251 public GroupData() 251 public GroupData()
252 { 252 {
253 GroupTitles = new List<string>(); 253 GroupTitles = new List<string>();
254 GroupMembers = new List<LLUUID>(); 254 GroupMembers = new List<LLUUID>();
255 } 255 }
256 256
257 public GroupPowers ActiveGroupPowers 257 public GroupPowers ActiveGroupPowers
258 { 258 {
259 set { groupPowers = (uint) value; } 259 set { groupPowers = (uint) value; }
260 get { return (GroupPowers) groupPowers; } 260 get { return (GroupPowers) groupPowers; }
261 } 261 }
262 } 262 }
263 263
264 public class GroupList 264 public class GroupList
265 { 265 {
266 public List<LLUUID> m_GroupList; 266 public List<LLUUID> m_GroupList;
267 267
268 public GroupList() 268 public GroupList()
269 { 269 {
270 m_GroupList = new List<LLUUID>(); 270 m_GroupList = new List<LLUUID>();
271 } 271 }
272 } 272 }
273} \ No newline at end of file 273} \ No newline at end of file