aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs217
1 files changed, 82 insertions, 135 deletions
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
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 =
43 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 44
44 private Dictionary<UUID, GroupList> m_grouplistmap = new Dictionary<UUID, GroupList>(); 45 private Dictionary<UUID, GroupMembershipData> m_GroupMap =
45 private Dictionary<UUID, GroupData> m_groupmap = new Dictionary<UUID, GroupData>(); 46 new Dictionary<UUID, GroupMembershipData>();
46 private Dictionary<UUID, IClientAPI> m_iclientmap = new Dictionary<UUID, IClientAPI>();
47 private Dictionary<UUID, GroupData> m_groupUUIDGroup = new Dictionary<UUID, GroupData>();
48 private UUID opensimulatorGroupID = new UUID("00000000-68f9-1111-024e-222222111123");
49 47
50 private List<Scene> m_scene = new List<Scene>(); 48 private Dictionary<UUID, IClientAPI> m_ClientMap =
49 new Dictionary<UUID, IClientAPI>();
50
51 private UUID opensimulatorGroupID =
52 new UUID("00000000-68f9-1111-024e-222222111123");
53
54 private List<Scene> m_SceneList = new List<Scene>();
55
56 private static GroupMembershipData osGroup =
57 new GroupMembershipData();
51 58
52 #region IRegionModule Members 59 #region IRegionModule Members
53 60
@@ -73,26 +80,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
73 80
74 m_log.Info("[GROUPS] Activated default groups module"); 81 m_log.Info("[GROUPS] Activated default groups module");
75 82
76 lock (m_scene) 83 lock (m_SceneList)
77 { 84 {
78 m_scene.Add(scene); 85 if (!m_SceneList.Contains(scene))
86 {
87 if (m_SceneList.Count == 0)
88 {
89 osGroup.GroupID = opensimulatorGroupID;
90 osGroup.GroupName = "OpenSimulator Testing";
91 osGroup.GroupPowers =
92 (uint)(GroupPowers.AllowLandmark |
93 GroupPowers.AllowSetHome);
94 m_GroupMap[opensimulatorGroupID] = osGroup;
95 }
96 m_SceneList.Add(scene);
97 }
79 } 98 }
99
80 scene.EventManager.OnNewClient += OnNewClient; 100 scene.EventManager.OnNewClient += OnNewClient;
81 scene.EventManager.OnClientClosed += OnClientClosed; 101 scene.EventManager.OnClientClosed += OnClientClosed;
82 scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage; 102 scene.EventManager.OnGridInstantMessageToGroupsModule +=
83 lock (m_groupUUIDGroup) 103 OnGridInstantMessage;
84 {
85
86 GroupData OpenSimulatorGroup = new GroupData();
87 OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester";
88 OpenSimulatorGroup.GroupID = opensimulatorGroupID;
89 OpenSimulatorGroup.groupName = "OpenSimulator Testing";
90 OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.AllowSetHome;
91 OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester");
92 if (!m_groupUUIDGroup.ContainsKey(opensimulatorGroupID))
93 m_groupUUIDGroup.Add(opensimulatorGroupID, OpenSimulatorGroup);
94 }
95 //scene.EventManager.
96 } 104 }
97 105
98 public void PostInitialise() 106 public void PostInitialise()
@@ -102,21 +110,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
102 public void Close() 110 public void Close()
103 { 111 {
104 m_log.Info("[GROUP]: Shutting down group module."); 112 m_log.Info("[GROUP]: Shutting down group module.");
105 lock (m_iclientmap) 113 lock (m_ClientMap)
106 { 114 {
107 m_iclientmap.Clear(); 115 m_ClientMap.Clear();
108 } 116 }
109 117
110 lock (m_groupmap) 118 lock (m_GroupMap)
111 { 119 {
112 m_groupmap.Clear(); 120 m_GroupMap.Clear();
113 } 121 }
114
115 lock (m_grouplistmap)
116 {
117 m_grouplistmap.Clear();
118 }
119 GC.Collect();
120 } 122 }
121 123
122 public string Name 124 public string Name
@@ -138,159 +140,104 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
138 client.OnInstantMessage += OnInstantMessage; 140 client.OnInstantMessage += OnInstantMessage;
139 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; 141 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
140 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; 142 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
141 lock (m_iclientmap) 143 lock (m_ClientMap)
142 {
143 if (!m_iclientmap.ContainsKey(client.AgentId))
144 {
145 m_iclientmap.Add(client.AgentId, client);
146 }
147 }
148 GroupData OpenSimulatorGroup = null;
149 lock (m_groupUUIDGroup)
150 { 144 {
151 OpenSimulatorGroup = m_groupUUIDGroup[opensimulatorGroupID]; 145 if (!m_ClientMap.ContainsKey(client.AgentId))
152 if (!OpenSimulatorGroup.GroupMembers.Contains(client.AgentId))
153 { 146 {
154 OpenSimulatorGroup.GroupMembers.Add(client.AgentId); 147 m_ClientMap.Add(client.AgentId, client);
155 m_groupUUIDGroup[opensimulatorGroupID] = OpenSimulatorGroup;
156 } 148 }
157
158 } 149 }
159 150
160 lock (m_groupmap) 151 m_log.Info("[GROUP]: Adding " + client.Name + " to " +
161 { 152 osGroup.GroupName + " ");
162 if (!m_groupmap.ContainsKey(client.AgentId))
163 {
164 m_groupmap.Add(client.AgentId, OpenSimulatorGroup);
165 }
166 }
167 GroupList testGroupList = new GroupList();
168 testGroupList.m_GroupList.Add(OpenSimulatorGroup.GroupID);
169 153
170 lock (m_grouplistmap) 154 GroupMembershipData[] updateGroups = new GroupMembershipData[1];
171 { 155 updateGroups[0] = osGroup;
172 if (!m_grouplistmap.ContainsKey(client.AgentId))
173 {
174 m_grouplistmap.Add(client.AgentId, testGroupList);
175 }
176 }
177 m_log.Info("[GROUP]: Adding " + client.Name + " to " + OpenSimulatorGroup.groupName + " ");
178 GroupData[] updateGroups = new GroupData[1];
179 updateGroups[0] = OpenSimulatorGroup;
180 156
181 client.SendGroupMembership(updateGroups); 157 client.SendGroupMembership(updateGroups);
182 } 158 }
183 159
184 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID AgentID, UUID SessionID) 160 private void OnAgentDataUpdateRequest(IClientAPI remoteClient,
161 UUID AgentID, UUID SessionID)
185 { 162 {
186 // Adam, this is one of those impossible to refactor items without resorting to .Split hackery 163 UUID ActiveGroupID;
164 string ActiveGroupName;
165 uint ActiveGroupPowers;
166
187 string firstname = remoteClient.FirstName; 167 string firstname = remoteClient.FirstName;
188 string lastname = remoteClient.LastName; 168 string lastname = remoteClient.LastName;
189 169
190 UUID ActiveGroupID = UUID.Zero;
191 uint ActiveGroupPowers = 0;
192 string ActiveGroupName = "OpenSimulator Tester";
193 string ActiveGroupTitle = "I IZ N0T"; 170 string ActiveGroupTitle = "I IZ N0T";
194 171
195 bool foundUser = false; 172 ActiveGroupID = osGroup.GroupID;
173 ActiveGroupName = osGroup.GroupName;
174 ActiveGroupPowers = osGroup.GroupPowers;
196 175
197 lock (m_iclientmap) 176 remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname,
198 { 177 lastname, ActiveGroupPowers, ActiveGroupName,
199 if (m_iclientmap.ContainsKey(remoteClient.AgentId)) 178 ActiveGroupTitle);
200 {
201 foundUser = true;
202 }
203 }
204 if (foundUser)
205 {
206 lock (m_groupmap)
207 {
208 if (m_groupmap.ContainsKey(remoteClient.AgentId))
209 {
210 GroupData grp = m_groupmap[remoteClient.AgentId];
211 if (grp != null)
212 {
213 ActiveGroupID = grp.GroupID;
214 ActiveGroupName = grp.groupName;
215 ActiveGroupPowers = grp.groupPowers;
216 ActiveGroupTitle = grp.ActiveGroupTitle;
217 }
218
219 remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle);
220 }
221 }
222 }
223 } 179 }
224 180
225 private void OnInstantMessage(IClientAPI client, UUID fromAgentID, 181 private void OnInstantMessage(IClientAPI client, UUID fromAgentID,
226 UUID fromAgentSession, UUID toAgentID, 182 UUID fromAgentSession, UUID toAgentID,
227 UUID imSessionID, uint timestamp, string fromAgentName, 183 UUID imSessionID, uint timestamp, string fromAgentName,
228 string message, byte dialog, bool fromGroup, byte offline, 184 string message, byte dialog, bool fromGroup, byte offline,
229 uint ParentEstateID, Vector3 Position, UUID RegionID, 185 uint ParentEstateID, Vector3 Position, UUID RegionID,
230 byte[] binaryBucket) 186 byte[] binaryBucket)
231 { 187 {
232 } 188 }
233 189
234 private void OnGridInstantMessage(GridInstantMessage msg) 190 private void OnGridInstantMessage(GridInstantMessage msg)
235 { 191 {
236 // Trigger the above event handler 192 // Trigger the above event handler
237 OnInstantMessage(null, new UUID(msg.fromAgentID), new UUID(msg.fromAgentSession), 193 OnInstantMessage(null, new UUID(msg.fromAgentID),
238 new UUID(msg.toAgentID), new UUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, 194 new UUID(msg.fromAgentSession),
239 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, 195 new UUID(msg.toAgentID), new UUID(msg.imSessionID),
240 new Vector3(msg.Position.X, msg.Position.Y, msg.Position.Z), new UUID(msg.RegionID), 196 msg.timestamp, msg.fromAgentName,
241 msg.binaryBucket); 197 msg.message, msg.dialog, msg.fromGroup, msg.offline,
198 msg.ParentEstateID,
199 new Vector3(msg.Position.X, msg.Position.Y, msg.Position.Z),
200 new UUID(msg.RegionID),
201 msg.binaryBucket);
242 } 202 }
203
243 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client) 204 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)
244 { 205 {
245 string groupnamereply = "Unknown"; 206 string groupnamereply = "Unknown";
246 UUID groupUUID = UUID.Zero; 207 UUID groupUUID = UUID.Zero;
247 208
248 lock (m_groupUUIDGroup) 209 lock (m_GroupMap)
249 { 210 {
250 if (m_groupUUIDGroup.ContainsKey(id)) 211 if (m_GroupMap.ContainsKey(id))
251 { 212 {
252 GroupData grp = m_groupUUIDGroup[id]; 213 GroupMembershipData grp = m_GroupMap[id];
253 groupnamereply = grp.groupName; 214 groupnamereply = grp.GroupName;
254 groupUUID = grp.GroupID; 215 groupUUID = grp.GroupID;
255 } 216 }
256 } 217 }
257 remote_client.SendGroupNameReply(groupUUID, groupnamereply); 218 remote_client.SendGroupNameReply(groupUUID, groupnamereply);
258 } 219 }
220
259 private void OnClientClosed(UUID agentID) 221 private void OnClientClosed(UUID agentID)
260 { 222 {
261 lock (m_iclientmap) 223 lock (m_ClientMap)
262 { 224 {
263 if (m_iclientmap.ContainsKey(agentID)) 225 if (m_ClientMap.ContainsKey(agentID))
264 { 226 {
265 IClientAPI cli = m_iclientmap[agentID]; 227 IClientAPI cli = m_ClientMap[agentID];
266 if (cli != null) 228 if (cli != null)
267 { 229 {
268 m_log.Info("[GROUP]: Removing all reference to groups for " + cli.Name); 230 m_log.Info("[GROUP]: Removing all reference to groups "+
231 "for " + cli.Name);
269 } 232 }
270 else 233 else
271 { 234 {
272 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString()); 235 m_log.Info("[GROUP]: Removing all reference to groups "+
236 "for " + agentID.ToString());
273 } 237 }
274 m_iclientmap.Remove(agentID); 238 m_ClientMap.Remove(agentID);
275 }
276 }
277
278 lock (m_groupmap)
279 {
280 if (m_groupmap.ContainsKey(agentID))
281 {
282 m_groupmap.Remove(agentID);
283 }
284 }
285
286 lock (m_grouplistmap)
287 {
288 if (m_grouplistmap.ContainsKey(agentID))
289 {
290 m_grouplistmap.Remove(agentID);
291 } 239 }
292 } 240 }
293 GC.Collect();
294 } 241 }
295 } 242 }
296} 243}