aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Groups
diff options
context:
space:
mode:
authorAdam Frisby2008-04-30 21:16:36 +0000
committerAdam Frisby2008-04-30 21:16:36 +0000
commitf5c312bc3c2567449c7268a54a08a54119f58d53 (patch)
tree424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/Avatar/Groups
parent* Adds the AuthbuyerID field to sqlite and makes use of it. (diff)
downloadopensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.zip
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.xz
* Refactored Environment/Modules directory - modules now reside in their own directory with any associated module-specific classes.
* Each module directory is currently inside one of the following category folders: Agent (Anything relating to do with Client<->Server communications.), Avatar (Anything to do with the avatar or presence inworld), Framework (Classes modules can use), Grid (Grid traffic, new OGS2 grid comms), Scripting (Scripting functions, etc), World (The enrivonment/scene, IE Sun/Tree modules.) * This should be moved into a seperate project file.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Groups')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs278
1 files changed, 278 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
new file mode 100644
index 0000000..4b28ad7
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
@@ -0,0 +1,278 @@
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 libsecondlife;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes;
37
38namespace OpenSim.Region.Environment.Modules.Avatar.Groups
39{
40 public class GroupsModule : IRegionModule
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 private List<Scene> m_scene = new List<Scene>();
45 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
46 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
47 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
48
49 public void Initialise(Scene scene, IConfigSource config)
50 {
51 lock (m_scene)
52 {
53 m_scene.Add(scene);
54 }
55 scene.EventManager.OnNewClient += OnNewClient;
56 scene.EventManager.OnClientClosed += OnClientClosed;
57 scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage;
58 //scene.EventManager.
59 }
60
61 private void OnNewClient(IClientAPI client)
62 {
63 // All friends establishment protocol goes over instant message
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
66 //
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
69
70 // Subscribe to instant messages
71 client.OnInstantMessage += OnInstantMessage;
72 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
73 lock (m_iclientmap)
74 {
75 if (!m_iclientmap.ContainsKey(client.AgentId))
76 {
77 m_iclientmap.Add(client.AgentId, client);
78 }
79 }
80 GroupData OpenSimulatorGroup = new GroupData();
81 OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester";
82 OpenSimulatorGroup.GroupID = new LLUUID("00000000-68f9-1111-024e-222222111120");
83 OpenSimulatorGroup.GroupMembers.Add(client.AgentId);
84 OpenSimulatorGroup.groupName = "OpenSimulator Testing";
85 OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.LandAllowSetHome;
86 OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester");
87 lock (m_groupmap)
88 {
89 if (!m_groupmap.ContainsKey(client.AgentId))
90 {
91 m_groupmap.Add(client.AgentId, OpenSimulatorGroup);
92 }
93 }
94 GroupList testGroupList = new GroupList();
95 testGroupList.m_GroupList.Add(new LLUUID("00000000-68f9-1111-024e-222222111120"));
96
97 lock (m_grouplistmap)
98 {
99 if (!m_grouplistmap.ContainsKey(client.AgentId))
100 {
101 m_grouplistmap.Add(client.AgentId, testGroupList);
102 }
103 }
104 m_log.Info("[GROUP]: Adding " + client.FirstName + " " + client.LastName + " to OpenSimulator Tester group");
105 }
106
107 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, LLUUID AgentID, LLUUID SessionID)
108 {
109 string firstname = remoteClient.FirstName;
110 string lastname = remoteClient.LastName;
111
112 LLUUID ActiveGroupID = LLUUID.Zero;
113 uint ActiveGroupPowers = 0;
114 string ActiveGroupName = "";
115 string ActiveGroupTitle = "";
116
117 bool foundUser = false;
118
119 lock (m_iclientmap)
120 {
121 if (m_iclientmap.ContainsKey(remoteClient.AgentId))
122 {
123 foundUser = true;
124 }
125 }
126 if (foundUser)
127 {
128 lock (m_groupmap)
129 {
130 if (m_groupmap.ContainsKey(remoteClient.AgentId))
131 {
132 GroupData grp = m_groupmap[remoteClient.AgentId];
133 if (grp != null)
134 {
135 ActiveGroupID = grp.GroupID;
136 ActiveGroupName = grp.groupName;
137 ActiveGroupPowers = grp.groupPowers;
138 ActiveGroupTitle = grp.ActiveGroupTitle;
139 }
140
141 //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle);
142
143 }
144 }
145 }
146
147 }
148
149 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
150 LLUUID fromAgentSession, LLUUID toAgentID,
151 LLUUID imSessionID, uint timestamp, string fromAgentName,
152 string message, byte dialog, bool fromGroup, byte offline,
153 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
154 byte[] binaryBucket)
155 {
156 }
157
158 private void OnGridInstantMessage(GridInstantMessage msg)
159 {
160 // Trigger the above event handler
161 OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
162 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
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),
165 msg.binaryBucket);
166 }
167
168 private void OnClientClosed(LLUUID agentID)
169 {
170 lock (m_iclientmap)
171 {
172 if (m_iclientmap.ContainsKey(agentID))
173 {
174 IClientAPI cli = m_iclientmap[agentID];
175 if (cli != null)
176 {
177 m_log.Info("[GROUP]: Removing all reference to groups for " + cli.FirstName + " " + cli.LastName);
178 }
179 else
180 {
181 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString());
182 }
183 m_iclientmap.Remove(agentID);
184 }
185 }
186
187 lock (m_groupmap)
188 {
189 if (m_groupmap.ContainsKey(agentID))
190 {
191 m_groupmap.Remove(agentID);
192 }
193 }
194
195 lock (m_grouplistmap)
196 {
197 if (m_grouplistmap.ContainsKey(agentID))
198 {
199 m_grouplistmap.Remove(agentID);
200 }
201 }
202 GC.Collect();
203 }
204
205 public void PostInitialise()
206 {
207 }
208
209 public void Close()
210 {
211 m_log.Info("[GROUP]: Shutting down group module.");
212 lock (m_iclientmap)
213 {
214 m_iclientmap.Clear();
215 }
216
217 lock (m_groupmap)
218 {
219 m_groupmap.Clear();
220 }
221
222 lock (m_grouplistmap)
223 {
224 m_grouplistmap.Clear();
225 }
226 GC.Collect();
227 }
228
229 public string Name
230 {
231 get { return "GroupsModule"; }
232 }
233
234 public bool IsSharedModule
235 {
236 get { return true; }
237 }
238
239 }
240
241 public class GroupData
242 {
243 public LLUUID GroupID;
244 public string groupName;
245 public string ActiveGroupTitle;
246 public List<string> GroupTitles;
247 public List<LLUUID> GroupMembers;
248 public uint groupPowers = (uint)(GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome);
249
250 public GroupPowers ActiveGroupPowers
251 {
252 set
253 {
254 groupPowers = (uint) value;
255 }
256 get
257 {
258 return (GroupPowers)groupPowers;
259 }
260 }
261
262 public GroupData()
263 {
264 GroupTitles = new List<string>();
265 GroupMembers = new List<LLUUID>();
266 }
267
268 }
269
270 public class GroupList
271 {
272 public List<LLUUID> m_GroupList;
273 public GroupList()
274 {
275 m_GroupList = new List<LLUUID>();
276 }
277 }
278} \ No newline at end of file