diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs | 257 |
1 files changed, 0 insertions, 257 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs deleted file mode 100644 index af54c1a..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs +++ /dev/null | |||
@@ -1,257 +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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | |||
38 | using Mono.Addins; | ||
39 | |||
40 | namespace 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 | m_Enabled = groupsConfig.GetBoolean("Enabled", false); | ||
77 | if (!m_Enabled) | ||
78 | { | ||
79 | m_log.Info("[GROUPS]: Groups disabled in configuration"); | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | if (groupsConfig.GetString("Module", "Default") != "Default") | ||
84 | return; | ||
85 | } | ||
86 | |||
87 | } | ||
88 | |||
89 | public void AddRegion(Scene scene) | ||
90 | { | ||
91 | if (!m_Enabled) | ||
92 | return; | ||
93 | |||
94 | lock (m_SceneList) | ||
95 | { | ||
96 | if (!m_SceneList.Contains(scene)) | ||
97 | { | ||
98 | if (m_SceneList.Count == 0) | ||
99 | { | ||
100 | osGroup.GroupID = opensimulatorGroupID; | ||
101 | osGroup.GroupName = "OpenSimulator Testing"; | ||
102 | osGroup.GroupPowers = | ||
103 | (uint)(GroupPowers.AllowLandmark | | ||
104 | GroupPowers.AllowSetHome); | ||
105 | m_GroupMap[opensimulatorGroupID] = osGroup; | ||
106 | } | ||
107 | m_SceneList.Add(scene); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | scene.EventManager.OnNewClient += OnNewClient; | ||
112 | scene.EventManager.OnClientClosed += OnClientClosed; | ||
113 | // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
114 | } | ||
115 | |||
116 | public void RemoveRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | lock (m_SceneList) | ||
122 | { | ||
123 | if (m_SceneList.Contains(scene)) | ||
124 | m_SceneList.Remove(scene); | ||
125 | } | ||
126 | |||
127 | scene.EventManager.OnNewClient -= OnNewClient; | ||
128 | scene.EventManager.OnClientClosed -= OnClientClosed; | ||
129 | } | ||
130 | |||
131 | public void RegionLoaded(Scene scene) | ||
132 | { | ||
133 | } | ||
134 | |||
135 | public void PostInitialise() | ||
136 | { | ||
137 | } | ||
138 | |||
139 | public void Close() | ||
140 | { | ||
141 | if (!m_Enabled) | ||
142 | return; | ||
143 | |||
144 | // m_log.Debug("[GROUPS]: Shutting down group module."); | ||
145 | |||
146 | lock (m_ClientMap) | ||
147 | { | ||
148 | m_ClientMap.Clear(); | ||
149 | } | ||
150 | |||
151 | lock (m_GroupMap) | ||
152 | { | ||
153 | m_GroupMap.Clear(); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | public string Name | ||
158 | { | ||
159 | get { return "GroupsModule"; } | ||
160 | } | ||
161 | |||
162 | public Type ReplaceableInterface | ||
163 | { | ||
164 | get { return null; } | ||
165 | } | ||
166 | |||
167 | #endregion | ||
168 | |||
169 | private void OnNewClient(IClientAPI client) | ||
170 | { | ||
171 | // Subscribe to instant messages | ||
172 | // client.OnInstantMessage += OnInstantMessage; | ||
173 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; | ||
174 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; | ||
175 | lock (m_ClientMap) | ||
176 | { | ||
177 | if (!m_ClientMap.ContainsKey(client.AgentId)) | ||
178 | { | ||
179 | m_ClientMap.Add(client.AgentId, client); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | GroupMembershipData[] updateGroups = new GroupMembershipData[1]; | ||
184 | updateGroups[0] = osGroup; | ||
185 | |||
186 | client.SendGroupMembership(updateGroups); | ||
187 | } | ||
188 | |||
189 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, | ||
190 | UUID AgentID, UUID SessionID) | ||
191 | { | ||
192 | UUID ActiveGroupID; | ||
193 | string ActiveGroupName; | ||
194 | ulong ActiveGroupPowers; | ||
195 | |||
196 | string firstname = remoteClient.FirstName; | ||
197 | string lastname = remoteClient.LastName; | ||
198 | |||
199 | string ActiveGroupTitle = "I IZ N0T"; | ||
200 | |||
201 | ActiveGroupID = osGroup.GroupID; | ||
202 | ActiveGroupName = osGroup.GroupName; | ||
203 | ActiveGroupPowers = osGroup.GroupPowers; | ||
204 | |||
205 | remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, | ||
206 | lastname, ActiveGroupPowers, ActiveGroupName, | ||
207 | ActiveGroupTitle); | ||
208 | } | ||
209 | |||
210 | // private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | ||
211 | // { | ||
212 | // } | ||
213 | |||
214 | // private void OnGridInstantMessage(GridInstantMessage msg) | ||
215 | // { | ||
216 | // // Trigger the above event handler | ||
217 | // OnInstantMessage(null, msg); | ||
218 | // } | ||
219 | |||
220 | private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client) | ||
221 | { | ||
222 | string groupnamereply = "Unknown"; | ||
223 | UUID groupUUID = UUID.Zero; | ||
224 | |||
225 | lock (m_GroupMap) | ||
226 | { | ||
227 | if (m_GroupMap.ContainsKey(id)) | ||
228 | { | ||
229 | GroupMembershipData grp = m_GroupMap[id]; | ||
230 | groupnamereply = grp.GroupName; | ||
231 | groupUUID = grp.GroupID; | ||
232 | } | ||
233 | } | ||
234 | remote_client.SendGroupNameReply(groupUUID, groupnamereply); | ||
235 | } | ||
236 | |||
237 | private void OnClientClosed(UUID agentID, Scene scene) | ||
238 | { | ||
239 | lock (m_ClientMap) | ||
240 | { | ||
241 | if (m_ClientMap.ContainsKey(agentID)) | ||
242 | { | ||
243 | // IClientAPI cli = m_ClientMap[agentID]; | ||
244 | // if (cli != null) | ||
245 | // { | ||
246 | // //m_log.Info("[GROUPS]: Removing all reference to groups for " + cli.Name); | ||
247 | // } | ||
248 | // else | ||
249 | // { | ||
250 | // //m_log.Info("[GROUPS]: Removing all reference to groups for " + agentID.ToString()); | ||
251 | // } | ||
252 | m_ClientMap.Remove(agentID); | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | } | ||