aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Groups
diff options
context:
space:
mode:
authorDr Scofield2009-02-10 13:10:57 +0000
committerDr Scofield2009-02-10 13:10:57 +0000
commit180be7de07014aa33bc6066f12a0819b731c1c9d (patch)
tree3aa13af3cda4b808fa9453655875327699b61311 /OpenSim/Region/CoreModules/Avatar/Groups
parentStopgap measure: To use gridlaunch, or GUI, start opensim with (diff)
downloadopensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.zip
opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.gz
opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.bz2
opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.xz
this is step 2 of 2 of the OpenSim.Region.Environment refactor.
NOTHING has been deleted or moved off to forge at this point. what has happened is that OpenSim.Region.Environment.Modules has been split in two: - OpenSim.Region.CoreModules: all those modules that are either directly or indirectly referenced from other OpenSim packages, or that provide functionality that the OpenSim developer community considers core functionality: CoreModules/Agent/AssetTransaction CoreModules/Agent/Capabilities CoreModules/Agent/TextureDownload CoreModules/Agent/TextureSender CoreModules/Agent/TextureSender/Tests CoreModules/Agent/Xfer CoreModules/Avatar/AvatarFactory CoreModules/Avatar/Chat/ChatModule CoreModules/Avatar/Combat CoreModules/Avatar/Currency/SampleMoney CoreModules/Avatar/Dialog CoreModules/Avatar/Friends CoreModules/Avatar/Gestures CoreModules/Avatar/Groups CoreModules/Avatar/InstantMessage CoreModules/Avatar/Inventory CoreModules/Avatar/Inventory/Archiver CoreModules/Avatar/Inventory/Transfer CoreModules/Avatar/Lure CoreModules/Avatar/ObjectCaps CoreModules/Avatar/Profiles CoreModules/Communications/Local CoreModules/Communications/REST CoreModules/Framework/EventQueue CoreModules/Framework/InterfaceCommander CoreModules/Hypergrid CoreModules/InterGrid CoreModules/Scripting/DynamicTexture CoreModules/Scripting/EMailModules CoreModules/Scripting/HttpRequest CoreModules/Scripting/LoadImageURL CoreModules/Scripting/VectorRender CoreModules/Scripting/WorldComm CoreModules/Scripting/XMLRPC CoreModules/World/Archiver CoreModules/World/Archiver/Tests CoreModules/World/Estate CoreModules/World/Land CoreModules/World/Permissions CoreModules/World/Serialiser CoreModules/World/Sound CoreModules/World/Sun CoreModules/World/Terrain CoreModules/World/Terrain/DefaultEffects CoreModules/World/Terrain/DefaultEffects/bin CoreModules/World/Terrain/DefaultEffects/bin/Debug CoreModules/World/Terrain/Effects CoreModules/World/Terrain/FileLoaders CoreModules/World/Terrain/FloodBrushes CoreModules/World/Terrain/PaintBrushes CoreModules/World/Terrain/Tests CoreModules/World/Vegetation CoreModules/World/Wind CoreModules/World/WorldMap - OpenSim.Region.OptionalModules: all those modules that are not core modules: OptionalModules/Avatar/Chat/IRC-stuff OptionalModules/Avatar/Concierge OptionalModules/Avatar/Voice/AsterixVoice OptionalModules/Avatar/Voice/SIPVoice OptionalModules/ContentManagementSystem OptionalModules/Grid/Interregion OptionalModules/Python OptionalModules/SvnSerialiser OptionalModules/World/NPC OptionalModules/World/TreePopulator
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Groups')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs223
1 files changed, 223 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
new file mode 100644
index 0000000..92d0fdd
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
@@ -0,0 +1,223 @@
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 OpenSim 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 OpenMetaverse;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37
38namespace OpenSim.Region.CoreModules.Avatar.Groups
39{
40 public class GroupsModule : IRegionModule
41 {
42 private static readonly ILog m_log =
43 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 private Dictionary<UUID, GroupMembershipData> m_GroupMap =
46 new Dictionary<UUID, GroupMembershipData>();
47
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();
58
59 #region IRegionModule Members
60
61 public void Initialise(Scene scene, IConfigSource config)
62 {
63 IConfig groupsConfig = config.Configs["Groups"];
64
65 if (groupsConfig == null)
66 {
67 m_log.Info("[GROUPS]: No configuration found. Using defaults");
68 }
69 else
70 {
71 if (!groupsConfig.GetBoolean("Enabled", false))
72 {
73 m_log.Info("[GROUPS]: Groups disabled in configuration");
74 return;
75 }
76
77 if (groupsConfig.GetString("Module", "Default") != "Default")
78 return;
79 }
80
81 lock (m_SceneList)
82 {
83 if (!m_SceneList.Contains(scene))
84 {
85 if (m_SceneList.Count == 0)
86 {
87 osGroup.GroupID = opensimulatorGroupID;
88 osGroup.GroupName = "OpenSimulator Testing";
89 osGroup.GroupPowers =
90 (uint)(GroupPowers.AllowLandmark |
91 GroupPowers.AllowSetHome);
92 m_GroupMap[opensimulatorGroupID] = osGroup;
93 }
94 m_SceneList.Add(scene);
95 }
96 }
97
98 scene.EventManager.OnNewClient += OnNewClient;
99 scene.EventManager.OnClientClosed += OnClientClosed;
100 scene.EventManager.OnIncomingInstantMessage +=
101 OnGridInstantMessage;
102 }
103
104 public void PostInitialise()
105 {
106 }
107
108 public void Close()
109 {
110// m_log.Debug("[GROUPS]: Shutting down group module.");
111
112 lock (m_ClientMap)
113 {
114 m_ClientMap.Clear();
115 }
116
117 lock (m_GroupMap)
118 {
119 m_GroupMap.Clear();
120 }
121 }
122
123 public string Name
124 {
125 get { return "GroupsModule"; }
126 }
127
128 public bool IsSharedModule
129 {
130 get { return true; }
131 }
132
133 #endregion
134
135 private void OnNewClient(IClientAPI client)
136 {
137 // Subscribe to instant messages
138 client.OnInstantMessage += OnInstantMessage;
139 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
140 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
141 lock (m_ClientMap)
142 {
143 if (!m_ClientMap.ContainsKey(client.AgentId))
144 {
145 m_ClientMap.Add(client.AgentId, client);
146 }
147 }
148
149 GroupMembershipData[] updateGroups = new GroupMembershipData[1];
150 updateGroups[0] = osGroup;
151
152 client.SendGroupMembership(updateGroups);
153 }
154
155 private void OnAgentDataUpdateRequest(IClientAPI remoteClient,
156 UUID AgentID, UUID SessionID)
157 {
158 UUID ActiveGroupID;
159 string ActiveGroupName;
160 ulong ActiveGroupPowers;
161
162 string firstname = remoteClient.FirstName;
163 string lastname = remoteClient.LastName;
164
165 string ActiveGroupTitle = "I IZ N0T";
166
167 ActiveGroupID = osGroup.GroupID;
168 ActiveGroupName = osGroup.GroupName;
169 ActiveGroupPowers = osGroup.GroupPowers;
170
171 remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname,
172 lastname, ActiveGroupPowers, ActiveGroupName,
173 ActiveGroupTitle);
174 }
175
176 private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
177 {
178 }
179
180 private void OnGridInstantMessage(GridInstantMessage msg)
181 {
182 // Trigger the above event handler
183 OnInstantMessage(null, msg);
184 }
185
186 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)
187 {
188 string groupnamereply = "Unknown";
189 UUID groupUUID = UUID.Zero;
190
191 lock (m_GroupMap)
192 {
193 if (m_GroupMap.ContainsKey(id))
194 {
195 GroupMembershipData grp = m_GroupMap[id];
196 groupnamereply = grp.GroupName;
197 groupUUID = grp.GroupID;
198 }
199 }
200 remote_client.SendGroupNameReply(groupUUID, groupnamereply);
201 }
202
203 private void OnClientClosed(UUID agentID)
204 {
205 lock (m_ClientMap)
206 {
207 if (m_ClientMap.ContainsKey(agentID))
208 {
209// IClientAPI cli = m_ClientMap[agentID];
210// if (cli != null)
211// {
212// //m_log.Info("[GROUPS]: Removing all reference to groups for " + cli.Name);
213// }
214// else
215// {
216// //m_log.Info("[GROUPS]: Removing all reference to groups for " + agentID.ToString());
217// }
218 m_ClientMap.Remove(agentID);
219 }
220 }
221 }
222 }
223}