diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs (renamed from OpenSim/Region/Environment/Modules/GroupsModule.cs) | 556 |
1 files changed, 278 insertions, 278 deletions
diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs index b23bb91..4b28ad7 100644 --- a/OpenSim/Region/Environment/Modules/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs | |||
@@ -1,278 +1,278 @@ | |||
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using log4net; | 32 | using log4net; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Environment.Interfaces; | 35 | using OpenSim.Region.Environment.Interfaces; |
36 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
37 | 37 | ||
38 | namespace OpenSim.Region.Environment.Modules | 38 | 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 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private List<Scene> m_scene = new List<Scene>(); | 44 | private List<Scene> m_scene = new List<Scene>(); |
45 | private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>(); | 45 | private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>(); |
46 | private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>(); | 46 | private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>(); |
47 | private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>(); | 47 | private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>(); |
48 | 48 | ||
49 | public void Initialise(Scene scene, IConfigSource config) | 49 | public void Initialise(Scene scene, IConfigSource config) |
50 | { | 50 | { |
51 | lock (m_scene) | 51 | lock (m_scene) |
52 | { | 52 | { |
53 | m_scene.Add(scene); | 53 | m_scene.Add(scene); |
54 | } | 54 | } |
55 | scene.EventManager.OnNewClient += OnNewClient; | 55 | scene.EventManager.OnNewClient += OnNewClient; |
56 | scene.EventManager.OnClientClosed += OnClientClosed; | 56 | scene.EventManager.OnClientClosed += OnClientClosed; |
57 | scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage; | 57 | scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage; |
58 | //scene.EventManager. | 58 | //scene.EventManager. |
59 | } | 59 | } |
60 | 60 | ||
61 | private void OnNewClient(IClientAPI client) | 61 | private void OnNewClient(IClientAPI client) |
62 | { | 62 | { |
63 | // All friends establishment protocol goes over instant message | 63 | // All friends establishment protocol goes over instant message |
64 | // There's no way to send a message from the sim | 64 | // There's no way to send a message from the sim |
65 | // to a user to 'add a friend' without causing dialog box spam | 65 | // to a user to 'add a friend' without causing dialog box spam |
66 | // | 66 | // |
67 | // The base set of friends are added when the user signs on in their XMLRPC response | 67 | // The base set of friends are added when the user signs on in their XMLRPC response |
68 | // Generated by LoginService. The friends are retreived from the database by the UserManager | 68 | // Generated by LoginService. The friends are retreived from the database by the UserManager |
69 | 69 | ||
70 | // Subscribe to instant messages | 70 | // Subscribe to instant messages |
71 | client.OnInstantMessage += OnInstantMessage; | 71 | client.OnInstantMessage += OnInstantMessage; |
72 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; | 72 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; |
73 | lock (m_iclientmap) | 73 | lock (m_iclientmap) |
74 | { | 74 | { |
75 | if (!m_iclientmap.ContainsKey(client.AgentId)) | 75 | if (!m_iclientmap.ContainsKey(client.AgentId)) |
76 | { | 76 | { |
77 | m_iclientmap.Add(client.AgentId, client); | 77 | m_iclientmap.Add(client.AgentId, client); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | GroupData OpenSimulatorGroup = new GroupData(); | 80 | GroupData OpenSimulatorGroup = new GroupData(); |
81 | OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester"; | 81 | OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester"; |
82 | OpenSimulatorGroup.GroupID = new LLUUID("00000000-68f9-1111-024e-222222111120"); | 82 | OpenSimulatorGroup.GroupID = new LLUUID("00000000-68f9-1111-024e-222222111120"); |
83 | OpenSimulatorGroup.GroupMembers.Add(client.AgentId); | 83 | OpenSimulatorGroup.GroupMembers.Add(client.AgentId); |
84 | OpenSimulatorGroup.groupName = "OpenSimulator Testing"; | 84 | OpenSimulatorGroup.groupName = "OpenSimulator Testing"; |
85 | OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.LandAllowSetHome; | 85 | OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.LandAllowSetHome; |
86 | OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester"); | 86 | OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester"); |
87 | lock (m_groupmap) | 87 | lock (m_groupmap) |
88 | { | 88 | { |
89 | if (!m_groupmap.ContainsKey(client.AgentId)) | 89 | if (!m_groupmap.ContainsKey(client.AgentId)) |
90 | { | 90 | { |
91 | m_groupmap.Add(client.AgentId, OpenSimulatorGroup); | 91 | m_groupmap.Add(client.AgentId, OpenSimulatorGroup); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | GroupList testGroupList = new GroupList(); | 94 | GroupList testGroupList = new GroupList(); |
95 | testGroupList.m_GroupList.Add(new LLUUID("00000000-68f9-1111-024e-222222111120")); | 95 | testGroupList.m_GroupList.Add(new LLUUID("00000000-68f9-1111-024e-222222111120")); |
96 | 96 | ||
97 | lock (m_grouplistmap) | 97 | lock (m_grouplistmap) |
98 | { | 98 | { |
99 | if (!m_grouplistmap.ContainsKey(client.AgentId)) | 99 | if (!m_grouplistmap.ContainsKey(client.AgentId)) |
100 | { | 100 | { |
101 | m_grouplistmap.Add(client.AgentId, testGroupList); | 101 | m_grouplistmap.Add(client.AgentId, testGroupList); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | m_log.Info("[GROUP]: Adding " + client.FirstName + " " + client.LastName + " to OpenSimulator Tester group"); | 104 | m_log.Info("[GROUP]: Adding " + client.FirstName + " " + client.LastName + " to OpenSimulator Tester group"); |
105 | } | 105 | } |
106 | 106 | ||
107 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, LLUUID AgentID, LLUUID SessionID) | 107 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, LLUUID AgentID, LLUUID SessionID) |
108 | { | 108 | { |
109 | string firstname = remoteClient.FirstName; | 109 | string firstname = remoteClient.FirstName; |
110 | string lastname = remoteClient.LastName; | 110 | string lastname = remoteClient.LastName; |
111 | 111 | ||
112 | LLUUID ActiveGroupID = LLUUID.Zero; | 112 | LLUUID ActiveGroupID = LLUUID.Zero; |
113 | uint ActiveGroupPowers = 0; | 113 | uint ActiveGroupPowers = 0; |
114 | string ActiveGroupName = ""; | 114 | string ActiveGroupName = ""; |
115 | string ActiveGroupTitle = ""; | 115 | string ActiveGroupTitle = ""; |
116 | 116 | ||
117 | bool foundUser = false; | 117 | bool foundUser = false; |
118 | 118 | ||
119 | lock (m_iclientmap) | 119 | lock (m_iclientmap) |
120 | { | 120 | { |
121 | if (m_iclientmap.ContainsKey(remoteClient.AgentId)) | 121 | if (m_iclientmap.ContainsKey(remoteClient.AgentId)) |
122 | { | 122 | { |
123 | foundUser = true; | 123 | foundUser = true; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | if (foundUser) | 126 | if (foundUser) |
127 | { | 127 | { |
128 | lock (m_groupmap) | 128 | lock (m_groupmap) |
129 | { | 129 | { |
130 | if (m_groupmap.ContainsKey(remoteClient.AgentId)) | 130 | if (m_groupmap.ContainsKey(remoteClient.AgentId)) |
131 | { | 131 | { |
132 | GroupData grp = m_groupmap[remoteClient.AgentId]; | 132 | GroupData grp = m_groupmap[remoteClient.AgentId]; |
133 | if (grp != null) | 133 | if (grp != null) |
134 | { | 134 | { |
135 | ActiveGroupID = grp.GroupID; | 135 | ActiveGroupID = grp.GroupID; |
136 | ActiveGroupName = grp.groupName; | 136 | ActiveGroupName = grp.groupName; |
137 | ActiveGroupPowers = grp.groupPowers; | 137 | ActiveGroupPowers = grp.groupPowers; |
138 | ActiveGroupTitle = grp.ActiveGroupTitle; | 138 | ActiveGroupTitle = grp.ActiveGroupTitle; |
139 | } | 139 | } |
140 | 140 | ||
141 | //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); | 141 | //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); |
142 | 142 | ||
143 | } | 143 | } |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, | 149 | private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, |
150 | LLUUID fromAgentSession, LLUUID toAgentID, | 150 | LLUUID fromAgentSession, LLUUID toAgentID, |
151 | LLUUID imSessionID, uint timestamp, string fromAgentName, | 151 | LLUUID imSessionID, uint timestamp, string fromAgentName, |
152 | string message, byte dialog, bool fromGroup, byte offline, | 152 | string message, byte dialog, bool fromGroup, byte offline, |
153 | uint ParentEstateID, LLVector3 Position, LLUUID RegionID, | 153 | uint ParentEstateID, LLVector3 Position, LLUUID RegionID, |
154 | byte[] binaryBucket) | 154 | byte[] binaryBucket) |
155 | { | 155 | { |
156 | } | 156 | } |
157 | 157 | ||
158 | private void OnGridInstantMessage(GridInstantMessage msg) | 158 | private void OnGridInstantMessage(GridInstantMessage msg) |
159 | { | 159 | { |
160 | // Trigger the above event handler | 160 | // Trigger the above event handler |
161 | OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), | 161 | OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), |
162 | new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, | 162 | new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, |
163 | msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, | 163 | msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, |
164 | new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID), | 164 | new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID), |
165 | msg.binaryBucket); | 165 | msg.binaryBucket); |
166 | } | 166 | } |
167 | 167 | ||
168 | private void OnClientClosed(LLUUID agentID) | 168 | private void OnClientClosed(LLUUID agentID) |
169 | { | 169 | { |
170 | lock (m_iclientmap) | 170 | lock (m_iclientmap) |
171 | { | 171 | { |
172 | if (m_iclientmap.ContainsKey(agentID)) | 172 | if (m_iclientmap.ContainsKey(agentID)) |
173 | { | 173 | { |
174 | IClientAPI cli = m_iclientmap[agentID]; | 174 | IClientAPI cli = m_iclientmap[agentID]; |
175 | if (cli != null) | 175 | if (cli != null) |
176 | { | 176 | { |
177 | m_log.Info("[GROUP]: Removing all reference to groups for " + cli.FirstName + " " + cli.LastName); | 177 | m_log.Info("[GROUP]: Removing all reference to groups for " + cli.FirstName + " " + cli.LastName); |
178 | } | 178 | } |
179 | else | 179 | else |
180 | { | 180 | { |
181 | m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString()); | 181 | m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString()); |
182 | } | 182 | } |
183 | m_iclientmap.Remove(agentID); | 183 | m_iclientmap.Remove(agentID); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | lock (m_groupmap) | 187 | lock (m_groupmap) |
188 | { | 188 | { |
189 | if (m_groupmap.ContainsKey(agentID)) | 189 | if (m_groupmap.ContainsKey(agentID)) |
190 | { | 190 | { |
191 | m_groupmap.Remove(agentID); | 191 | m_groupmap.Remove(agentID); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | lock (m_grouplistmap) | 195 | lock (m_grouplistmap) |
196 | { | 196 | { |
197 | if (m_grouplistmap.ContainsKey(agentID)) | 197 | if (m_grouplistmap.ContainsKey(agentID)) |
198 | { | 198 | { |
199 | m_grouplistmap.Remove(agentID); | 199 | m_grouplistmap.Remove(agentID); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | GC.Collect(); | 202 | GC.Collect(); |
203 | } | 203 | } |
204 | 204 | ||
205 | public void PostInitialise() | 205 | public void PostInitialise() |
206 | { | 206 | { |
207 | } | 207 | } |
208 | 208 | ||
209 | public void Close() | 209 | public void Close() |
210 | { | 210 | { |
211 | m_log.Info("[GROUP]: Shutting down group module."); | 211 | m_log.Info("[GROUP]: Shutting down group module."); |
212 | lock (m_iclientmap) | 212 | lock (m_iclientmap) |
213 | { | 213 | { |
214 | m_iclientmap.Clear(); | 214 | m_iclientmap.Clear(); |
215 | } | 215 | } |
216 | 216 | ||
217 | lock (m_groupmap) | 217 | lock (m_groupmap) |
218 | { | 218 | { |
219 | m_groupmap.Clear(); | 219 | m_groupmap.Clear(); |
220 | } | 220 | } |
221 | 221 | ||
222 | lock (m_grouplistmap) | 222 | lock (m_grouplistmap) |
223 | { | 223 | { |
224 | m_grouplistmap.Clear(); | 224 | m_grouplistmap.Clear(); |
225 | } | 225 | } |
226 | GC.Collect(); | 226 | GC.Collect(); |
227 | } | 227 | } |
228 | 228 | ||
229 | public string Name | 229 | public string Name |
230 | { | 230 | { |
231 | get { return "GroupsModule"; } | 231 | get { return "GroupsModule"; } |
232 | } | 232 | } |
233 | 233 | ||
234 | public bool IsSharedModule | 234 | public bool IsSharedModule |
235 | { | 235 | { |
236 | get { return true; } | 236 | get { return true; } |
237 | } | 237 | } |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | public class GroupData | 241 | public class GroupData |
242 | { | 242 | { |
243 | public LLUUID GroupID; | 243 | public LLUUID GroupID; |
244 | public string groupName; | 244 | public string groupName; |
245 | public string ActiveGroupTitle; | 245 | public string ActiveGroupTitle; |
246 | public List<string> GroupTitles; | 246 | public List<string> GroupTitles; |
247 | public List<LLUUID> GroupMembers; | 247 | public List<LLUUID> GroupMembers; |
248 | public uint groupPowers = (uint)(GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome); | 248 | public uint groupPowers = (uint)(GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome); |
249 | 249 | ||
250 | public GroupPowers ActiveGroupPowers | 250 | public GroupPowers ActiveGroupPowers |
251 | { | 251 | { |
252 | set | 252 | set |
253 | { | 253 | { |
254 | groupPowers = (uint) value; | 254 | groupPowers = (uint) value; |
255 | } | 255 | } |
256 | get | 256 | get |
257 | { | 257 | { |
258 | return (GroupPowers)groupPowers; | 258 | return (GroupPowers)groupPowers; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | public GroupData() | 262 | public GroupData() |
263 | { | 263 | { |
264 | GroupTitles = new List<string>(); | 264 | GroupTitles = new List<string>(); |
265 | GroupMembers = new List<LLUUID>(); | 265 | GroupMembers = new List<LLUUID>(); |
266 | } | 266 | } |
267 | 267 | ||
268 | } | 268 | } |
269 | 269 | ||
270 | public class GroupList | 270 | public class GroupList |
271 | { | 271 | { |
272 | public List<LLUUID> m_GroupList; | 272 | public List<LLUUID> m_GroupList; |
273 | public GroupList() | 273 | public GroupList() |
274 | { | 274 | { |
275 | m_GroupList = new List<LLUUID>(); | 275 | m_GroupList = new List<LLUUID>(); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | } | 278 | } \ No newline at end of file |