aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs252
1 files changed, 0 insertions, 252 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
deleted file mode 100644
index d2ef6b1..0000000
--- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
+++ /dev/null
@@ -1,252 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37
38using Mono.Addins;
39
40namespace OpenSim.Region.CoreModules.Avatar.Groups
41{
42 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")]
43 public class GroupsModule : ISharedRegionModule
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private Dictionary<UUID, GroupMembershipData> m_GroupMap =
49 new Dictionary<UUID, GroupMembershipData>();
50
51 private Dictionary<UUID, IClientAPI> m_ClientMap =
52 new Dictionary<UUID, IClientAPI>();
53
54 private UUID opensimulatorGroupID =
55 new UUID("00000000-68f9-1111-024e-222222111123");
56
57 private List<Scene> m_SceneList = new List<Scene>();
58
59 private static GroupMembershipData osGroup =
60 new GroupMembershipData();
61
62 private bool m_Enabled = false;
63
64 #region ISharedRegionModule Members
65
66 public void Initialise(IConfigSource config)
67 {
68 IConfig groupsConfig = config.Configs["Groups"];
69
70 if (groupsConfig == null)
71 {
72 m_log.Info("[GROUPS]: No configuration found. Using defaults");
73 }
74 else
75 {
76 if (groupsConfig.GetBoolean("Enabled", false))
77 {
78 if (groupsConfig.GetString("Module", "Default") == "Default")
79 m_Enabled = true;
80 }
81 }
82 }
83
84 public void AddRegion(Scene scene)
85 {
86 if (!m_Enabled)
87 return;
88
89 lock (m_SceneList)
90 {
91 if (!m_SceneList.Contains(scene))
92 {
93 if (m_SceneList.Count == 0)
94 {
95 osGroup.GroupID = opensimulatorGroupID;
96 osGroup.GroupName = "OpenSimulator Testing";
97 osGroup.GroupPowers =
98 (uint)(GroupPowers.AllowLandmark |
99 GroupPowers.AllowSetHome);
100 m_GroupMap[opensimulatorGroupID] = osGroup;
101 }
102 m_SceneList.Add(scene);
103 }
104 }
105
106 scene.EventManager.OnNewClient += OnNewClient;
107 scene.EventManager.OnClientClosed += OnClientClosed;
108 // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
109 }
110
111 public void RemoveRegion(Scene scene)
112 {
113 if (!m_Enabled)
114 return;
115
116 lock (m_SceneList)
117 {
118 if (m_SceneList.Contains(scene))
119 m_SceneList.Remove(scene);
120 }
121
122 scene.EventManager.OnNewClient -= OnNewClient;
123 scene.EventManager.OnClientClosed -= OnClientClosed;
124 }
125
126 public void RegionLoaded(Scene scene)
127 {
128 }
129
130 public void PostInitialise()
131 {
132 }
133
134 public void Close()
135 {
136 if (!m_Enabled)
137 return;
138
139// m_log.Debug("[GROUPS]: Shutting down group module.");
140
141 lock (m_ClientMap)
142 {
143 m_ClientMap.Clear();
144 }
145
146 lock (m_GroupMap)
147 {
148 m_GroupMap.Clear();
149 }
150 }
151
152 public string Name
153 {
154 get { return "GroupsModule"; }
155 }
156
157 public Type ReplaceableInterface
158 {
159 get { return null; }
160 }
161
162 #endregion
163
164 private void OnNewClient(IClientAPI client)
165 {
166 // Subscribe to instant messages
167// client.OnInstantMessage += OnInstantMessage;
168 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
169 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
170 lock (m_ClientMap)
171 {
172 if (!m_ClientMap.ContainsKey(client.AgentId))
173 {
174 m_ClientMap.Add(client.AgentId, client);
175 }
176 }
177
178 GroupMembershipData[] updateGroups = new GroupMembershipData[1];
179 updateGroups[0] = osGroup;
180
181 client.SendGroupMembership(updateGroups);
182 }
183
184 private void OnAgentDataUpdateRequest(IClientAPI remoteClient,
185 UUID AgentID, UUID SessionID)
186 {
187 UUID ActiveGroupID;
188 string ActiveGroupName;
189 ulong ActiveGroupPowers;
190
191 string firstname = remoteClient.FirstName;
192 string lastname = remoteClient.LastName;
193
194 string ActiveGroupTitle = "I IZ N0T";
195
196 ActiveGroupID = osGroup.GroupID;
197 ActiveGroupName = osGroup.GroupName;
198 ActiveGroupPowers = osGroup.GroupPowers;
199
200 remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname,
201 lastname, ActiveGroupPowers, ActiveGroupName,
202 ActiveGroupTitle);
203 }
204
205// private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
206// {
207// }
208
209// private void OnGridInstantMessage(GridInstantMessage msg)
210// {
211// // Trigger the above event handler
212// OnInstantMessage(null, msg);
213// }
214
215 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)
216 {
217 string groupnamereply = "Unknown";
218 UUID groupUUID = UUID.Zero;
219
220 lock (m_GroupMap)
221 {
222 if (m_GroupMap.ContainsKey(id))
223 {
224 GroupMembershipData grp = m_GroupMap[id];
225 groupnamereply = grp.GroupName;
226 groupUUID = grp.GroupID;
227 }
228 }
229 remote_client.SendGroupNameReply(groupUUID, groupnamereply);
230 }
231
232 private void OnClientClosed(UUID agentID, Scene scene)
233 {
234 lock (m_ClientMap)
235 {
236 if (m_ClientMap.ContainsKey(agentID))
237 {
238// IClientAPI cli = m_ClientMap[agentID];
239// if (cli != null)
240// {
241// //m_log.Info("[GROUPS]: Removing all reference to groups for " + cli.Name);
242// }
243// else
244// {
245// //m_log.Info("[GROUPS]: Removing all reference to groups for " + agentID.ToString());
246// }
247 m_ClientMap.Remove(agentID);
248 }
249 }
250 }
251 }
252}