diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups')
5 files changed, 1974 insertions, 494 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 00fe5df..185d44d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -28,41 +28,30 @@ | |||
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 | |||
32 | |||
33 | using log4net; | 31 | using log4net; |
34 | using Mono.Addins; | 32 | using Mono.Addins; |
35 | using Nini.Config; | 33 | using Nini.Config; |
36 | |||
37 | using OpenMetaverse; | 34 | using OpenMetaverse; |
38 | using OpenMetaverse.StructuredData; | 35 | using OpenMetaverse.StructuredData; |
39 | |||
40 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
41 | using OpenSim.Region.CoreModules.Framework.EventQueue; | 37 | using OpenSim.Region.CoreModules.Framework.EventQueue; |
42 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
44 | 40 | ||
45 | |||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | 41 | using Caps = OpenSim.Framework.Capabilities.Caps; |
47 | 42 | ||
48 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 43 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
49 | { | 44 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
51 | public class GroupsMessagingModule : ISharedRegionModule | 46 | public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule |
52 | { | 47 | { |
53 | |||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 49 | ||
56 | private List<Scene> m_sceneList = new List<Scene>(); | 50 | private List<Scene> m_sceneList = new List<Scene>(); |
57 | 51 | ||
58 | private IMessageTransferModule m_msgTransferModule = null; | 52 | private IMessageTransferModule m_msgTransferModule = null; |
59 | 53 | ||
60 | private IGroupsModule m_groupsModule = null; | 54 | private IGroupsServicesConnector m_groupData = null; |
61 | |||
62 | // TODO: Move this off to the Groups Server | ||
63 | public Dictionary<Guid, List<Guid>> m_agentsInGroupSession = new Dictionary<Guid, List<Guid>>(); | ||
64 | public Dictionary<Guid, List<Guid>> m_agentsDroppedSession = new Dictionary<Guid, List<Guid>>(); | ||
65 | |||
66 | 55 | ||
67 | // Config Options | 56 | // Config Options |
68 | private bool m_groupMessagingEnabled = false; | 57 | private bool m_groupMessagingEnabled = false; |
@@ -108,8 +97,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
108 | 97 | ||
109 | public void AddRegion(Scene scene) | 98 | public void AddRegion(Scene scene) |
110 | { | 99 | { |
111 | // NoOp | 100 | if (!m_groupMessagingEnabled) |
101 | return; | ||
102 | |||
103 | scene.RegisterModuleInterface<IGroupsMessagingModule>(this); | ||
112 | } | 104 | } |
105 | |||
113 | public void RegionLoaded(Scene scene) | 106 | public void RegionLoaded(Scene scene) |
114 | { | 107 | { |
115 | if (!m_groupMessagingEnabled) | 108 | if (!m_groupMessagingEnabled) |
@@ -117,12 +110,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
117 | 110 | ||
118 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 111 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
119 | 112 | ||
120 | m_groupsModule = scene.RequestModuleInterface<IGroupsModule>(); | 113 | m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>(); |
121 | 114 | ||
122 | // No groups module, no groups messaging | 115 | // No groups module, no groups messaging |
123 | if (m_groupsModule == null) | 116 | if (m_groupData == null) |
124 | { | 117 | { |
125 | m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsModule, GroupsMessagingModule is now disabled."); | 118 | m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled."); |
126 | Close(); | 119 | Close(); |
127 | m_groupMessagingEnabled = false; | 120 | m_groupMessagingEnabled = false; |
128 | return; | 121 | return; |
@@ -144,7 +137,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
144 | 137 | ||
145 | scene.EventManager.OnNewClient += OnNewClient; | 138 | scene.EventManager.OnNewClient += OnNewClient; |
146 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 139 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
147 | 140 | scene.EventManager.OnClientLogin += OnClientLogin; | |
148 | } | 141 | } |
149 | 142 | ||
150 | public void RemoveRegion(Scene scene) | 143 | public void RemoveRegion(Scene scene) |
@@ -172,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
172 | 165 | ||
173 | m_sceneList.Clear(); | 166 | m_sceneList.Clear(); |
174 | 167 | ||
175 | m_groupsModule = null; | 168 | m_groupData = null; |
176 | m_msgTransferModule = null; | 169 | m_msgTransferModule = null; |
177 | } | 170 | } |
178 | 171 | ||
@@ -197,8 +190,84 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
197 | 190 | ||
198 | #endregion | 191 | #endregion |
199 | 192 | ||
193 | /// <summary> | ||
194 | /// Not really needed, but does confirm that the group exists. | ||
195 | /// </summary> | ||
196 | public bool StartGroupChatSession(UUID agentID, UUID groupID) | ||
197 | { | ||
198 | if (m_debugEnabled) | ||
199 | m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
200 | |||
201 | GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null); | ||
202 | |||
203 | if (groupInfo != null) | ||
204 | { | ||
205 | return true; | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | return false; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | public void SendMessageToGroup(GridInstantMessage im, UUID groupID) | ||
214 | { | ||
215 | if (m_debugEnabled) | ||
216 | m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
217 | |||
218 | |||
219 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID)) | ||
220 | { | ||
221 | if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) | ||
222 | { | ||
223 | // Don't deliver messages to people who have dropped this session | ||
224 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | ||
225 | continue; | ||
226 | } | ||
227 | |||
228 | // Copy Message | ||
229 | GridInstantMessage msg = new GridInstantMessage(); | ||
230 | msg.imSessionID = groupID.Guid; | ||
231 | msg.fromAgentName = im.fromAgentName; | ||
232 | msg.message = im.message; | ||
233 | msg.dialog = im.dialog; | ||
234 | msg.offline = im.offline; | ||
235 | msg.ParentEstateID = im.ParentEstateID; | ||
236 | msg.Position = im.Position; | ||
237 | msg.RegionID = im.RegionID; | ||
238 | msg.binaryBucket = im.binaryBucket; | ||
239 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
240 | |||
241 | msg.fromAgentID = im.fromAgentID; | ||
242 | msg.fromGroup = true; | ||
243 | |||
244 | msg.toAgentID = member.AgentID.Guid; | ||
245 | |||
246 | IClientAPI client = GetActiveClient(member.AgentID); | ||
247 | if (client == null) | ||
248 | { | ||
249 | // If they're not local, forward across the grid | ||
250 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); | ||
251 | m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | // Deliver locally, directly | ||
256 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); | ||
257 | ProcessMessageFromGroupSession(msg); | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | |||
200 | #region SimGridEventHandlers | 262 | #region SimGridEventHandlers |
201 | 263 | ||
264 | void OnClientLogin(IClientAPI client) | ||
265 | { | ||
266 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name); | ||
267 | |||
268 | |||
269 | } | ||
270 | |||
202 | private void OnNewClient(IClientAPI client) | 271 | private void OnNewClient(IClientAPI client) |
203 | { | 272 | { |
204 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name); | 273 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name); |
@@ -236,42 +305,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
236 | { | 305 | { |
237 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); | 306 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); |
238 | 307 | ||
308 | UUID AgentID = new UUID(msg.fromAgentID); | ||
309 | UUID GroupID = new UUID(msg.imSessionID); | ||
310 | |||
239 | switch (msg.dialog) | 311 | switch (msg.dialog) |
240 | { | 312 | { |
241 | case (byte)InstantMessageDialog.SessionAdd: | 313 | case (byte)InstantMessageDialog.SessionAdd: |
242 | AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID); | 314 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); |
243 | break; | 315 | break; |
244 | 316 | ||
245 | case (byte)InstantMessageDialog.SessionDrop: | 317 | case (byte)InstantMessageDialog.SessionDrop: |
246 | RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID); | 318 | m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID); |
247 | break; | 319 | break; |
248 | 320 | ||
249 | case (byte)InstantMessageDialog.SessionSend: | 321 | case (byte)InstantMessageDialog.SessionSend: |
250 | if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) | 322 | if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) |
251 | && !m_agentsDroppedSession.ContainsKey(msg.toAgentID)) | 323 | && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID) |
324 | ) | ||
252 | { | 325 | { |
253 | // Agent not in session and hasn't dropped from session | 326 | // Agent not in session and hasn't dropped from session |
254 | // Add them to the session for now, and Invite them | 327 | // Add them to the session for now, and Invite them |
255 | AddAgentToGroupSession(msg.toAgentID, msg.imSessionID); | 328 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); |
256 | 329 | ||
257 | UUID toAgentID = new UUID(msg.toAgentID); | 330 | UUID toAgentID = new UUID(msg.toAgentID); |
258 | IClientAPI activeClient = GetActiveClient(toAgentID); | 331 | IClientAPI activeClient = GetActiveClient(toAgentID); |
259 | if (activeClient != null) | 332 | if (activeClient != null) |
260 | { | 333 | { |
261 | UUID groupID = new UUID(msg.fromAgentID); | 334 | GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); |
262 | |||
263 | GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); | ||
264 | if (groupInfo != null) | 335 | if (groupInfo != null) |
265 | { | 336 | { |
266 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); | 337 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); |
267 | 338 | ||
268 | // Force? open the group session dialog??? | 339 | // Force? open the group session dialog??? |
340 | // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg); | ||
269 | IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); | 341 | IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); |
270 | eq.ChatterboxInvitation( | 342 | eq.ChatterboxInvitation( |
271 | groupID | 343 | GroupID |
272 | , groupInfo.GroupName | 344 | , groupInfo.GroupName |
273 | , new UUID(msg.fromAgentID) | 345 | , new UUID(msg.fromAgentID) |
274 | , msg.message, new UUID(msg.toAgentID) | 346 | , msg.message |
347 | , new UUID(msg.toAgentID) | ||
275 | , msg.fromAgentName | 348 | , msg.fromAgentName |
276 | , msg.dialog | 349 | , msg.dialog |
277 | , msg.timestamp | 350 | , msg.timestamp |
@@ -285,7 +358,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
285 | ); | 358 | ); |
286 | 359 | ||
287 | eq.ChatterBoxSessionAgentListUpdates( | 360 | eq.ChatterBoxSessionAgentListUpdates( |
288 | new UUID(groupID) | 361 | new UUID(GroupID) |
289 | , new UUID(msg.fromAgentID) | 362 | , new UUID(msg.fromAgentID) |
290 | , new UUID(msg.toAgentID) | 363 | , new UUID(msg.toAgentID) |
291 | , false //canVoiceChat | 364 | , false //canVoiceChat |
@@ -295,7 +368,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
295 | } | 368 | } |
296 | } | 369 | } |
297 | } | 370 | } |
298 | else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID)) | 371 | else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) |
299 | { | 372 | { |
300 | // User hasn't dropped, so they're in the session, | 373 | // User hasn't dropped, so they're in the session, |
301 | // maybe we should deliver it. | 374 | // maybe we should deliver it. |
@@ -321,56 +394,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
321 | 394 | ||
322 | #endregion | 395 | #endregion |
323 | 396 | ||
324 | #region ClientEvents | ||
325 | |||
326 | private void RemoveAgentFromGroupSession(Guid agentID, Guid sessionID) | ||
327 | { | ||
328 | if (m_agentsInGroupSession.ContainsKey(sessionID)) | ||
329 | { | ||
330 | // If in session remove | ||
331 | if (m_agentsInGroupSession[sessionID].Contains(agentID)) | ||
332 | { | ||
333 | m_agentsInGroupSession[sessionID].Remove(agentID); | ||
334 | } | ||
335 | |||
336 | // If not in dropped list, add | ||
337 | if (!m_agentsDroppedSession[sessionID].Contains(agentID)) | ||
338 | { | ||
339 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Dropped {1} from session {0}", sessionID, agentID); | ||
340 | m_agentsDroppedSession[sessionID].Add(agentID); | ||
341 | } | ||
342 | } | ||
343 | } | ||
344 | |||
345 | private void AddAgentToGroupSession(Guid agentID, Guid sessionID) | ||
346 | { | ||
347 | // Add Session Status if it doesn't exist for this session | ||
348 | CreateGroupSessionTracking(sessionID); | ||
349 | |||
350 | // If nessesary, remove from dropped list | ||
351 | if (m_agentsDroppedSession[sessionID].Contains(agentID)) | ||
352 | { | ||
353 | m_agentsDroppedSession[sessionID].Remove(agentID); | ||
354 | } | ||
355 | |||
356 | // If nessesary, add to in session list | ||
357 | if (!m_agentsInGroupSession[sessionID].Contains(agentID)) | ||
358 | { | ||
359 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Added {1} to session {0}", sessionID, agentID); | ||
360 | m_agentsInGroupSession[sessionID].Add(agentID); | ||
361 | } | ||
362 | } | ||
363 | |||
364 | private void CreateGroupSessionTracking(Guid sessionID) | ||
365 | { | ||
366 | if (!m_agentsInGroupSession.ContainsKey(sessionID)) | ||
367 | { | ||
368 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Creating session tracking for : {0}", sessionID); | ||
369 | m_agentsInGroupSession.Add(sessionID, new List<Guid>()); | ||
370 | m_agentsDroppedSession.Add(sessionID, new List<Guid>()); | ||
371 | } | ||
372 | } | ||
373 | 397 | ||
398 | #region ClientEvents | ||
374 | private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) | 399 | private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) |
375 | { | 400 | { |
376 | if (m_debugEnabled) | 401 | if (m_debugEnabled) |
@@ -383,21 +408,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
383 | // Start group IM session | 408 | // Start group IM session |
384 | if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) | 409 | if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) |
385 | { | 410 | { |
386 | UUID groupID = new UUID(im.toAgentID); | 411 | if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID); |
387 | 412 | ||
388 | GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); | 413 | UUID GroupID = new UUID(im.imSessionID); |
414 | UUID AgentID = new UUID(im.fromAgentID); | ||
415 | |||
416 | GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); | ||
417 | |||
389 | if (groupInfo != null) | 418 | if (groupInfo != null) |
390 | { | 419 | { |
391 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); | 420 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); |
392 | |||
393 | AddAgentToGroupSession(im.fromAgentID, im.imSessionID); | ||
394 | 421 | ||
395 | ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); | 422 | ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID); |
396 | 423 | ||
397 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); | 424 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); |
398 | queue.ChatterBoxSessionAgentListUpdates( | 425 | queue.ChatterBoxSessionAgentListUpdates( |
399 | new UUID(groupID) | 426 | GroupID |
400 | , new UUID(im.fromAgentID) | 427 | , AgentID |
401 | , new UUID(im.toAgentID) | 428 | , new UUID(im.toAgentID) |
402 | , false //canVoiceChat | 429 | , false //canVoiceChat |
403 | , false //isModerator | 430 | , false //isModerator |
@@ -409,64 +436,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
409 | // Send a message from locally connected client to a group | 436 | // Send a message from locally connected client to a group |
410 | if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) | 437 | if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) |
411 | { | 438 | { |
412 | UUID groupID = new UUID(im.toAgentID); | 439 | UUID GroupID = new UUID(im.imSessionID); |
440 | UUID AgentID = new UUID(im.fromAgentID); | ||
441 | |||
442 | if (m_debugEnabled) | ||
443 | m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString()); | ||
413 | 444 | ||
414 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); | 445 | //If this agent is sending a message, then they want to be in the session |
446 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); | ||
415 | 447 | ||
416 | SendMessageToGroup(im, groupID); | 448 | SendMessageToGroup(im, GroupID); |
417 | } | 449 | } |
418 | } | 450 | } |
419 | 451 | ||
420 | #endregion | 452 | #endregion |
421 | 453 | ||
422 | private void SendMessageToGroup(GridInstantMessage im, UUID groupID) | ||
423 | { | ||
424 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
425 | |||
426 | foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID)) | ||
427 | { | ||
428 | if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid)) | ||
429 | { | ||
430 | // Don't deliver messages to people who have dropped this session | ||
431 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | ||
432 | continue; | ||
433 | } | ||
434 | |||
435 | // Copy Message | ||
436 | GridInstantMessage msg = new GridInstantMessage(); | ||
437 | msg.imSessionID = im.imSessionID; | ||
438 | msg.fromAgentName = im.fromAgentName; | ||
439 | msg.message = im.message; | ||
440 | msg.dialog = im.dialog; | ||
441 | msg.offline = im.offline; | ||
442 | msg.ParentEstateID = im.ParentEstateID; | ||
443 | msg.Position = im.Position; | ||
444 | msg.RegionID = im.RegionID; | ||
445 | msg.binaryBucket = im.binaryBucket; | ||
446 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
447 | |||
448 | // Updat Pertinate fields to make it a "group message" | ||
449 | msg.fromAgentID = groupID.Guid; | ||
450 | msg.fromGroup = true; | ||
451 | |||
452 | msg.toAgentID = member.AgentID.Guid; | ||
453 | |||
454 | IClientAPI client = GetActiveClient(member.AgentID); | ||
455 | if (client == null) | ||
456 | { | ||
457 | // If they're not local, forward across the grid | ||
458 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); | ||
459 | m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); | ||
460 | } | ||
461 | else | ||
462 | { | ||
463 | // Deliver locally, directly | ||
464 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); | ||
465 | ProcessMessageFromGroupSession(msg); | ||
466 | } | ||
467 | } | ||
468 | } | ||
469 | |||
470 | void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) | 454 | void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) |
471 | { | 455 | { |
472 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 456 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -518,6 +502,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
518 | /// </summary> | 502 | /// </summary> |
519 | private IClientAPI GetActiveClient(UUID agentID) | 503 | private IClientAPI GetActiveClient(UUID agentID) |
520 | { | 504 | { |
505 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); | ||
506 | |||
521 | IClientAPI child = null; | 507 | IClientAPI child = null; |
522 | 508 | ||
523 | // Try root avatar first | 509 | // Try root avatar first |
@@ -529,16 +515,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
529 | ScenePresence user = (ScenePresence)scene.Entities[agentID]; | 515 | ScenePresence user = (ScenePresence)scene.Entities[agentID]; |
530 | if (!user.IsChildAgent) | 516 | if (!user.IsChildAgent) |
531 | { | 517 | { |
518 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); | ||
532 | return user.ControllingClient; | 519 | return user.ControllingClient; |
533 | } | 520 | } |
534 | else | 521 | else |
535 | { | 522 | { |
523 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); | ||
536 | child = user.ControllingClient; | 524 | child = user.ControllingClient; |
537 | } | 525 | } |
538 | } | 526 | } |
539 | } | 527 | } |
540 | 528 | ||
541 | // If we didn't find a root, then just return whichever child we found, or null if none | 529 | // If we didn't find a root, then just return whichever child we found, or null if none |
530 | if (child == null) | ||
531 | { | ||
532 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); | ||
533 | } | ||
534 | else | ||
535 | { | ||
536 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); | ||
537 | } | ||
542 | return child; | 538 | return child; |
543 | } | 539 | } |
544 | 540 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 8d32e66..56c0d98 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -43,6 +43,8 @@ using OpenSim.Region.CoreModules.Framework.EventQueue; | |||
43 | using OpenSim.Region.Framework.Interfaces; | 43 | using OpenSim.Region.Framework.Interfaces; |
44 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
45 | 45 | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | |||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | 48 | using Caps = OpenSim.Framework.Capabilities.Caps; |
47 | using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; | 49 | using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; |
48 | 50 | ||
@@ -87,16 +89,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
87 | 89 | ||
88 | private IGroupsServicesConnector m_groupData = null; | 90 | private IGroupsServicesConnector m_groupData = null; |
89 | 91 | ||
90 | class GroupRequestIDInfo | ||
91 | { | ||
92 | public GroupRequestID RequestID = new GroupRequestID(); | ||
93 | public DateTime LastUsedTMStamp = DateTime.MinValue; | ||
94 | } | ||
95 | private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>(); | ||
96 | private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes | ||
97 | private Timer m_clientRequestIDFlushTimer; | ||
98 | |||
99 | |||
100 | // Configuration settings | 92 | // Configuration settings |
101 | private bool m_groupsEnabled = false; | 93 | private bool m_groupsEnabled = false; |
102 | private bool m_groupNoticesEnabled = true; | 94 | private bool m_groupNoticesEnabled = true; |
@@ -133,30 +125,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
133 | m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); | 125 | m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); |
134 | m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); | 126 | m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); |
135 | 127 | ||
136 | m_clientRequestIDFlushTimer = new Timer(); | ||
137 | m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut; | ||
138 | m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache; | ||
139 | m_clientRequestIDFlushTimer.AutoReset = true; | ||
140 | m_clientRequestIDFlushTimer.Start(); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e) | ||
145 | { | ||
146 | lock (m_clientRequestIDInfo) | ||
147 | { | ||
148 | TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000); | ||
149 | UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count]; | ||
150 | foreach (UUID key in CurrentKeys) | ||
151 | { | ||
152 | if (m_clientRequestIDInfo.ContainsKey(key)) | ||
153 | { | ||
154 | if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout) | ||
155 | { | ||
156 | m_clientRequestIDInfo.Remove(key); | ||
157 | } | ||
158 | } | ||
159 | } | ||
160 | } | 128 | } |
161 | } | 129 | } |
162 | 130 | ||
@@ -208,7 +176,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
208 | 176 | ||
209 | scene.EventManager.OnNewClient += OnNewClient; | 177 | scene.EventManager.OnNewClient += OnNewClient; |
210 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 178 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
211 | |||
212 | // The InstantMessageModule itself doesn't do this, | 179 | // The InstantMessageModule itself doesn't do this, |
213 | // so lets see if things explode if we don't do it | 180 | // so lets see if things explode if we don't do it |
214 | // scene.EventManager.OnClientClosed += OnClientClosed; | 181 | // scene.EventManager.OnClientClosed += OnClientClosed; |
@@ -234,8 +201,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
234 | return; | 201 | return; |
235 | 202 | ||
236 | if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); | 203 | if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); |
237 | |||
238 | m_clientRequestIDFlushTimer.Stop(); | ||
239 | } | 204 | } |
240 | 205 | ||
241 | public Type ReplaceableInterface | 206 | public Type ReplaceableInterface |
@@ -272,14 +237,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
272 | // Used for Notices and Group Invites/Accept/Reject | 237 | // Used for Notices and Group Invites/Accept/Reject |
273 | client.OnInstantMessage += OnInstantMessage; | 238 | client.OnInstantMessage += OnInstantMessage; |
274 | 239 | ||
275 | lock (m_clientRequestIDInfo) | 240 | // Send client thier groups information. |
276 | { | ||
277 | if (m_clientRequestIDInfo.ContainsKey(client.AgentId)) | ||
278 | { | ||
279 | // flush any old RequestID information | ||
280 | m_clientRequestIDInfo.Remove(client.AgentId); | ||
281 | } | ||
282 | } | ||
283 | SendAgentGroupDataUpdate(client, client.AgentId); | 241 | SendAgentGroupDataUpdate(client, client.AgentId); |
284 | } | 242 | } |
285 | 243 | ||
@@ -287,7 +245,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
287 | { | 245 | { |
288 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 246 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
289 | 247 | ||
290 | //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); | 248 | //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray(); |
291 | GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); | 249 | GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); |
292 | remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); | 250 | remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); |
293 | } | 251 | } |
@@ -326,15 +284,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
326 | } | 284 | } |
327 | */ | 285 | */ |
328 | 286 | ||
329 | |||
330 | void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) | 287 | void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) |
331 | { | 288 | { |
332 | if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) | 289 | if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) |
333 | { | 290 | { |
334 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); | 291 | if (m_debugEnabled) |
292 | m_log.DebugFormat( | ||
293 | "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", | ||
294 | System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); | ||
335 | 295 | ||
336 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | 296 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order |
337 | remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); | 297 | remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray()); |
338 | } | 298 | } |
339 | 299 | ||
340 | } | 300 | } |
@@ -348,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
348 | string activeGroupName = string.Empty; | 308 | string activeGroupName = string.Empty; |
349 | ulong activeGroupPowers = (ulong)GroupPowers.None; | 309 | ulong activeGroupPowers = (ulong)GroupPowers.None; |
350 | 310 | ||
351 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); | 311 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID); |
352 | if (membership != null) | 312 | if (membership != null) |
353 | { | 313 | { |
354 | activeGroupID = membership.GroupID; | 314 | activeGroupID = membership.GroupID; |
@@ -361,13 +321,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
361 | SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); | 321 | SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); |
362 | } | 322 | } |
363 | 323 | ||
364 | private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient) | 324 | private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) |
365 | { | 325 | { |
366 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 326 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
367 | 327 | ||
368 | string GroupName; | 328 | string GroupName; |
369 | 329 | ||
370 | GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); | 330 | GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null); |
371 | if (group != null) | 331 | if (group != null) |
372 | { | 332 | { |
373 | GroupName = group.GroupName; | 333 | GroupName = group.GroupName; |
@@ -388,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
388 | if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) | 348 | if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) |
389 | { | 349 | { |
390 | UUID inviteID = new UUID(im.imSessionID); | 350 | UUID inviteID = new UUID(im.imSessionID); |
391 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); | 351 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); |
392 | 352 | ||
393 | if (inviteInfo == null) | 353 | if (inviteInfo == null) |
394 | { | 354 | { |
@@ -407,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
407 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); | 367 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); |
408 | 368 | ||
409 | // and the sessionid is the role | 369 | // and the sessionid is the role |
410 | m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); | 370 | m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); |
411 | 371 | ||
412 | GridInstantMessage msg = new GridInstantMessage(); | 372 | GridInstantMessage msg = new GridInstantMessage(); |
413 | msg.imSessionID = UUID.Zero.Guid; | 373 | msg.imSessionID = UUID.Zero.Guid; |
@@ -431,14 +391,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
431 | // TODO: If the inviter is still online, they need an agent dataupdate | 391 | // TODO: If the inviter is still online, they need an agent dataupdate |
432 | // and maybe group membership updates for the invitee | 392 | // and maybe group membership updates for the invitee |
433 | 393 | ||
434 | m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); | 394 | m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); |
435 | } | 395 | } |
436 | 396 | ||
437 | // Reject | 397 | // Reject |
438 | if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) | 398 | if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) |
439 | { | 399 | { |
440 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); | 400 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); |
441 | m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); | 401 | m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); |
442 | } | 402 | } |
443 | } | 403 | } |
444 | } | 404 | } |
@@ -452,7 +412,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
452 | } | 412 | } |
453 | 413 | ||
454 | UUID GroupID = new UUID(im.toAgentID); | 414 | UUID GroupID = new UUID(im.toAgentID); |
455 | if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) | 415 | if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null) |
456 | { | 416 | { |
457 | UUID NoticeID = UUID.Random(); | 417 | UUID NoticeID = UUID.Random(); |
458 | string Subject = im.message.Substring(0, im.message.IndexOf('|')); | 418 | string Subject = im.message.Substring(0, im.message.IndexOf('|')); |
@@ -496,21 +456,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
496 | } | 456 | } |
497 | 457 | ||
498 | 458 | ||
499 | m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); | 459 | m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); |
500 | if (OnNewGroupNotice != null) | 460 | if (OnNewGroupNotice != null) |
501 | { | 461 | { |
502 | OnNewGroupNotice(GroupID, NoticeID); | 462 | OnNewGroupNotice(GroupID, NoticeID); |
503 | } | 463 | } |
504 | 464 | ||
505 | // Send notice out to everyone that wants notices | 465 | // Send notice out to everyone that wants notices |
506 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) | 466 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID)) |
507 | { | 467 | { |
508 | if (m_debugEnabled) | 468 | if (m_debugEnabled) |
509 | { | 469 | { |
510 | UserProfileData targetUserProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(member.AgentID); | 470 | UserAccount targetUser = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, member.AgentID); |
511 | if (targetUserProfile != null) | 471 | if (targetUser != null) |
512 | { | 472 | { |
513 | m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUserProfile.Name, member.AcceptNotices); | 473 | m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices); |
514 | } | 474 | } |
515 | else | 475 | else |
516 | { | 476 | { |
@@ -549,7 +509,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
549 | IClientAPI ejectee = GetActiveClient(ejecteeID); | 509 | IClientAPI ejectee = GetActiveClient(ejecteeID); |
550 | if (ejectee != null) | 510 | if (ejectee != null) |
551 | { | 511 | { |
552 | UUID groupID = new UUID(im.fromAgentID); | 512 | UUID groupID = new UUID(im.imSessionID); |
553 | ejectee.SendAgentDropGroup(groupID); | 513 | ejectee.SendAgentDropGroup(groupID); |
554 | } | 514 | } |
555 | } | 515 | } |
@@ -588,20 +548,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
588 | 548 | ||
589 | public GroupRecord GetGroupRecord(UUID GroupID) | 549 | public GroupRecord GetGroupRecord(UUID GroupID) |
590 | { | 550 | { |
591 | return m_groupData.GetGroupRecord(null, GroupID, null); | 551 | return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); |
592 | } | 552 | } |
593 | 553 | ||
554 | public GroupRecord GetGroupRecord(string name) | ||
555 | { | ||
556 | return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name); | ||
557 | } | ||
558 | |||
594 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) | 559 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) |
595 | { | 560 | { |
596 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 561 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
597 | 562 | ||
598 | m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); | 563 | m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
599 | 564 | ||
600 | // Changing active group changes title, active powers, all kinds of things | 565 | // Changing active group changes title, active powers, all kinds of things |
601 | // anyone who is in any region that can see this client, should probably be | 566 | // anyone who is in any region that can see this client, should probably be |
602 | // updated with new group info. At a minimum, they should get ScenePresence | 567 | // updated with new group info. At a minimum, they should get ScenePresence |
603 | // updated with new title. | 568 | // updated with new title. |
604 | UpdateAllClientsWithGroupInfo(remoteClient.AgentId); | 569 | UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); |
605 | } | 570 | } |
606 | 571 | ||
607 | /// <summary> | 572 | /// <summary> |
@@ -611,10 +576,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
611 | { | 576 | { |
612 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 577 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
613 | 578 | ||
614 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
615 | 579 | ||
616 | List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); | 580 | List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
617 | GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); | 581 | GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
618 | 582 | ||
619 | List<GroupTitlesData> titles = new List<GroupTitlesData>(); | 583 | List<GroupTitlesData> titles = new List<GroupTitlesData>(); |
620 | foreach (GroupRolesData role in agentRoles) | 584 | foreach (GroupRolesData role in agentRoles) |
@@ -636,8 +600,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
636 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) | 600 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) |
637 | { | 601 | { |
638 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 602 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
603 | List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID); | ||
639 | 604 | ||
640 | List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); | 605 | if (m_debugEnabled) |
606 | { | ||
607 | foreach (GroupMembersData member in data) | ||
608 | { | ||
609 | m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner); | ||
610 | } | ||
611 | } | ||
641 | 612 | ||
642 | return data; | 613 | return data; |
643 | 614 | ||
@@ -647,21 +618,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
647 | { | 618 | { |
648 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 619 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
649 | 620 | ||
650 | List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); | 621 | List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID); |
651 | 622 | ||
652 | return data; | 623 | return data; |
653 | |||
654 | } | 624 | } |
655 | 625 | ||
656 | public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) | 626 | public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) |
657 | { | 627 | { |
658 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 628 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
659 | 629 | ||
660 | List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); | 630 | List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID); |
661 | 631 | ||
632 | if (m_debugEnabled) | ||
633 | { | ||
634 | foreach (GroupRoleMembersData member in data) | ||
635 | { | ||
636 | m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID); | ||
637 | } | ||
638 | } | ||
662 | return data; | 639 | return data; |
663 | |||
664 | |||
665 | } | 640 | } |
666 | 641 | ||
667 | public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) | 642 | public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) |
@@ -670,17 +645,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
670 | 645 | ||
671 | GroupProfileData profile = new GroupProfileData(); | 646 | GroupProfileData profile = new GroupProfileData(); |
672 | 647 | ||
673 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
674 | 648 | ||
675 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); | 649 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); |
676 | if (groupInfo != null) | 650 | if (groupInfo != null) |
677 | { | 651 | { |
678 | profile.AllowPublish = groupInfo.AllowPublish; | 652 | profile.AllowPublish = groupInfo.AllowPublish; |
679 | profile.Charter = groupInfo.Charter; | 653 | profile.Charter = groupInfo.Charter; |
680 | profile.FounderID = groupInfo.FounderID; | 654 | profile.FounderID = groupInfo.FounderID; |
681 | profile.GroupID = groupID; | 655 | profile.GroupID = groupID; |
682 | profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; | 656 | profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count; |
683 | profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; | 657 | profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count; |
684 | profile.InsigniaID = groupInfo.GroupPicture; | 658 | profile.InsigniaID = groupInfo.GroupPicture; |
685 | profile.MaturePublish = groupInfo.MaturePublish; | 659 | profile.MaturePublish = groupInfo.MaturePublish; |
686 | profile.MembershipFee = groupInfo.MembershipFee; | 660 | profile.MembershipFee = groupInfo.MembershipFee; |
@@ -691,7 +665,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
691 | profile.ShowInList = groupInfo.ShowInList; | 665 | profile.ShowInList = groupInfo.ShowInList; |
692 | } | 666 | } |
693 | 667 | ||
694 | GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); | 668 | GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
695 | if (memberInfo != null) | 669 | if (memberInfo != null) |
696 | { | 670 | { |
697 | profile.MemberTitle = memberInfo.GroupTitle; | 671 | profile.MemberTitle = memberInfo.GroupTitle; |
@@ -705,46 +679,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
705 | { | 679 | { |
706 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 680 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
707 | 681 | ||
708 | return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); | 682 | return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray(); |
709 | } | 683 | } |
710 | 684 | ||
711 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) | 685 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) |
712 | { | 686 | { |
713 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 687 | if (m_debugEnabled) |
688 | m_log.DebugFormat( | ||
689 | "[GROUPS]: {0} called with groupID={1}, agentID={2}", | ||
690 | System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); | ||
714 | 691 | ||
715 | return m_groupData.GetAgentGroupMembership(null, agentID, groupID); | 692 | return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID); |
716 | } | 693 | } |
717 | 694 | ||
718 | public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) | 695 | public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) |
719 | { | 696 | { |
720 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 697 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
721 | 698 | ||
722 | // TODO: Security Check? | 699 | // Note: Permissions checking for modification rights is handled by the Groups Server/Service |
723 | 700 | m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); | |
724 | m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); | ||
725 | } | 701 | } |
726 | 702 | ||
727 | public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) | 703 | public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) |
728 | { | 704 | { |
729 | // TODO: Security Check? | 705 | // Note: Permissions checking for modification rights is handled by the Groups Server/Service |
730 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 706 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
731 | 707 | ||
732 | m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); | 708 | m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile); |
733 | } | 709 | } |
734 | 710 | ||
735 | public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) | 711 | public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) |
736 | { | 712 | { |
737 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 713 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
738 | 714 | ||
739 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | 715 | if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null) |
740 | |||
741 | if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null) | ||
742 | { | 716 | { |
743 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); | 717 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); |
744 | return UUID.Zero; | 718 | return UUID.Zero; |
745 | } | 719 | } |
746 | // is there is a money module present ? | 720 | // is there is a money module present ? |
747 | IMoneyModule money=remoteClient.Scene.RequestModuleInterface<IMoneyModule>(); | 721 | IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>(); |
748 | if (money != null) | 722 | if (money != null) |
749 | { | 723 | { |
750 | // do the transaction, that is if the agent has got sufficient funds | 724 | // do the transaction, that is if the agent has got sufficient funds |
@@ -752,14 +726,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
752 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); | 726 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); |
753 | return UUID.Zero; | 727 | return UUID.Zero; |
754 | } | 728 | } |
755 | money.ApplyGroupCreationCharge(remoteClient.AgentId); | 729 | money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient)); |
756 | } | 730 | } |
757 | UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); | 731 | UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient)); |
758 | 732 | ||
759 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); | 733 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); |
760 | 734 | ||
761 | // Update the founder with new group information. | 735 | // Update the founder with new group information. |
762 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 736 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
763 | 737 | ||
764 | return groupID; | 738 | return groupID; |
765 | } | 739 | } |
@@ -770,7 +744,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
770 | 744 | ||
771 | // ToDo: check if agent is a member of group and is allowed to see notices? | 745 | // ToDo: check if agent is a member of group and is allowed to see notices? |
772 | 746 | ||
773 | return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); | 747 | return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray(); |
774 | } | 748 | } |
775 | 749 | ||
776 | /// <summary> | 750 | /// <summary> |
@@ -780,7 +754,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
780 | { | 754 | { |
781 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 755 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
782 | 756 | ||
783 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); | 757 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID); |
784 | if (membership != null) | 758 | if (membership != null) |
785 | { | 759 | { |
786 | return membership.GroupTitle; | 760 | return membership.GroupTitle; |
@@ -795,13 +769,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
795 | { | 769 | { |
796 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 770 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
797 | 771 | ||
798 | m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); | 772 | m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID); |
799 | 773 | ||
800 | // TODO: Not sure what all is needed here, but if the active group role change is for the group | 774 | // TODO: Not sure what all is needed here, but if the active group role change is for the group |
801 | // the client currently has set active, then we need to do a scene presence update too | 775 | // the client currently has set active, then we need to do a scene presence update too |
802 | // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID) | 776 | // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) |
803 | 777 | ||
804 | UpdateAllClientsWithGroupInfo(remoteClient.AgentId); | 778 | UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); |
805 | } | 779 | } |
806 | 780 | ||
807 | 781 | ||
@@ -811,16 +785,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
811 | 785 | ||
812 | // Security Checks are handled in the Groups Service. | 786 | // Security Checks are handled in the Groups Service. |
813 | 787 | ||
814 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
815 | |||
816 | switch ((OpenMetaverse.GroupRoleUpdate)updateType) | 788 | switch ((OpenMetaverse.GroupRoleUpdate)updateType) |
817 | { | 789 | { |
818 | case OpenMetaverse.GroupRoleUpdate.Create: | 790 | case OpenMetaverse.GroupRoleUpdate.Create: |
819 | m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); | 791 | m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers); |
820 | break; | 792 | break; |
821 | 793 | ||
822 | case OpenMetaverse.GroupRoleUpdate.Delete: | 794 | case OpenMetaverse.GroupRoleUpdate.Delete: |
823 | m_groupData.RemoveGroupRole(grID, groupID, roleID); | 795 | m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID); |
824 | break; | 796 | break; |
825 | 797 | ||
826 | case OpenMetaverse.GroupRoleUpdate.UpdateAll: | 798 | case OpenMetaverse.GroupRoleUpdate.UpdateAll: |
@@ -831,7 +803,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
831 | GroupPowers gp = (GroupPowers)powers; | 803 | GroupPowers gp = (GroupPowers)powers; |
832 | m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); | 804 | m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); |
833 | } | 805 | } |
834 | m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); | 806 | m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers); |
835 | break; | 807 | break; |
836 | 808 | ||
837 | case OpenMetaverse.GroupRoleUpdate.NoUpdate: | 809 | case OpenMetaverse.GroupRoleUpdate.NoUpdate: |
@@ -842,7 +814,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
842 | } | 814 | } |
843 | 815 | ||
844 | // TODO: This update really should send out updates for everyone in the role that just got changed. | 816 | // TODO: This update really should send out updates for everyone in the role that just got changed. |
845 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 817 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
846 | } | 818 | } |
847 | 819 | ||
848 | public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) | 820 | public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) |
@@ -850,18 +822,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
850 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 822 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
851 | // Todo: Security check | 823 | // Todo: Security check |
852 | 824 | ||
853 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
854 | |||
855 | switch (changes) | 825 | switch (changes) |
856 | { | 826 | { |
857 | case 0: | 827 | case 0: |
858 | // Add | 828 | // Add |
859 | m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); | 829 | m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); |
860 | 830 | ||
861 | break; | 831 | break; |
862 | case 1: | 832 | case 1: |
863 | // Remove | 833 | // Remove |
864 | m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); | 834 | m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); |
865 | 835 | ||
866 | break; | 836 | break; |
867 | default: | 837 | default: |
@@ -870,25 +840,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
870 | } | 840 | } |
871 | 841 | ||
872 | // TODO: This update really should send out updates for everyone in the role that just got changed. | 842 | // TODO: This update really should send out updates for everyone in the role that just got changed. |
873 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 843 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
874 | } | 844 | } |
875 | 845 | ||
876 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) | 846 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) |
877 | { | 847 | { |
878 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 848 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
879 | 849 | ||
880 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | 850 | GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID); |
881 | |||
882 | GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID); | ||
883 | 851 | ||
884 | if (data != null) | 852 | if (data != null) |
885 | { | 853 | { |
886 | GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); | 854 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); |
887 | 855 | ||
888 | GridInstantMessage msg = new GridInstantMessage(); | 856 | GridInstantMessage msg = new GridInstantMessage(); |
889 | msg.imSessionID = UUID.Zero.Guid; | 857 | msg.imSessionID = UUID.Zero.Guid; |
890 | msg.fromAgentID = data.GroupID.Guid; | 858 | msg.fromAgentID = data.GroupID.Guid; |
891 | msg.toAgentID = remoteClient.AgentId.Guid; | 859 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; |
892 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 860 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
893 | msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; | 861 | msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; |
894 | msg.message = data.noticeData.Subject + "|" + data.Message; | 862 | msg.message = data.noticeData.Subject + "|" + data.Message; |
@@ -900,7 +868,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
900 | msg.RegionID = UUID.Zero.Guid; | 868 | msg.RegionID = UUID.Zero.Guid; |
901 | msg.binaryBucket = data.BinaryBucket; | 869 | msg.binaryBucket = data.BinaryBucket; |
902 | 870 | ||
903 | OutgoingInstantMessage(msg, remoteClient.AgentId); | 871 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
904 | } | 872 | } |
905 | 873 | ||
906 | } | 874 | } |
@@ -920,7 +888,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
920 | msg.Position = Vector3.Zero; | 888 | msg.Position = Vector3.Zero; |
921 | msg.RegionID = UUID.Zero.Guid; | 889 | msg.RegionID = UUID.Zero.Guid; |
922 | 890 | ||
923 | GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); | 891 | GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID); |
924 | if (info != null) | 892 | if (info != null) |
925 | { | 893 | { |
926 | msg.fromAgentID = info.GroupID.Guid; | 894 | msg.fromAgentID = info.GroupID.Guid; |
@@ -947,7 +915,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
947 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 915 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
948 | 916 | ||
949 | // Send agent information about his groups | 917 | // Send agent information about his groups |
950 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 918 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
951 | } | 919 | } |
952 | 920 | ||
953 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) | 921 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) |
@@ -955,19 +923,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
955 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 923 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
956 | 924 | ||
957 | // Should check to see if OpenEnrollment, or if there's an outstanding invitation | 925 | // Should check to see if OpenEnrollment, or if there's an outstanding invitation |
958 | m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); | 926 | m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero); |
959 | 927 | ||
960 | remoteClient.SendJoinGroupReply(groupID, true); | 928 | remoteClient.SendJoinGroupReply(groupID, true); |
961 | 929 | ||
962 | // Should this send updates to everyone in the group? | 930 | // Should this send updates to everyone in the group? |
963 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 931 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
964 | } | 932 | } |
965 | 933 | ||
966 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) | 934 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) |
967 | { | 935 | { |
968 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 936 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
969 | 937 | ||
970 | m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); | 938 | m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
971 | 939 | ||
972 | remoteClient.SendLeaveGroupReply(groupID, true); | 940 | remoteClient.SendLeaveGroupReply(groupID, true); |
973 | 941 | ||
@@ -975,34 +943,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
975 | 943 | ||
976 | // SL sends out notifcations to the group messaging session that the person has left | 944 | // SL sends out notifcations to the group messaging session that the person has left |
977 | // Should this also update everyone who is in the group? | 945 | // Should this also update everyone who is in the group? |
978 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 946 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
979 | } | 947 | } |
980 | 948 | ||
981 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) | 949 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) |
982 | { | 950 | { |
983 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 951 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
984 | 952 | ||
985 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
986 | 953 | ||
987 | // Todo: Security check? | 954 | // Todo: Security check? |
988 | m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); | 955 | m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID); |
989 | 956 | ||
990 | remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); | 957 | remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true); |
991 | 958 | ||
992 | GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); | 959 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); |
993 | UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); | ||
994 | 960 | ||
995 | if ((groupInfo == null) || (userProfile == null)) | 961 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); |
962 | if ((groupInfo == null) || (account == null)) | ||
996 | { | 963 | { |
997 | return; | 964 | return; |
998 | } | 965 | } |
999 | |||
1000 | 966 | ||
1001 | // Send Message to Ejectee | 967 | // Send Message to Ejectee |
1002 | GridInstantMessage msg = new GridInstantMessage(); | 968 | GridInstantMessage msg = new GridInstantMessage(); |
1003 | 969 | ||
1004 | msg.imSessionID = UUID.Zero.Guid; | 970 | msg.imSessionID = UUID.Zero.Guid; |
1005 | msg.fromAgentID = remoteClient.AgentId.Guid; | 971 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1006 | // msg.fromAgentID = info.GroupID; | 972 | // msg.fromAgentID = info.GroupID; |
1007 | msg.toAgentID = ejecteeID.Guid; | 973 | msg.toAgentID = ejecteeID.Guid; |
1008 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 974 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
@@ -1028,13 +994,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1028 | 994 | ||
1029 | msg = new GridInstantMessage(); | 995 | msg = new GridInstantMessage(); |
1030 | msg.imSessionID = UUID.Zero.Guid; | 996 | msg.imSessionID = UUID.Zero.Guid; |
1031 | msg.fromAgentID = remoteClient.AgentId.Guid; | 997 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1032 | msg.toAgentID = remoteClient.AgentId.Guid; | 998 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; |
1033 | msg.timestamp = 0; | 999 | msg.timestamp = 0; |
1034 | msg.fromAgentName = remoteClient.Name; | 1000 | msg.fromAgentName = remoteClient.Name; |
1035 | if (userProfile != null) | 1001 | if (account != null) |
1036 | { | 1002 | { |
1037 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, userProfile.Name); | 1003 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName); |
1038 | } | 1004 | } |
1039 | else | 1005 | else |
1040 | { | 1006 | { |
@@ -1047,7 +1013,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1047 | msg.Position = Vector3.Zero; | 1013 | msg.Position = Vector3.Zero; |
1048 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; | 1014 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; |
1049 | msg.binaryBucket = new byte[0]; | 1015 | msg.binaryBucket = new byte[0]; |
1050 | OutgoingInstantMessage(msg, remoteClient.AgentId); | 1016 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
1051 | 1017 | ||
1052 | 1018 | ||
1053 | // SL sends out messages to everyone in the group | 1019 | // SL sends out messages to everyone in the group |
@@ -1061,13 +1027,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1061 | 1027 | ||
1062 | // Todo: Security check, probably also want to send some kind of notification | 1028 | // Todo: Security check, probably also want to send some kind of notification |
1063 | UUID InviteID = UUID.Random(); | 1029 | UUID InviteID = UUID.Random(); |
1064 | GroupRequestID grid = GetClientGroupRequestID(remoteClient); | ||
1065 | 1030 | ||
1066 | m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); | 1031 | m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID); |
1067 | 1032 | ||
1068 | // Check to see if the invite went through, if it did not then it's possible | 1033 | // Check to see if the invite went through, if it did not then it's possible |
1069 | // the remoteClient did not validate or did not have permission to invite. | 1034 | // the remoteClient did not validate or did not have permission to invite. |
1070 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); | 1035 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID); |
1071 | 1036 | ||
1072 | if (inviteInfo != null) | 1037 | if (inviteInfo != null) |
1073 | { | 1038 | { |
@@ -1079,7 +1044,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1079 | 1044 | ||
1080 | msg.imSessionID = inviteUUID; | 1045 | msg.imSessionID = inviteUUID; |
1081 | 1046 | ||
1082 | // msg.fromAgentID = remoteClient.AgentId.Guid; | 1047 | // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1083 | msg.fromAgentID = groupID.Guid; | 1048 | msg.fromAgentID = groupID.Guid; |
1084 | msg.toAgentID = invitedAgentID.Guid; | 1049 | msg.toAgentID = invitedAgentID.Guid; |
1085 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 1050 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
@@ -1132,57 +1097,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1132 | return child; | 1097 | return child; |
1133 | } | 1098 | } |
1134 | 1099 | ||
1135 | private GroupRequestID GetClientGroupRequestID(IClientAPI client) | ||
1136 | { | ||
1137 | if (client == null) | ||
1138 | { | ||
1139 | return new GroupRequestID(); | ||
1140 | } | ||
1141 | |||
1142 | lock (m_clientRequestIDInfo) | ||
1143 | { | ||
1144 | if (!m_clientRequestIDInfo.ContainsKey(client.AgentId)) | ||
1145 | { | ||
1146 | GroupRequestIDInfo info = new GroupRequestIDInfo(); | ||
1147 | info.RequestID.AgentID = client.AgentId; | ||
1148 | info.RequestID.SessionID = client.SessionId; | ||
1149 | |||
1150 | UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId); | ||
1151 | if (userProfile == null) | ||
1152 | { | ||
1153 | // This should be impossible. If I've been passed a reference to a client | ||
1154 | // that client should be registered with the UserService. So something | ||
1155 | // is horribly wrong somewhere. | ||
1156 | |||
1157 | m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId); | ||
1158 | |||
1159 | // Default to local user service and hope for the best? | ||
1160 | info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; | ||
1161 | |||
1162 | } | ||
1163 | else if (userProfile is ForeignUserProfileData) | ||
1164 | { | ||
1165 | // They aren't from around here | ||
1166 | ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile; | ||
1167 | info.RequestID.UserServiceURL = fupd.UserServerURI; | ||
1168 | } | ||
1169 | else | ||
1170 | { | ||
1171 | // They're a local user, use this: | ||
1172 | info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; | ||
1173 | } | ||
1174 | |||
1175 | m_clientRequestIDInfo.Add(client.AgentId, info); | ||
1176 | } | ||
1177 | |||
1178 | m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now; | ||
1179 | |||
1180 | return m_clientRequestIDInfo[client.AgentId].RequestID; | ||
1181 | } | ||
1182 | // Unreachable code! | ||
1183 | // return new GroupRequestID(); | ||
1184 | } | ||
1185 | |||
1186 | /// <summary> | 1100 | /// <summary> |
1187 | /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. | 1101 | /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. |
1188 | /// </summary> | 1102 | /// </summary> |
@@ -1201,7 +1115,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1201 | 1115 | ||
1202 | foreach (GroupMembershipData membership in data) | 1116 | foreach (GroupMembershipData membership in data) |
1203 | { | 1117 | { |
1204 | if (remoteClient.AgentId != dataForAgentID) | 1118 | if (GetRequestingAgentID(remoteClient) != dataForAgentID) |
1205 | { | 1119 | { |
1206 | if (!membership.ListInProfile) | 1120 | if (!membership.ListInProfile) |
1207 | { | 1121 | { |
@@ -1231,11 +1145,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1231 | llDataStruct.Add("GroupData", GroupData); | 1145 | llDataStruct.Add("GroupData", GroupData); |
1232 | llDataStruct.Add("NewGroupData", NewGroupData); | 1146 | llDataStruct.Add("NewGroupData", NewGroupData); |
1233 | 1147 | ||
1148 | if (m_debugEnabled) | ||
1149 | { | ||
1150 | m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct)); | ||
1151 | } | ||
1152 | |||
1234 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); | 1153 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); |
1235 | 1154 | ||
1236 | if (queue != null) | 1155 | if (queue != null) |
1237 | { | 1156 | { |
1238 | queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId); | 1157 | queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); |
1239 | } | 1158 | } |
1240 | 1159 | ||
1241 | } | 1160 | } |
@@ -1308,7 +1227,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1308 | /// <returns></returns> | 1227 | /// <returns></returns> |
1309 | private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) | 1228 | private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) |
1310 | { | 1229 | { |
1311 | List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); | 1230 | List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID); |
1312 | GroupMembershipData[] membershipArray; | 1231 | GroupMembershipData[] membershipArray; |
1313 | 1232 | ||
1314 | if (requestingClient.AgentId != dataForAgentID) | 1233 | if (requestingClient.AgentId != dataForAgentID) |
@@ -1330,7 +1249,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1330 | m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); | 1249 | m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); |
1331 | foreach (GroupMembershipData membership in membershipArray) | 1250 | foreach (GroupMembershipData membership in membershipArray) |
1332 | { | 1251 | { |
1333 | m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); | 1252 | m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers); |
1334 | } | 1253 | } |
1335 | } | 1254 | } |
1336 | 1255 | ||
@@ -1342,12 +1261,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1342 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1261 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
1343 | 1262 | ||
1344 | // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff | 1263 | // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff |
1345 | UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(dataForAgentID); | 1264 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); |
1346 | string firstname, lastname; | 1265 | string firstname, lastname; |
1347 | if (userProfile != null) | 1266 | if (account != null) |
1348 | { | 1267 | { |
1349 | firstname = userProfile.FirstName; | 1268 | firstname = account.FirstName; |
1350 | lastname = userProfile.SurName; | 1269 | lastname = account.LastName; |
1351 | } | 1270 | } |
1352 | else | 1271 | else |
1353 | { | 1272 | { |
@@ -1389,6 +1308,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1389 | } | 1308 | } |
1390 | 1309 | ||
1391 | #endregion | 1310 | #endregion |
1311 | |||
1312 | private UUID GetRequestingAgentID(IClientAPI client) | ||
1313 | { | ||
1314 | UUID requestingAgentID = UUID.Zero; | ||
1315 | if (client != null) | ||
1316 | { | ||
1317 | requestingAgentID = client.AgentId; | ||
1318 | } | ||
1319 | return requestingAgentID; | ||
1320 | } | ||
1392 | } | 1321 | } |
1393 | 1322 | ||
1323 | public class GroupNoticeInfo | ||
1324 | { | ||
1325 | public GroupNoticeData noticeData = new GroupNoticeData(); | ||
1326 | public UUID GroupID = UUID.Zero; | ||
1327 | public string Message = string.Empty; | ||
1328 | public byte[] BinaryBucket = new byte[0]; | ||
1329 | } | ||
1394 | } | 1330 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs index 9e0fa2d..a046e09 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs | |||
@@ -36,42 +36,47 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
36 | { | 36 | { |
37 | interface IGroupsServicesConnector | 37 | interface IGroupsServicesConnector |
38 | { | 38 | { |
39 | UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); | 39 | UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); |
40 | void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); | 40 | void UpdateGroup(UUID RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); |
41 | GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName); | 41 | GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName); |
42 | List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search); | 42 | List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search); |
43 | List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID); | 43 | List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID); |
44 | 44 | ||
45 | void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); | 45 | void AddGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); |
46 | void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); | 46 | void UpdateGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); |
47 | void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID); | 47 | void RemoveGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID); |
48 | List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID); | 48 | List<GroupRolesData> GetGroupRoles(UUID RequestingAgentID, UUID GroupID); |
49 | List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID); | 49 | List<GroupRoleMembersData> GetGroupRoleMembers(UUID RequestingAgentID, UUID GroupID); |
50 | 50 | ||
51 | void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 51 | void AddAgentToGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); |
52 | void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); | 52 | void RemoveAgentFromGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID); |
53 | 53 | ||
54 | void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID); | 54 | void AddAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID); |
55 | GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); | 55 | GroupInviteInfo GetAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID); |
56 | void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); | 56 | void RemoveAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID); |
57 | 57 | ||
58 | void AddAgentToGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); | ||
59 | void RemoveAgentFromGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); | ||
60 | List<GroupRolesData> GetAgentGroupRoles(UUID RequestingAgentID, UUID AgentID, UUID GroupID); | ||
58 | 61 | ||
59 | void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 62 | void SetAgentActiveGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID); |
60 | void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 63 | GroupMembershipData GetAgentActiveMembership(UUID RequestingAgentID, UUID AgentID); |
61 | List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID); | ||
62 | 64 | ||
63 | void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); | 65 | void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); |
64 | GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID); | 66 | void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); |
65 | 67 | ||
66 | void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 68 | GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID); |
67 | void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); | 69 | List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID); |
68 | 70 | ||
69 | GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID); | 71 | void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); |
70 | List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID); | 72 | GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID); |
73 | List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID); | ||
71 | 74 | ||
72 | void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); | 75 | void ResetAgentGroupChatSessions(UUID agentID); |
73 | GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID); | 76 | bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID); |
74 | List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID); | 77 | bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID); |
78 | void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID); | ||
79 | void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID); | ||
75 | } | 80 | } |
76 | 81 | ||
77 | public class GroupInviteInfo | 82 | public class GroupInviteInfo |
@@ -81,11 +86,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
81 | public UUID AgentID = UUID.Zero; | 86 | public UUID AgentID = UUID.Zero; |
82 | public UUID InviteID = UUID.Zero; | 87 | public UUID InviteID = UUID.Zero; |
83 | } | 88 | } |
84 | |||
85 | public class GroupRequestID | ||
86 | { | ||
87 | public UUID AgentID = UUID.Zero; | ||
88 | public string UserServiceURL = string.Empty; | ||
89 | public UUID SessionID = UUID.Zero; | ||
90 | } | ||
91 | } | 89 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs new file mode 100644 index 0000000..9363205 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | |||
@@ -0,0 +1,1390 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Collections.Specialized; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using Nwc.XmlRpc; | ||
35 | |||
36 | using log4net; | ||
37 | using Mono.Addins; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.StructuredData; | ||
42 | |||
43 | using OpenSim.Framework; | ||
44 | using OpenSim.Framework.Communications; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | |||
48 | /*************************************************************************** | ||
49 | * Simian Data Map | ||
50 | * =============== | ||
51 | * | ||
52 | * OwnerID -> Type -> Key | ||
53 | * ----------------------- | ||
54 | * | ||
55 | * UserID -> Group -> ActiveGroup | ||
56 | * + GroupID | ||
57 | * | ||
58 | * UserID -> GroupSessionDropped -> GroupID | ||
59 | * UserID -> GroupSessionInvited -> GroupID | ||
60 | * | ||
61 | * UserID -> GroupMember -> GroupID | ||
62 | * + SelectedRoleID [UUID] | ||
63 | * + AcceptNotices [bool] | ||
64 | * + ListInProfile [bool] | ||
65 | * + Contribution [int] | ||
66 | * | ||
67 | * UserID -> GroupRole[GroupID] -> RoleID | ||
68 | * | ||
69 | * | ||
70 | * GroupID -> Group -> GroupName | ||
71 | * + Charter | ||
72 | * + ShowInList | ||
73 | * + InsigniaID | ||
74 | * + MembershipFee | ||
75 | * + OpenEnrollment | ||
76 | * + AllowPublish | ||
77 | * + MaturePublish | ||
78 | * + FounderID | ||
79 | * + EveryonePowers | ||
80 | * + OwnerRoleID | ||
81 | * + OwnersPowers | ||
82 | * | ||
83 | * GroupID -> GroupRole -> RoleID | ||
84 | * + Name | ||
85 | * + Description | ||
86 | * + Title | ||
87 | * + Powers | ||
88 | * | ||
89 | * GroupID -> GroupMemberInvite -> InviteID | ||
90 | * + AgentID | ||
91 | * + RoleID | ||
92 | * | ||
93 | * GroupID -> GroupNotice -> NoticeID | ||
94 | * + TimeStamp [uint] | ||
95 | * + FromName [string] | ||
96 | * + Subject [string] | ||
97 | * + Message [string] | ||
98 | * + BinaryBucket [byte[]] | ||
99 | * | ||
100 | * */ | ||
101 | |||
102 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | ||
103 | { | ||
104 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
105 | public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector | ||
106 | { | ||
107 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
108 | |||
109 | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | | ||
110 | GroupPowers.Accountable | | ||
111 | GroupPowers.JoinChat | | ||
112 | GroupPowers.AllowVoiceChat | | ||
113 | GroupPowers.ReceiveNotices | | ||
114 | GroupPowers.StartProposal | | ||
115 | GroupPowers.VoteOnProposal; | ||
116 | |||
117 | // Would this be cleaner as (GroupPowers)ulong.MaxValue; | ||
118 | public const GroupPowers m_DefaultOwnerPowers = GroupPowers.Accountable | ||
119 | | GroupPowers.AllowEditLand | ||
120 | | GroupPowers.AllowFly | ||
121 | | GroupPowers.AllowLandmark | ||
122 | | GroupPowers.AllowRez | ||
123 | | GroupPowers.AllowSetHome | ||
124 | | GroupPowers.AllowVoiceChat | ||
125 | | GroupPowers.AssignMember | ||
126 | | GroupPowers.AssignMemberLimited | ||
127 | | GroupPowers.ChangeActions | ||
128 | | GroupPowers.ChangeIdentity | ||
129 | | GroupPowers.ChangeMedia | ||
130 | | GroupPowers.ChangeOptions | ||
131 | | GroupPowers.CreateRole | ||
132 | | GroupPowers.DeedObject | ||
133 | | GroupPowers.DeleteRole | ||
134 | | GroupPowers.Eject | ||
135 | | GroupPowers.FindPlaces | ||
136 | | GroupPowers.Invite | ||
137 | | GroupPowers.JoinChat | ||
138 | | GroupPowers.LandChangeIdentity | ||
139 | | GroupPowers.LandDeed | ||
140 | | GroupPowers.LandDivideJoin | ||
141 | | GroupPowers.LandEdit | ||
142 | | GroupPowers.LandEjectAndFreeze | ||
143 | | GroupPowers.LandGardening | ||
144 | | GroupPowers.LandManageAllowed | ||
145 | | GroupPowers.LandManageBanned | ||
146 | | GroupPowers.LandManagePasses | ||
147 | | GroupPowers.LandOptions | ||
148 | | GroupPowers.LandRelease | ||
149 | | GroupPowers.LandSetSale | ||
150 | | GroupPowers.ModerateChat | ||
151 | | GroupPowers.ObjectManipulate | ||
152 | | GroupPowers.ObjectSetForSale | ||
153 | | GroupPowers.ReceiveNotices | ||
154 | | GroupPowers.RemoveMember | ||
155 | | GroupPowers.ReturnGroupOwned | ||
156 | | GroupPowers.ReturnGroupSet | ||
157 | | GroupPowers.ReturnNonGroup | ||
158 | | GroupPowers.RoleProperties | ||
159 | | GroupPowers.SendNotices | ||
160 | | GroupPowers.SetLandingPoint | ||
161 | | GroupPowers.StartProposal | ||
162 | | GroupPowers.VoteOnProposal; | ||
163 | |||
164 | private bool m_connectorEnabled = false; | ||
165 | |||
166 | private string m_groupsServerURI = string.Empty; | ||
167 | |||
168 | private bool m_debugEnabled = false; | ||
169 | |||
170 | private ExpiringCache<string, OSDMap> m_memoryCache; | ||
171 | private int m_cacheTimeout = 30; | ||
172 | |||
173 | // private IUserAccountService m_accountService = null; | ||
174 | |||
175 | |||
176 | #region IRegionModuleBase Members | ||
177 | |||
178 | public string Name | ||
179 | { | ||
180 | get { return "SimianGroupsServicesConnector"; } | ||
181 | } | ||
182 | |||
183 | // this module is not intended to be replaced, but there should only be 1 of them. | ||
184 | public Type ReplaceableInterface | ||
185 | { | ||
186 | get { return null; } | ||
187 | } | ||
188 | |||
189 | public void Initialise(IConfigSource config) | ||
190 | { | ||
191 | IConfig groupsConfig = config.Configs["Groups"]; | ||
192 | |||
193 | if (groupsConfig == null) | ||
194 | { | ||
195 | // Do not run this module by default. | ||
196 | return; | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | // if groups aren't enabled, we're not needed. | ||
201 | // if we're not specified as the connector to use, then we're not wanted | ||
202 | if ((groupsConfig.GetBoolean("Enabled", false) == false) | ||
203 | || (groupsConfig.GetString("ServicesConnectorModule", "Default") != Name)) | ||
204 | { | ||
205 | m_connectorEnabled = false; | ||
206 | return; | ||
207 | } | ||
208 | |||
209 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name); | ||
210 | |||
211 | m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); | ||
212 | if ((m_groupsServerURI == null) || | ||
213 | (m_groupsServerURI == string.Empty)) | ||
214 | { | ||
215 | m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); | ||
216 | m_connectorEnabled = false; | ||
217 | return; | ||
218 | } | ||
219 | |||
220 | |||
221 | m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30); | ||
222 | if (m_cacheTimeout == 0) | ||
223 | { | ||
224 | m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled."); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout); | ||
229 | } | ||
230 | |||
231 | |||
232 | |||
233 | m_memoryCache = new ExpiringCache<string,OSDMap>(); | ||
234 | |||
235 | |||
236 | // If we got all the config options we need, lets start'er'up | ||
237 | m_connectorEnabled = true; | ||
238 | |||
239 | m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); | ||
240 | |||
241 | } | ||
242 | } | ||
243 | |||
244 | public void Close() | ||
245 | { | ||
246 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name); | ||
247 | } | ||
248 | |||
249 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) | ||
250 | { | ||
251 | if (m_connectorEnabled) | ||
252 | { | ||
253 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); | ||
254 | } | ||
255 | } | ||
256 | |||
257 | public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) | ||
258 | { | ||
259 | if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) | ||
260 | { | ||
261 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) | ||
266 | { | ||
267 | // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info | ||
268 | // scene.EventManager.OnNewClient += OnNewClient; | ||
269 | } | ||
270 | |||
271 | #endregion | ||
272 | |||
273 | #region ISharedRegionModule Members | ||
274 | |||
275 | public void PostInitialise() | ||
276 | { | ||
277 | // NoOp | ||
278 | } | ||
279 | |||
280 | #endregion | ||
281 | |||
282 | |||
283 | |||
284 | |||
285 | #region IGroupsServicesConnector Members | ||
286 | |||
287 | /// <summary> | ||
288 | /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. | ||
289 | /// </summary> | ||
290 | public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, | ||
291 | int membershipFee, bool openEnrollment, bool allowPublish, | ||
292 | bool maturePublish, UUID founderID) | ||
293 | { | ||
294 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
295 | |||
296 | UUID GroupID = UUID.Random(); | ||
297 | UUID OwnerRoleID = UUID.Random(); | ||
298 | |||
299 | OSDMap GroupInfoMap = new OSDMap(); | ||
300 | GroupInfoMap["Charter"] = OSD.FromString(charter); | ||
301 | GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList); | ||
302 | GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID); | ||
303 | GroupInfoMap["MembershipFee"] = OSD.FromInteger(0); | ||
304 | GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment); | ||
305 | GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish); | ||
306 | GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish); | ||
307 | GroupInfoMap["FounderID"] = OSD.FromUUID(founderID); | ||
308 | GroupInfoMap["EveryonePowers"] = OSD.FromULong((ulong)m_DefaultEveryonePowers); | ||
309 | GroupInfoMap["OwnerRoleID"] = OSD.FromUUID(OwnerRoleID); | ||
310 | GroupInfoMap["OwnersPowers"] = OSD.FromULong((ulong)m_DefaultOwnerPowers); | ||
311 | |||
312 | if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap)) | ||
313 | { | ||
314 | AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers); | ||
315 | AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers); | ||
316 | |||
317 | AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID); | ||
318 | |||
319 | return GroupID; | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | return UUID.Zero; | ||
324 | } | ||
325 | } | ||
326 | |||
327 | |||
328 | public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, | ||
329 | UUID insigniaID, int membershipFee, bool openEnrollment, | ||
330 | bool allowPublish, bool maturePublish) | ||
331 | { | ||
332 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
333 | // TODO: Check to make sure requestingAgentID has permission to update group | ||
334 | |||
335 | string GroupName; | ||
336 | OSDMap GroupInfoMap; | ||
337 | if( SimianGetFirstGenericEntry(groupID, "GroupInfo", out GroupName, out GroupInfoMap) ) | ||
338 | { | ||
339 | GroupInfoMap["Charter"] = OSD.FromString(charter); | ||
340 | GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList); | ||
341 | GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID); | ||
342 | GroupInfoMap["MembershipFee"] = OSD.FromInteger(0); | ||
343 | GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment); | ||
344 | GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish); | ||
345 | GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish); | ||
346 | |||
347 | SimianAddGeneric(groupID, "Group", GroupName, GroupInfoMap); | ||
348 | } | ||
349 | |||
350 | } | ||
351 | |||
352 | |||
353 | public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, | ||
354 | string title, ulong powers) | ||
355 | { | ||
356 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
357 | |||
358 | OSDMap GroupRoleInfo = new OSDMap(); | ||
359 | GroupRoleInfo["Name"] = OSD.FromString(name); | ||
360 | GroupRoleInfo["Description"] = OSD.FromString(description); | ||
361 | GroupRoleInfo["Title"] = OSD.FromString(title); | ||
362 | GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers); | ||
363 | |||
364 | // TODO: Add security, make sure that requestingAgentID has permision to add roles | ||
365 | SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo); | ||
366 | } | ||
367 | |||
368 | public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID) | ||
369 | { | ||
370 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
371 | |||
372 | // TODO: Add security | ||
373 | |||
374 | // Can't delete the Everyone Role | ||
375 | if (roleID != UUID.Zero) | ||
376 | { | ||
377 | // Remove all GroupRole Members from Role | ||
378 | Dictionary<UUID, OSDMap> GroupRoleMembers; | ||
379 | string GroupRoleMemberType = "GroupRole" + groupID.ToString(); | ||
380 | if (SimianGetGenericEntries(GroupRoleMemberType, roleID.ToString(), out GroupRoleMembers)) | ||
381 | { | ||
382 | foreach(UUID UserID in GroupRoleMembers.Keys) | ||
383 | { | ||
384 | EnsureRoleNotSelectedByMember(groupID, roleID, UserID); | ||
385 | |||
386 | SimianRemoveGenericEntry(UserID, GroupRoleMemberType, roleID.ToString()); | ||
387 | } | ||
388 | } | ||
389 | |||
390 | // Remove role | ||
391 | SimianRemoveGenericEntry(groupID, "GroupRole", roleID.ToString()); | ||
392 | } | ||
393 | } | ||
394 | |||
395 | |||
396 | public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, | ||
397 | string title, ulong powers) | ||
398 | { | ||
399 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
400 | |||
401 | // TODO: Security, check that requestingAgentID is allowed to update group roles | ||
402 | |||
403 | OSDMap GroupRoleInfo; | ||
404 | if (SimianGetGenericEntry(groupID, "GroupRole", roleID.ToString(), out GroupRoleInfo)) | ||
405 | { | ||
406 | if (name != null) | ||
407 | { | ||
408 | GroupRoleInfo["Name"] = OSD.FromString(name); | ||
409 | } | ||
410 | if (description != null) | ||
411 | { | ||
412 | GroupRoleInfo["Description"] = OSD.FromString(description); | ||
413 | } | ||
414 | if (title != null) | ||
415 | { | ||
416 | GroupRoleInfo["Title"] = OSD.FromString(title); | ||
417 | } | ||
418 | GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers); | ||
419 | |||
420 | } | ||
421 | |||
422 | |||
423 | SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo); | ||
424 | } | ||
425 | |||
426 | public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) | ||
427 | { | ||
428 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
429 | |||
430 | OSDMap GroupInfoMap = null; | ||
431 | if (groupID != UUID.Zero) | ||
432 | { | ||
433 | if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out GroupInfoMap)) | ||
434 | { | ||
435 | return null; | ||
436 | } | ||
437 | } | ||
438 | else if ((groupName != null) && (groupName != string.Empty)) | ||
439 | { | ||
440 | if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) | ||
441 | { | ||
442 | return null; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | GroupRecord GroupInfo = new GroupRecord(); | ||
447 | |||
448 | GroupInfo.GroupID = groupID; | ||
449 | GroupInfo.GroupName = groupName; | ||
450 | GroupInfo.Charter = GroupInfoMap["Charter"].AsString(); | ||
451 | GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean(); | ||
452 | GroupInfo.GroupPicture = GroupInfoMap["InsigniaID"].AsUUID(); | ||
453 | GroupInfo.MembershipFee = GroupInfoMap["MembershipFee"].AsInteger(); | ||
454 | GroupInfo.OpenEnrollment = GroupInfoMap["OpenEnrollment"].AsBoolean(); | ||
455 | GroupInfo.AllowPublish = GroupInfoMap["AllowPublish"].AsBoolean(); | ||
456 | GroupInfo.MaturePublish = GroupInfoMap["MaturePublish"].AsBoolean(); | ||
457 | GroupInfo.FounderID = GroupInfoMap["FounderID"].AsUUID(); | ||
458 | GroupInfo.OwnerRoleID = GroupInfoMap["OwnerRoleID"].AsUUID(); | ||
459 | |||
460 | return GroupInfo; | ||
461 | |||
462 | } | ||
463 | |||
464 | public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID groupID, UUID memberID) | ||
465 | { | ||
466 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
467 | |||
468 | OSDMap groupProfile; | ||
469 | string groupName; | ||
470 | if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out groupProfile)) | ||
471 | { | ||
472 | // GroupProfileData is not nullable | ||
473 | return new GroupProfileData(); | ||
474 | } | ||
475 | |||
476 | GroupProfileData MemberGroupProfile = new GroupProfileData(); | ||
477 | MemberGroupProfile.GroupID = groupID; | ||
478 | MemberGroupProfile.Name = groupName; | ||
479 | |||
480 | if (groupProfile["Charter"] != null) | ||
481 | { | ||
482 | MemberGroupProfile.Charter = groupProfile["Charter"].AsString(); | ||
483 | } | ||
484 | |||
485 | MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1"; | ||
486 | MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID(); | ||
487 | MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger(); | ||
488 | MemberGroupProfile.OpenEnrollment = groupProfile["OpenEnrollment"].AsBoolean(); | ||
489 | MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean(); | ||
490 | MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean(); | ||
491 | MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();; | ||
492 | MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID(); | ||
493 | |||
494 | Dictionary<UUID, OSDMap> Members; | ||
495 | if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members)) | ||
496 | { | ||
497 | MemberGroupProfile.GroupMembershipCount = Members.Count; | ||
498 | } | ||
499 | |||
500 | Dictionary<string, OSDMap> Roles; | ||
501 | if (SimianGetGenericEntries(groupID, "GroupRole", out Roles)) | ||
502 | { | ||
503 | MemberGroupProfile.GroupRolesCount = Roles.Count; | ||
504 | } | ||
505 | |||
506 | // TODO: Get Group Money balance from somewhere | ||
507 | // group.Money = 0; | ||
508 | |||
509 | GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, memberID, groupID); | ||
510 | |||
511 | MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; | ||
512 | MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; | ||
513 | |||
514 | return MemberGroupProfile; | ||
515 | } | ||
516 | |||
517 | public void SetAgentActiveGroup(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
518 | { | ||
519 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
520 | |||
521 | OSDMap ActiveGroup = new OSDMap(); | ||
522 | ActiveGroup.Add("GroupID", OSD.FromUUID(groupID)); | ||
523 | SimianAddGeneric(agentID, "Group", "ActiveGroup", ActiveGroup); | ||
524 | } | ||
525 | |||
526 | public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) | ||
527 | { | ||
528 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
529 | |||
530 | OSDMap GroupMemberInfo; | ||
531 | if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo)) | ||
532 | { | ||
533 | GroupMemberInfo = new OSDMap(); | ||
534 | } | ||
535 | |||
536 | GroupMemberInfo["SelectedRoleID"] = OSD.FromUUID(roleID); | ||
537 | SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo); | ||
538 | } | ||
539 | |||
540 | public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile) | ||
541 | { | ||
542 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
543 | |||
544 | OSDMap GroupMemberInfo; | ||
545 | if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo)) | ||
546 | { | ||
547 | GroupMemberInfo = new OSDMap(); | ||
548 | } | ||
549 | |||
550 | GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices); | ||
551 | GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile); | ||
552 | GroupMemberInfo["Contribution"] = OSD.FromInteger(0); | ||
553 | GroupMemberInfo["SelectedRole"] = OSD.FromUUID(UUID.Zero); | ||
554 | SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo); | ||
555 | } | ||
556 | |||
557 | public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) | ||
558 | { | ||
559 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
560 | |||
561 | OSDMap Invite = new OSDMap(); | ||
562 | Invite["AgentID"] = OSD.FromUUID(agentID); | ||
563 | Invite["RoleID"] = OSD.FromUUID(roleID); | ||
564 | |||
565 | SimianAddGeneric(groupID, "GroupMemberInvite", inviteID.ToString(), Invite); | ||
566 | } | ||
567 | |||
568 | public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) | ||
569 | { | ||
570 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
571 | |||
572 | OSDMap GroupMemberInvite; | ||
573 | UUID GroupID; | ||
574 | if (!SimianGetFirstGenericEntry("GroupMemberInvite", inviteID.ToString(), out GroupID, out GroupMemberInvite)) | ||
575 | { | ||
576 | return null; | ||
577 | } | ||
578 | |||
579 | GroupInviteInfo inviteInfo = new GroupInviteInfo(); | ||
580 | inviteInfo.InviteID = inviteID; | ||
581 | inviteInfo.GroupID = GroupID; | ||
582 | inviteInfo.AgentID = GroupMemberInvite["AgentID"].AsUUID(); | ||
583 | inviteInfo.RoleID = GroupMemberInvite["RoleID"].AsUUID(); | ||
584 | |||
585 | return inviteInfo; | ||
586 | } | ||
587 | |||
588 | public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) | ||
589 | { | ||
590 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
591 | |||
592 | GroupInviteInfo invite = GetAgentToGroupInvite(requestingAgentID, inviteID); | ||
593 | SimianRemoveGenericEntry(invite.GroupID, "GroupMemberInvite", inviteID.ToString()); | ||
594 | } | ||
595 | |||
596 | public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) | ||
597 | { | ||
598 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
599 | |||
600 | // Setup Agent/Group information | ||
601 | SetAgentGroupInfo(requestingAgentID, AgentID, GroupID, true, true); | ||
602 | |||
603 | // Add agent to Everyone Group | ||
604 | AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, UUID.Zero); | ||
605 | |||
606 | // Add agent to Specified Role | ||
607 | AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, RoleID); | ||
608 | |||
609 | // Set selected role in this group to specified role | ||
610 | SetAgentActiveGroupRole(requestingAgentID, AgentID, GroupID, RoleID); | ||
611 | } | ||
612 | |||
613 | public void RemoveAgentFromGroup(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
614 | { | ||
615 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
616 | |||
617 | // If current active group is the group the agent is being removed from, change their group to UUID.Zero | ||
618 | GroupMembershipData memberActiveMembership = GetAgentActiveMembership(requestingAgentID, agentID); | ||
619 | if (memberActiveMembership.GroupID == groupID) | ||
620 | { | ||
621 | SetAgentActiveGroup(agentID, agentID, UUID.Zero); | ||
622 | } | ||
623 | |||
624 | // Remove Group Member information for this group | ||
625 | SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString()); | ||
626 | |||
627 | // By using a Simian Generics Type consisting of a prefix and a groupID, | ||
628 | // combined with RoleID as key allows us to get a list of roles a particular member | ||
629 | // of a group is assigned to. | ||
630 | string GroupRoleMemberType = "GroupRole" + groupID.ToString(); | ||
631 | |||
632 | // Take Agent out of all other group roles | ||
633 | Dictionary<string, OSDMap> GroupRoles; | ||
634 | if (SimianGetGenericEntries(agentID, GroupRoleMemberType, out GroupRoles)) | ||
635 | { | ||
636 | foreach (string roleID in GroupRoles.Keys) | ||
637 | { | ||
638 | SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID); | ||
639 | } | ||
640 | } | ||
641 | } | ||
642 | |||
643 | public void AddAgentToGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) | ||
644 | { | ||
645 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
646 | |||
647 | SimianAddGeneric(agentID, "GroupRole" + groupID.ToString(), roleID.ToString(), new OSDMap()); | ||
648 | } | ||
649 | |||
650 | public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) | ||
651 | { | ||
652 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
653 | |||
654 | // Cannot remove members from the Everyone Role | ||
655 | if (roleID != UUID.Zero) | ||
656 | { | ||
657 | EnsureRoleNotSelectedByMember(groupID, roleID, agentID); | ||
658 | |||
659 | string GroupRoleMemberType = "GroupRole" + groupID.ToString(); | ||
660 | SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID.ToString()); | ||
661 | } | ||
662 | } | ||
663 | |||
664 | public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search) | ||
665 | { | ||
666 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
667 | |||
668 | List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); | ||
669 | |||
670 | NameValueCollection requestArgs = new NameValueCollection | ||
671 | { | ||
672 | { "RequestMethod", "GetGenerics" }, | ||
673 | { "Type", "Group" }, | ||
674 | { "Key", search }, | ||
675 | { "Fuzzy", "1" } | ||
676 | }; | ||
677 | |||
678 | |||
679 | OSDMap response = CachedPostRequest(requestArgs); | ||
680 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | ||
681 | { | ||
682 | OSDArray entryArray = (OSDArray)response["Entries"]; | ||
683 | foreach (OSDMap entryMap in entryArray) | ||
684 | { | ||
685 | DirGroupsReplyData data = new DirGroupsReplyData(); | ||
686 | data.groupID = entryMap["OwnerID"].AsUUID(); | ||
687 | data.groupName = entryMap["Key"].AsString(); | ||
688 | |||
689 | // TODO: is there a better way to do this? | ||
690 | Dictionary<UUID, OSDMap> Members; | ||
691 | if (SimianGetGenericEntries("GroupMember", data.groupID.ToString(), out Members)) | ||
692 | { | ||
693 | data.members = Members.Count; | ||
694 | } | ||
695 | else | ||
696 | { | ||
697 | data.members = 0; | ||
698 | } | ||
699 | |||
700 | // TODO: sort results? | ||
701 | // data.searchOrder = order; | ||
702 | |||
703 | findings.Add(data); | ||
704 | } | ||
705 | } | ||
706 | |||
707 | |||
708 | return findings; | ||
709 | } | ||
710 | |||
711 | public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
712 | { | ||
713 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
714 | |||
715 | GroupMembershipData data = new GroupMembershipData(); | ||
716 | |||
717 | /////////////////////////////// | ||
718 | // Agent Specific Information: | ||
719 | // | ||
720 | OSDMap UserActiveGroup; | ||
721 | if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup)) | ||
722 | { | ||
723 | data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID); | ||
724 | } | ||
725 | |||
726 | OSDMap UserGroupMemberInfo; | ||
727 | if( SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo) ) | ||
728 | { | ||
729 | data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean(); | ||
730 | data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger(); | ||
731 | data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean(); | ||
732 | data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID(); | ||
733 | |||
734 | /////////////////////////////// | ||
735 | // Role Specific Information: | ||
736 | // | ||
737 | |||
738 | OSDMap GroupRoleInfo; | ||
739 | if( SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo) ) | ||
740 | { | ||
741 | data.GroupTitle = GroupRoleInfo["Title"].AsString(); | ||
742 | data.GroupPowers = GroupRoleInfo["Powers"].AsULong(); | ||
743 | } | ||
744 | } | ||
745 | |||
746 | /////////////////////////////// | ||
747 | // Group Specific Information: | ||
748 | // | ||
749 | OSDMap GroupInfo; | ||
750 | string GroupName; | ||
751 | if( SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo) ) | ||
752 | { | ||
753 | data.GroupID = groupID; | ||
754 | data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean(); | ||
755 | data.Charter = GroupInfo["Charter"].AsString(); | ||
756 | data.FounderID = GroupInfo["FounderID"].AsUUID(); | ||
757 | data.GroupName = GroupName; | ||
758 | data.GroupPicture = GroupInfo["InsigniaID"].AsUUID(); | ||
759 | data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean(); | ||
760 | data.MembershipFee = GroupInfo["MembershipFee"].AsInteger(); | ||
761 | data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean(); | ||
762 | data.ShowInList = GroupInfo["ShowInList"].AsBoolean(); | ||
763 | } | ||
764 | |||
765 | return data; | ||
766 | } | ||
767 | |||
768 | public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID agentID) | ||
769 | { | ||
770 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
771 | |||
772 | UUID GroupID = UUID.Zero; | ||
773 | OSDMap UserActiveGroup; | ||
774 | if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup)) | ||
775 | { | ||
776 | GroupID = UserActiveGroup["GroupID"].AsUUID(); | ||
777 | } | ||
778 | |||
779 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString()); | ||
780 | return GetAgentGroupMembership(requestingAgentID, agentID, GroupID); | ||
781 | } | ||
782 | |||
783 | public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID agentID) | ||
784 | { | ||
785 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
786 | |||
787 | List<GroupMembershipData> memberships = new List<GroupMembershipData>(); | ||
788 | |||
789 | Dictionary<string,OSDMap> GroupMemberShips; | ||
790 | if (SimianGetGenericEntries(agentID, "GroupMember", out GroupMemberShips)) | ||
791 | { | ||
792 | foreach (string key in GroupMemberShips.Keys) | ||
793 | { | ||
794 | memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key))); | ||
795 | } | ||
796 | } | ||
797 | |||
798 | return memberships; | ||
799 | } | ||
800 | |||
801 | public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
802 | { | ||
803 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
804 | |||
805 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | ||
806 | |||
807 | Dictionary<string, OSDMap> GroupRoles; | ||
808 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) | ||
809 | { | ||
810 | Dictionary<string, OSDMap> MemberRoles; | ||
811 | if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles)) | ||
812 | { | ||
813 | foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles) | ||
814 | { | ||
815 | GroupRolesData data = new GroupRolesData(); | ||
816 | data.RoleID = UUID.Parse(kvp.Key); | ||
817 | data.Name = GroupRoles[kvp.Key]["Name"].AsString(); | ||
818 | data.Description = GroupRoles[kvp.Key]["Description"].AsString(); | ||
819 | data.Title = GroupRoles[kvp.Key]["Title"].AsString(); | ||
820 | data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong(); | ||
821 | |||
822 | Roles.Add(data); | ||
823 | } | ||
824 | } | ||
825 | } | ||
826 | return Roles; | ||
827 | } | ||
828 | |||
829 | public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID groupID) | ||
830 | { | ||
831 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
832 | |||
833 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | ||
834 | |||
835 | Dictionary<string, OSDMap> GroupRoles; | ||
836 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) | ||
837 | { | ||
838 | foreach (KeyValuePair<string, OSDMap> role in GroupRoles) | ||
839 | { | ||
840 | GroupRolesData data = new GroupRolesData(); | ||
841 | |||
842 | data.RoleID = UUID.Parse(role.Key); | ||
843 | |||
844 | data.Name = role.Value["Name"].AsString(); | ||
845 | data.Description = role.Value["Description"].AsString(); | ||
846 | data.Title = role.Value["Title"].AsString(); | ||
847 | data.Powers = role.Value["Powers"].AsULong(); | ||
848 | |||
849 | Dictionary<UUID, OSDMap> GroupRoleMembers; | ||
850 | if (SimianGetGenericEntries("GroupRole" + groupID.ToString(), role.Key, out GroupRoleMembers)) | ||
851 | { | ||
852 | data.Members = GroupRoleMembers.Count; | ||
853 | } | ||
854 | else | ||
855 | { | ||
856 | data.Members = 0; | ||
857 | } | ||
858 | |||
859 | Roles.Add(data); | ||
860 | } | ||
861 | } | ||
862 | |||
863 | return Roles; | ||
864 | |||
865 | } | ||
866 | |||
867 | |||
868 | |||
869 | public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) | ||
870 | { | ||
871 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
872 | |||
873 | List<GroupMembersData> members = new List<GroupMembersData>(); | ||
874 | |||
875 | OSDMap GroupInfo; | ||
876 | string GroupName; | ||
877 | UUID GroupOwnerRoleID = UUID.Zero; | ||
878 | if (!SimianGetFirstGenericEntry(GroupID, "Group", out GroupName, out GroupInfo)) | ||
879 | { | ||
880 | return members; | ||
881 | } | ||
882 | GroupOwnerRoleID = GroupInfo["OwnerRoleID"].AsUUID(); | ||
883 | |||
884 | // Locally cache group roles, since we'll be needing this data for each member | ||
885 | Dictionary<string,OSDMap> GroupRoles; | ||
886 | SimianGetGenericEntries(GroupID, "GroupRole", out GroupRoles); | ||
887 | |||
888 | // Locally cache list of group owners | ||
889 | Dictionary<UUID, OSDMap> GroupOwners; | ||
890 | SimianGetGenericEntries("GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners); | ||
891 | |||
892 | |||
893 | Dictionary<UUID, OSDMap> GroupMembers; | ||
894 | if (SimianGetGenericEntries("GroupMember", GroupID.ToString(), out GroupMembers)) | ||
895 | { | ||
896 | foreach (KeyValuePair<UUID, OSDMap> member in GroupMembers) | ||
897 | { | ||
898 | GroupMembersData data = new GroupMembersData(); | ||
899 | |||
900 | data.AgentID = member.Key; | ||
901 | |||
902 | UUID SelectedRoleID = member.Value["SelectedRoleID"].AsUUID(); | ||
903 | |||
904 | data.AcceptNotices = member.Value["AcceptNotices"].AsBoolean(); | ||
905 | data.ListInProfile = member.Value["ListInProfile"].AsBoolean(); | ||
906 | data.Contribution = member.Value["Contribution"].AsInteger(); | ||
907 | |||
908 | data.IsOwner = GroupOwners.ContainsKey(member.Key); | ||
909 | |||
910 | OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()]; | ||
911 | data.Title = GroupRoleInfo["Title"].AsString(); | ||
912 | data.AgentPowers = GroupRoleInfo["Powers"].AsULong(); | ||
913 | |||
914 | members.Add(data); | ||
915 | } | ||
916 | } | ||
917 | |||
918 | return members; | ||
919 | |||
920 | } | ||
921 | |||
922 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID groupID) | ||
923 | { | ||
924 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
925 | |||
926 | List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); | ||
927 | |||
928 | Dictionary<string, OSDMap> GroupRoles; | ||
929 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) | ||
930 | { | ||
931 | foreach( KeyValuePair<string, OSDMap> Role in GroupRoles ) | ||
932 | { | ||
933 | Dictionary<UUID, OSDMap> GroupRoleMembers; | ||
934 | if( SimianGetGenericEntries("GroupRole"+groupID.ToString(), Role.Key, out GroupRoleMembers) ) | ||
935 | { | ||
936 | foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers ) | ||
937 | { | ||
938 | GroupRoleMembersData data = new GroupRoleMembersData(); | ||
939 | |||
940 | data.MemberID = GroupRoleMember.Key; | ||
941 | data.RoleID = UUID.Parse(Role.Key); | ||
942 | |||
943 | members.Add(data); | ||
944 | } | ||
945 | } | ||
946 | } | ||
947 | } | ||
948 | |||
949 | return members; | ||
950 | } | ||
951 | |||
952 | public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) | ||
953 | { | ||
954 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
955 | |||
956 | List<GroupNoticeData> values = new List<GroupNoticeData>(); | ||
957 | |||
958 | Dictionary<string, OSDMap> Notices; | ||
959 | if (SimianGetGenericEntries(GroupID, "GroupNotice", out Notices)) | ||
960 | { | ||
961 | foreach (KeyValuePair<string, OSDMap> Notice in Notices) | ||
962 | { | ||
963 | GroupNoticeData data = new GroupNoticeData(); | ||
964 | data.NoticeID = UUID.Parse(Notice.Key); | ||
965 | data.Timestamp = Notice.Value["TimeStamp"].AsUInteger(); | ||
966 | data.FromName = Notice.Value["FromName"].AsString(); | ||
967 | data.Subject = Notice.Value["Subject"].AsString(); | ||
968 | data.HasAttachment = Notice.Value["BinaryBucket"].AsBinary().Length > 0; | ||
969 | |||
970 | //TODO: Figure out how to get this | ||
971 | data.AssetType = 0; | ||
972 | |||
973 | values.Add(data); | ||
974 | } | ||
975 | } | ||
976 | |||
977 | return values; | ||
978 | |||
979 | } | ||
980 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) | ||
981 | { | ||
982 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
983 | |||
984 | OSDMap GroupNotice; | ||
985 | UUID GroupID; | ||
986 | if (SimianGetFirstGenericEntry("GroupNotice", noticeID.ToString(), out GroupID, out GroupNotice)) | ||
987 | { | ||
988 | GroupNoticeInfo data = new GroupNoticeInfo(); | ||
989 | data.GroupID = GroupID; | ||
990 | data.Message = GroupNotice["Message"].AsString(); | ||
991 | data.BinaryBucket = GroupNotice["BinaryBucket"].AsBinary(); | ||
992 | data.noticeData.NoticeID = noticeID; | ||
993 | data.noticeData.Timestamp = GroupNotice["TimeStamp"].AsUInteger(); | ||
994 | data.noticeData.FromName = GroupNotice["FromName"].AsString(); | ||
995 | data.noticeData.Subject = GroupNotice["Subject"].AsString(); | ||
996 | data.noticeData.HasAttachment = data.BinaryBucket.Length > 0; | ||
997 | data.noticeData.AssetType = 0; | ||
998 | |||
999 | if (data.Message == null) | ||
1000 | { | ||
1001 | data.Message = string.Empty; | ||
1002 | } | ||
1003 | |||
1004 | return data; | ||
1005 | } | ||
1006 | return null; | ||
1007 | } | ||
1008 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) | ||
1009 | { | ||
1010 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
1011 | |||
1012 | OSDMap Notice = new OSDMap(); | ||
1013 | Notice["TimeStamp"] = OSD.FromUInteger((uint)Util.UnixTimeSinceEpoch()); | ||
1014 | Notice["FromName"] = OSD.FromString(fromName); | ||
1015 | Notice["Subject"] = OSD.FromString(subject); | ||
1016 | Notice["Message"] = OSD.FromString(message); | ||
1017 | Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket); | ||
1018 | |||
1019 | SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice); | ||
1020 | |||
1021 | } | ||
1022 | #endregion | ||
1023 | |||
1024 | #region GroupSessionTracking | ||
1025 | |||
1026 | public void ResetAgentGroupChatSessions(UUID agentID) | ||
1027 | { | ||
1028 | Dictionary<string, OSDMap> agentSessions; | ||
1029 | |||
1030 | if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions)) | ||
1031 | { | ||
1032 | foreach (string GroupID in agentSessions.Keys) | ||
1033 | { | ||
1034 | SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID); | ||
1035 | } | ||
1036 | } | ||
1037 | |||
1038 | if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions)) | ||
1039 | { | ||
1040 | foreach (string GroupID in agentSessions.Keys) | ||
1041 | { | ||
1042 | SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID); | ||
1043 | } | ||
1044 | } | ||
1045 | } | ||
1046 | |||
1047 | public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) | ||
1048 | { | ||
1049 | OSDMap session; | ||
1050 | return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); | ||
1051 | } | ||
1052 | |||
1053 | public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) | ||
1054 | { | ||
1055 | SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap()); | ||
1056 | } | ||
1057 | |||
1058 | public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) | ||
1059 | { | ||
1060 | SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap()); | ||
1061 | } | ||
1062 | |||
1063 | public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) | ||
1064 | { | ||
1065 | OSDMap session; | ||
1066 | return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); | ||
1067 | } | ||
1068 | |||
1069 | #endregion | ||
1070 | |||
1071 | private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) | ||
1072 | { | ||
1073 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
1074 | |||
1075 | // If member's SelectedRole is roleID, change their selected role to Everyone | ||
1076 | // before removing them from the role | ||
1077 | OSDMap UserGroupInfo; | ||
1078 | if (SimianGetGenericEntry(userID, "GroupMember", groupID.ToString(), out UserGroupInfo)) | ||
1079 | { | ||
1080 | if (UserGroupInfo["SelectedRoleID"].AsUUID() == roleID) | ||
1081 | { | ||
1082 | UserGroupInfo["SelectedRoleID"] = OSD.FromUUID(UUID.Zero); | ||
1083 | } | ||
1084 | SimianAddGeneric(userID, "GroupMember", groupID.ToString(), UserGroupInfo); | ||
1085 | } | ||
1086 | } | ||
1087 | |||
1088 | |||
1089 | #region Simian Util Methods | ||
1090 | private bool SimianAddGeneric(UUID ownerID, string type, string key, OSDMap map) | ||
1091 | { | ||
1092 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key); | ||
1093 | |||
1094 | string value = OSDParser.SerializeJsonString(map); | ||
1095 | |||
1096 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] value: {0}", value); | ||
1097 | |||
1098 | NameValueCollection RequestArgs = new NameValueCollection | ||
1099 | { | ||
1100 | { "RequestMethod", "AddGeneric" }, | ||
1101 | { "OwnerID", ownerID.ToString() }, | ||
1102 | { "Type", type }, | ||
1103 | { "Key", key }, | ||
1104 | { "Value", value} | ||
1105 | }; | ||
1106 | |||
1107 | |||
1108 | OSDMap Response = CachedPostRequest(RequestArgs); | ||
1109 | if (Response["Success"].AsBoolean()) | ||
1110 | { | ||
1111 | return true; | ||
1112 | } | ||
1113 | else | ||
1114 | { | ||
1115 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, Response["Message"]); | ||
1116 | return false; | ||
1117 | } | ||
1118 | } | ||
1119 | |||
1120 | /// <summary> | ||
1121 | /// Returns the first of possibly many entries for Owner/Type pair | ||
1122 | /// </summary> | ||
1123 | private bool SimianGetFirstGenericEntry(UUID ownerID, string type, out string key, out OSDMap map) | ||
1124 | { | ||
1125 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type); | ||
1126 | |||
1127 | NameValueCollection RequestArgs = new NameValueCollection | ||
1128 | { | ||
1129 | { "RequestMethod", "GetGenerics" }, | ||
1130 | { "OwnerID", ownerID.ToString() }, | ||
1131 | { "Type", type } | ||
1132 | }; | ||
1133 | |||
1134 | |||
1135 | OSDMap Response = CachedPostRequest(RequestArgs); | ||
1136 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | ||
1137 | { | ||
1138 | OSDArray entryArray = (OSDArray)Response["Entries"]; | ||
1139 | if (entryArray.Count >= 1) | ||
1140 | { | ||
1141 | OSDMap entryMap = entryArray[0] as OSDMap; | ||
1142 | key = entryMap["Key"].AsString(); | ||
1143 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | ||
1144 | |||
1145 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1146 | |||
1147 | return true; | ||
1148 | } | ||
1149 | else | ||
1150 | { | ||
1151 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1152 | } | ||
1153 | } | ||
1154 | else | ||
1155 | { | ||
1156 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]); | ||
1157 | } | ||
1158 | key = null; | ||
1159 | map = null; | ||
1160 | return false; | ||
1161 | } | ||
1162 | private bool SimianGetFirstGenericEntry(string type, string key, out UUID ownerID, out OSDMap map) | ||
1163 | { | ||
1164 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key); | ||
1165 | |||
1166 | |||
1167 | NameValueCollection RequestArgs = new NameValueCollection | ||
1168 | { | ||
1169 | { "RequestMethod", "GetGenerics" }, | ||
1170 | { "Type", type }, | ||
1171 | { "Key", key} | ||
1172 | }; | ||
1173 | |||
1174 | |||
1175 | OSDMap Response = CachedPostRequest(RequestArgs); | ||
1176 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | ||
1177 | { | ||
1178 | OSDArray entryArray = (OSDArray)Response["Entries"]; | ||
1179 | if (entryArray.Count >= 1) | ||
1180 | { | ||
1181 | OSDMap entryMap = entryArray[0] as OSDMap; | ||
1182 | ownerID = entryMap["OwnerID"].AsUUID(); | ||
1183 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | ||
1184 | |||
1185 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1186 | |||
1187 | return true; | ||
1188 | } | ||
1189 | else | ||
1190 | { | ||
1191 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1192 | } | ||
1193 | } | ||
1194 | else | ||
1195 | { | ||
1196 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]); | ||
1197 | } | ||
1198 | ownerID = UUID.Zero; | ||
1199 | map = null; | ||
1200 | return false; | ||
1201 | } | ||
1202 | |||
1203 | private bool SimianGetGenericEntry(UUID ownerID, string type, string key, out OSDMap map) | ||
1204 | { | ||
1205 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key); | ||
1206 | |||
1207 | NameValueCollection RequestArgs = new NameValueCollection | ||
1208 | { | ||
1209 | { "RequestMethod", "GetGenerics" }, | ||
1210 | { "OwnerID", ownerID.ToString() }, | ||
1211 | { "Type", type }, | ||
1212 | { "Key", key} | ||
1213 | }; | ||
1214 | |||
1215 | |||
1216 | OSDMap Response = CachedPostRequest(RequestArgs); | ||
1217 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | ||
1218 | { | ||
1219 | OSDArray entryArray = (OSDArray)Response["Entries"]; | ||
1220 | if (entryArray.Count == 1) | ||
1221 | { | ||
1222 | OSDMap entryMap = entryArray[0] as OSDMap; | ||
1223 | key = entryMap["Key"].AsString(); | ||
1224 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | ||
1225 | |||
1226 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1227 | |||
1228 | return true; | ||
1229 | } | ||
1230 | else | ||
1231 | { | ||
1232 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1233 | } | ||
1234 | } | ||
1235 | else | ||
1236 | { | ||
1237 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]); | ||
1238 | } | ||
1239 | map = null; | ||
1240 | return false; | ||
1241 | } | ||
1242 | |||
1243 | private bool SimianGetGenericEntries(UUID ownerID, string type, out Dictionary<string, OSDMap> maps) | ||
1244 | { | ||
1245 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name,ownerID, type); | ||
1246 | |||
1247 | NameValueCollection requestArgs = new NameValueCollection | ||
1248 | { | ||
1249 | { "RequestMethod", "GetGenerics" }, | ||
1250 | { "OwnerID", ownerID.ToString() }, | ||
1251 | { "Type", type } | ||
1252 | }; | ||
1253 | |||
1254 | |||
1255 | |||
1256 | OSDMap response = CachedPostRequest(requestArgs); | ||
1257 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | ||
1258 | { | ||
1259 | maps = new Dictionary<string, OSDMap>(); | ||
1260 | |||
1261 | OSDArray entryArray = (OSDArray)response["Entries"]; | ||
1262 | foreach (OSDMap entryMap in entryArray) | ||
1263 | { | ||
1264 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1265 | maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); | ||
1266 | } | ||
1267 | if(maps.Count == 0) | ||
1268 | { | ||
1269 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1270 | } | ||
1271 | |||
1272 | return true; | ||
1273 | } | ||
1274 | else | ||
1275 | { | ||
1276 | maps = null; | ||
1277 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", response["Message"]); | ||
1278 | } | ||
1279 | return false; | ||
1280 | } | ||
1281 | private bool SimianGetGenericEntries(string type, string key, out Dictionary<UUID, OSDMap> maps) | ||
1282 | { | ||
1283 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key); | ||
1284 | |||
1285 | NameValueCollection requestArgs = new NameValueCollection | ||
1286 | { | ||
1287 | { "RequestMethod", "GetGenerics" }, | ||
1288 | { "Type", type }, | ||
1289 | { "Key", key } | ||
1290 | }; | ||
1291 | |||
1292 | |||
1293 | |||
1294 | OSDMap response = CachedPostRequest(requestArgs); | ||
1295 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | ||
1296 | { | ||
1297 | maps = new Dictionary<UUID, OSDMap>(); | ||
1298 | |||
1299 | OSDArray entryArray = (OSDArray)response["Entries"]; | ||
1300 | foreach (OSDMap entryMap in entryArray) | ||
1301 | { | ||
1302 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1303 | maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); | ||
1304 | } | ||
1305 | if (maps.Count == 0) | ||
1306 | { | ||
1307 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1308 | } | ||
1309 | return true; | ||
1310 | } | ||
1311 | else | ||
1312 | { | ||
1313 | maps = null; | ||
1314 | m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR]: Error retrieving group info ({0})", response["Message"]); | ||
1315 | } | ||
1316 | return false; | ||
1317 | } | ||
1318 | |||
1319 | private bool SimianRemoveGenericEntry(UUID ownerID, string type, string key) | ||
1320 | { | ||
1321 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key); | ||
1322 | |||
1323 | NameValueCollection requestArgs = new NameValueCollection | ||
1324 | { | ||
1325 | { "RequestMethod", "RemoveGeneric" }, | ||
1326 | { "OwnerID", ownerID.ToString() }, | ||
1327 | { "Type", type }, | ||
1328 | { "Key", key } | ||
1329 | }; | ||
1330 | |||
1331 | |||
1332 | OSDMap response = CachedPostRequest(requestArgs); | ||
1333 | if (response["Success"].AsBoolean()) | ||
1334 | { | ||
1335 | return true; | ||
1336 | } | ||
1337 | else | ||
1338 | { | ||
1339 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, response["Message"]); | ||
1340 | return false; | ||
1341 | } | ||
1342 | } | ||
1343 | #endregion | ||
1344 | |||
1345 | #region CheesyCache | ||
1346 | OSDMap CachedPostRequest(NameValueCollection requestArgs) | ||
1347 | { | ||
1348 | // Immediately forward the request if the cache is disabled. | ||
1349 | if (m_cacheTimeout == 0) | ||
1350 | { | ||
1351 | return WebUtil.PostToService(m_groupsServerURI, requestArgs); | ||
1352 | } | ||
1353 | |||
1354 | // Check if this is an update or a request | ||
1355 | if ( requestArgs["RequestMethod"] == "RemoveGeneric" | ||
1356 | || requestArgs["RequestMethod"] == "AddGeneric" | ||
1357 | ) | ||
1358 | |||
1359 | { | ||
1360 | // Any and all updates cause the cache to clear | ||
1361 | m_memoryCache.Clear(); | ||
1362 | |||
1363 | // Send update to server, return the response without caching it | ||
1364 | return WebUtil.PostToService(m_groupsServerURI, requestArgs); | ||
1365 | |||
1366 | } | ||
1367 | |||
1368 | // If we're not doing an update, we must be requesting data | ||
1369 | |||
1370 | // Create the cache key for the request and see if we have it cached | ||
1371 | string CacheKey = WebUtil.BuildQueryString(requestArgs); | ||
1372 | OSDMap response = null; | ||
1373 | if (!m_memoryCache.TryGetValue(CacheKey, out response)) | ||
1374 | { | ||
1375 | // if it wasn't in the cache, pass the request to the Simian Grid Services | ||
1376 | response = WebUtil.PostToService(m_groupsServerURI, requestArgs); | ||
1377 | |||
1378 | // and cache the response | ||
1379 | m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout)); | ||
1380 | } | ||
1381 | |||
1382 | // return cached response | ||
1383 | return response; | ||
1384 | } | ||
1385 | #endregion | ||
1386 | |||
1387 | } | ||
1388 | |||
1389 | } | ||
1390 | |||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 964d0bb..79b9a16 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Text; | ||
32 | 33 | ||
33 | using Nwc.XmlRpc; | 34 | using Nwc.XmlRpc; |
34 | 35 | ||
@@ -40,16 +41,16 @@ using OpenMetaverse; | |||
40 | using OpenMetaverse.StructuredData; | 41 | using OpenMetaverse.StructuredData; |
41 | 42 | ||
42 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
44 | using OpenSim.Framework.Communications; | ||
43 | using OpenSim.Region.Framework.Interfaces; | 45 | using OpenSim.Region.Framework.Interfaces; |
46 | using OpenSim.Services.Interfaces; | ||
44 | 47 | ||
45 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 48 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
46 | { | 49 | { |
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
48 | public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector | 51 | public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector |
49 | { | 52 | { |
50 | private static readonly ILog m_log = | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | 54 | ||
54 | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | | 55 | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | |
55 | GroupPowers.Accountable | | 56 | GroupPowers.Accountable | |
@@ -61,13 +62,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
61 | 62 | ||
62 | private bool m_connectorEnabled = false; | 63 | private bool m_connectorEnabled = false; |
63 | 64 | ||
64 | private string m_serviceURL = string.Empty; | 65 | private string m_groupsServerURI = string.Empty; |
65 | 66 | ||
66 | private bool m_disableKeepAlive = false; | 67 | private bool m_disableKeepAlive = false; |
67 | 68 | ||
68 | private string m_groupReadKey = string.Empty; | 69 | private string m_groupReadKey = string.Empty; |
69 | private string m_groupWriteKey = string.Empty; | 70 | private string m_groupWriteKey = string.Empty; |
70 | 71 | ||
72 | private IUserAccountService m_accountService = null; | ||
73 | |||
74 | private ExpiringCache<string, XmlRpcResponse> m_memoryCache; | ||
75 | private int m_cacheTimeout = 30; | ||
76 | |||
77 | // Used to track which agents are have dropped from a group chat session | ||
78 | // Should be reset per agent, on logon | ||
79 | // TODO: move this to Flotsam XmlRpc Service | ||
80 | // SessionID, List<AgentID> | ||
81 | private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>(); | ||
82 | private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>(); | ||
83 | |||
71 | 84 | ||
72 | #region IRegionModuleBase Members | 85 | #region IRegionModuleBase Members |
73 | 86 | ||
@@ -102,13 +115,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
102 | return; | 115 | return; |
103 | } | 116 | } |
104 | 117 | ||
105 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); | 118 | m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name); |
106 | 119 | ||
107 | m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); | 120 | m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); |
108 | if ((m_serviceURL == null) || | 121 | if ((m_groupsServerURI == null) || |
109 | (m_serviceURL == string.Empty)) | 122 | (m_groupsServerURI == string.Empty)) |
110 | { | 123 | { |
111 | m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); | 124 | m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); |
112 | m_connectorEnabled = false; | 125 | m_connectorEnabled = false; |
113 | return; | 126 | return; |
114 | } | 127 | } |
@@ -118,26 +131,49 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
118 | m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); | 131 | m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); |
119 | m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); | 132 | m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); |
120 | 133 | ||
134 | |||
135 | m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30); | ||
136 | if (m_cacheTimeout == 0) | ||
137 | { | ||
138 | m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled."); | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout); | ||
143 | } | ||
144 | |||
121 | // If we got all the config options we need, lets start'er'up | 145 | // If we got all the config options we need, lets start'er'up |
146 | m_memoryCache = new ExpiringCache<string, XmlRpcResponse>(); | ||
122 | m_connectorEnabled = true; | 147 | m_connectorEnabled = true; |
123 | } | 148 | } |
124 | } | 149 | } |
125 | 150 | ||
126 | public void Close() | 151 | public void Close() |
127 | { | 152 | { |
128 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); | 153 | m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name); |
129 | } | 154 | } |
130 | 155 | ||
131 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) | 156 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) |
132 | { | 157 | { |
133 | if (m_connectorEnabled) | 158 | if (m_connectorEnabled) |
159 | { | ||
160 | |||
161 | if (m_accountService == null) | ||
162 | { | ||
163 | m_accountService = scene.UserAccountService; | ||
164 | } | ||
165 | |||
166 | |||
134 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); | 167 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); |
168 | } | ||
135 | } | 169 | } |
136 | 170 | ||
137 | public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) | 171 | public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) |
138 | { | 172 | { |
139 | if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) | 173 | if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) |
174 | { | ||
140 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); | 175 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); |
176 | } | ||
141 | } | 177 | } |
142 | 178 | ||
143 | public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) | 179 | public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) |
@@ -157,14 +193,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
157 | 193 | ||
158 | #endregion | 194 | #endregion |
159 | 195 | ||
160 | |||
161 | |||
162 | #region IGroupsServicesConnector Members | 196 | #region IGroupsServicesConnector Members |
163 | 197 | ||
164 | /// <summary> | 198 | /// <summary> |
165 | /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. | 199 | /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. |
166 | /// </summary> | 200 | /// </summary> |
167 | public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, | 201 | public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, |
168 | int membershipFee, bool openEnrollment, bool allowPublish, | 202 | int membershipFee, bool openEnrollment, bool allowPublish, |
169 | bool maturePublish, UUID founderID) | 203 | bool maturePublish, UUID founderID) |
170 | { | 204 | { |
@@ -236,7 +270,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
236 | 270 | ||
237 | 271 | ||
238 | 272 | ||
239 | Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param); | 273 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param); |
240 | 274 | ||
241 | if (respData.Contains("error")) | 275 | if (respData.Contains("error")) |
242 | { | 276 | { |
@@ -248,7 +282,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
248 | return UUID.Parse((string)respData["GroupID"]); | 282 | return UUID.Parse((string)respData["GroupID"]); |
249 | } | 283 | } |
250 | 284 | ||
251 | public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, | 285 | public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, |
252 | UUID insigniaID, int membershipFee, bool openEnrollment, | 286 | UUID insigniaID, int membershipFee, bool openEnrollment, |
253 | bool allowPublish, bool maturePublish) | 287 | bool allowPublish, bool maturePublish) |
254 | { | 288 | { |
@@ -262,10 +296,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
262 | param["AllowPublish"] = allowPublish == true ? 1 : 0; | 296 | param["AllowPublish"] = allowPublish == true ? 1 : 0; |
263 | param["MaturePublish"] = maturePublish == true ? 1 : 0; | 297 | param["MaturePublish"] = maturePublish == true ? 1 : 0; |
264 | 298 | ||
265 | XmlRpcCall(requestID, "groups.updateGroup", param); | 299 | XmlRpcCall(requestingAgentID, "groups.updateGroup", param); |
266 | } | 300 | } |
267 | 301 | ||
268 | public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, | 302 | public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, |
269 | string title, ulong powers) | 303 | string title, ulong powers) |
270 | { | 304 | { |
271 | Hashtable param = new Hashtable(); | 305 | Hashtable param = new Hashtable(); |
@@ -276,19 +310,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
276 | param["Title"] = title; | 310 | param["Title"] = title; |
277 | param["Powers"] = powers.ToString(); | 311 | param["Powers"] = powers.ToString(); |
278 | 312 | ||
279 | XmlRpcCall(requestID, "groups.addRoleToGroup", param); | 313 | XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param); |
280 | } | 314 | } |
281 | 315 | ||
282 | public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID) | 316 | public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID) |
283 | { | 317 | { |
284 | Hashtable param = new Hashtable(); | 318 | Hashtable param = new Hashtable(); |
285 | param["GroupID"] = groupID.ToString(); | 319 | param["GroupID"] = groupID.ToString(); |
286 | param["RoleID"] = roleID.ToString(); | 320 | param["RoleID"] = roleID.ToString(); |
287 | 321 | ||
288 | XmlRpcCall(requestID, "groups.removeRoleFromGroup", param); | 322 | XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param); |
289 | } | 323 | } |
290 | 324 | ||
291 | public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, | 325 | public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, |
292 | string title, ulong powers) | 326 | string title, ulong powers) |
293 | { | 327 | { |
294 | Hashtable param = new Hashtable(); | 328 | Hashtable param = new Hashtable(); |
@@ -308,10 +342,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
308 | } | 342 | } |
309 | param["Powers"] = powers.ToString(); | 343 | param["Powers"] = powers.ToString(); |
310 | 344 | ||
311 | XmlRpcCall(requestID, "groups.updateGroupRole", param); | 345 | XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param); |
312 | } | 346 | } |
313 | 347 | ||
314 | public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName) | 348 | public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName) |
315 | { | 349 | { |
316 | Hashtable param = new Hashtable(); | 350 | Hashtable param = new Hashtable(); |
317 | if (GroupID != UUID.Zero) | 351 | if (GroupID != UUID.Zero) |
@@ -323,7 +357,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
323 | param["Name"] = GroupName.ToString(); | 357 | param["Name"] = GroupName.ToString(); |
324 | } | 358 | } |
325 | 359 | ||
326 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); | 360 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param); |
327 | 361 | ||
328 | if (respData.Contains("error")) | 362 | if (respData.Contains("error")) |
329 | { | 363 | { |
@@ -334,12 +368,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
334 | 368 | ||
335 | } | 369 | } |
336 | 370 | ||
337 | public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID) | 371 | public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID) |
338 | { | 372 | { |
339 | Hashtable param = new Hashtable(); | 373 | Hashtable param = new Hashtable(); |
340 | param["GroupID"] = GroupID.ToString(); | 374 | param["GroupID"] = GroupID.ToString(); |
341 | 375 | ||
342 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); | 376 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param); |
343 | 377 | ||
344 | if (respData.Contains("error")) | 378 | if (respData.Contains("error")) |
345 | { | 379 | { |
@@ -347,38 +381,35 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
347 | return new GroupProfileData(); | 381 | return new GroupProfileData(); |
348 | } | 382 | } |
349 | 383 | ||
350 | GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID); | 384 | GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID); |
351 | GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); | 385 | GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); |
352 | 386 | ||
353 | MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; | 387 | MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; |
354 | MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; | 388 | MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; |
355 | 389 | ||
356 | return MemberGroupProfile; | 390 | return MemberGroupProfile; |
357 | |||
358 | } | 391 | } |
359 | 392 | ||
360 | 393 | public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) | |
361 | |||
362 | public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) | ||
363 | { | 394 | { |
364 | Hashtable param = new Hashtable(); | 395 | Hashtable param = new Hashtable(); |
365 | param["AgentID"] = AgentID.ToString(); | 396 | param["AgentID"] = AgentID.ToString(); |
366 | param["GroupID"] = GroupID.ToString(); | 397 | param["GroupID"] = GroupID.ToString(); |
367 | 398 | ||
368 | XmlRpcCall(requestID, "groups.setAgentActiveGroup", param); | 399 | XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param); |
369 | } | 400 | } |
370 | 401 | ||
371 | public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 402 | public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
372 | { | 403 | { |
373 | Hashtable param = new Hashtable(); | 404 | Hashtable param = new Hashtable(); |
374 | param["AgentID"] = AgentID.ToString(); | 405 | param["AgentID"] = AgentID.ToString(); |
375 | param["GroupID"] = GroupID.ToString(); | 406 | param["GroupID"] = GroupID.ToString(); |
376 | param["SelectedRoleID"] = RoleID.ToString(); | 407 | param["SelectedRoleID"] = RoleID.ToString(); |
377 | 408 | ||
378 | XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); | 409 | XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param); |
379 | } | 410 | } |
380 | 411 | ||
381 | public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) | 412 | public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) |
382 | { | 413 | { |
383 | Hashtable param = new Hashtable(); | 414 | Hashtable param = new Hashtable(); |
384 | param["AgentID"] = AgentID.ToString(); | 415 | param["AgentID"] = AgentID.ToString(); |
@@ -386,11 +417,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
386 | param["AcceptNotices"] = AcceptNotices ? "1" : "0"; | 417 | param["AcceptNotices"] = AcceptNotices ? "1" : "0"; |
387 | param["ListInProfile"] = ListInProfile ? "1" : "0"; | 418 | param["ListInProfile"] = ListInProfile ? "1" : "0"; |
388 | 419 | ||
389 | XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); | 420 | XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param); |
390 | 421 | ||
391 | } | 422 | } |
392 | 423 | ||
393 | public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) | 424 | public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) |
394 | { | 425 | { |
395 | Hashtable param = new Hashtable(); | 426 | Hashtable param = new Hashtable(); |
396 | param["InviteID"] = inviteID.ToString(); | 427 | param["InviteID"] = inviteID.ToString(); |
@@ -398,16 +429,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
398 | param["RoleID"] = roleID.ToString(); | 429 | param["RoleID"] = roleID.ToString(); |
399 | param["GroupID"] = groupID.ToString(); | 430 | param["GroupID"] = groupID.ToString(); |
400 | 431 | ||
401 | XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param); | 432 | XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param); |
402 | 433 | ||
403 | } | 434 | } |
404 | 435 | ||
405 | public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) | 436 | public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) |
406 | { | 437 | { |
407 | Hashtable param = new Hashtable(); | 438 | Hashtable param = new Hashtable(); |
408 | param["InviteID"] = inviteID.ToString(); | 439 | param["InviteID"] = inviteID.ToString(); |
409 | 440 | ||
410 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param); | 441 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param); |
411 | 442 | ||
412 | if (respData.Contains("error")) | 443 | if (respData.Contains("error")) |
413 | { | 444 | { |
@@ -423,60 +454,59 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
423 | return inviteInfo; | 454 | return inviteInfo; |
424 | } | 455 | } |
425 | 456 | ||
426 | public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) | 457 | public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) |
427 | { | 458 | { |
428 | Hashtable param = new Hashtable(); | 459 | Hashtable param = new Hashtable(); |
429 | param["InviteID"] = inviteID.ToString(); | 460 | param["InviteID"] = inviteID.ToString(); |
430 | 461 | ||
431 | XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param); | 462 | XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param); |
432 | } | 463 | } |
433 | 464 | ||
434 | public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 465 | public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
435 | { | 466 | { |
436 | Hashtable param = new Hashtable(); | 467 | Hashtable param = new Hashtable(); |
437 | param["AgentID"] = AgentID.ToString(); | 468 | param["AgentID"] = AgentID.ToString(); |
438 | param["GroupID"] = GroupID.ToString(); | 469 | param["GroupID"] = GroupID.ToString(); |
439 | param["RoleID"] = RoleID.ToString(); | 470 | param["RoleID"] = RoleID.ToString(); |
440 | 471 | ||
441 | XmlRpcCall(requestID, "groups.addAgentToGroup", param); | 472 | XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param); |
442 | } | 473 | } |
443 | 474 | ||
444 | public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 475 | public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
445 | { | 476 | { |
446 | Hashtable param = new Hashtable(); | 477 | Hashtable param = new Hashtable(); |
447 | param["AgentID"] = AgentID.ToString(); | 478 | param["AgentID"] = AgentID.ToString(); |
448 | param["GroupID"] = GroupID.ToString(); | 479 | param["GroupID"] = GroupID.ToString(); |
449 | 480 | ||
450 | XmlRpcCall(requestID, "groups.removeAgentFromGroup", param); | 481 | XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param); |
451 | } | 482 | } |
452 | 483 | ||
453 | public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 484 | public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
454 | { | 485 | { |
455 | Hashtable param = new Hashtable(); | 486 | Hashtable param = new Hashtable(); |
456 | param["AgentID"] = AgentID.ToString(); | 487 | param["AgentID"] = AgentID.ToString(); |
457 | param["GroupID"] = GroupID.ToString(); | 488 | param["GroupID"] = GroupID.ToString(); |
458 | param["RoleID"] = RoleID.ToString(); | 489 | param["RoleID"] = RoleID.ToString(); |
459 | 490 | ||
460 | XmlRpcCall(requestID, "groups.addAgentToGroupRole", param); | 491 | XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param); |
461 | } | 492 | } |
462 | 493 | ||
463 | public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 494 | public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
464 | { | 495 | { |
465 | Hashtable param = new Hashtable(); | 496 | Hashtable param = new Hashtable(); |
466 | param["AgentID"] = AgentID.ToString(); | 497 | param["AgentID"] = AgentID.ToString(); |
467 | param["GroupID"] = GroupID.ToString(); | 498 | param["GroupID"] = GroupID.ToString(); |
468 | param["RoleID"] = RoleID.ToString(); | 499 | param["RoleID"] = RoleID.ToString(); |
469 | 500 | ||
470 | XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param); | 501 | XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param); |
471 | } | 502 | } |
472 | 503 | ||
473 | 504 | public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search) | |
474 | public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search) | ||
475 | { | 505 | { |
476 | Hashtable param = new Hashtable(); | 506 | Hashtable param = new Hashtable(); |
477 | param["Search"] = search; | 507 | param["Search"] = search; |
478 | 508 | ||
479 | Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param); | 509 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param); |
480 | 510 | ||
481 | List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); | 511 | List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); |
482 | 512 | ||
@@ -498,13 +528,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
498 | return findings; | 528 | return findings; |
499 | } | 529 | } |
500 | 530 | ||
501 | public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 531 | public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
502 | { | 532 | { |
503 | Hashtable param = new Hashtable(); | 533 | Hashtable param = new Hashtable(); |
504 | param["AgentID"] = AgentID.ToString(); | 534 | param["AgentID"] = AgentID.ToString(); |
505 | param["GroupID"] = GroupID.ToString(); | 535 | param["GroupID"] = GroupID.ToString(); |
506 | 536 | ||
507 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param); | 537 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param); |
508 | 538 | ||
509 | if (respData.Contains("error")) | 539 | if (respData.Contains("error")) |
510 | { | 540 | { |
@@ -516,12 +546,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
516 | return data; | 546 | return data; |
517 | } | 547 | } |
518 | 548 | ||
519 | public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID) | 549 | public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID) |
520 | { | 550 | { |
521 | Hashtable param = new Hashtable(); | 551 | Hashtable param = new Hashtable(); |
522 | param["AgentID"] = AgentID.ToString(); | 552 | param["AgentID"] = AgentID.ToString(); |
523 | 553 | ||
524 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param); | 554 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param); |
525 | 555 | ||
526 | if (respData.Contains("error")) | 556 | if (respData.Contains("error")) |
527 | { | 557 | { |
@@ -531,13 +561,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
531 | return HashTableToGroupMembershipData(respData); | 561 | return HashTableToGroupMembershipData(respData); |
532 | } | 562 | } |
533 | 563 | ||
534 | 564 | public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID) | |
535 | public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID) | ||
536 | { | 565 | { |
537 | Hashtable param = new Hashtable(); | 566 | Hashtable param = new Hashtable(); |
538 | param["AgentID"] = AgentID.ToString(); | 567 | param["AgentID"] = AgentID.ToString(); |
539 | 568 | ||
540 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param); | 569 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param); |
541 | 570 | ||
542 | List<GroupMembershipData> memberships = new List<GroupMembershipData>(); | 571 | List<GroupMembershipData> memberships = new List<GroupMembershipData>(); |
543 | 572 | ||
@@ -552,13 +581,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
552 | return memberships; | 581 | return memberships; |
553 | } | 582 | } |
554 | 583 | ||
555 | public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 584 | public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
556 | { | 585 | { |
557 | Hashtable param = new Hashtable(); | 586 | Hashtable param = new Hashtable(); |
558 | param["AgentID"] = AgentID.ToString(); | 587 | param["AgentID"] = AgentID.ToString(); |
559 | param["GroupID"] = GroupID.ToString(); | 588 | param["GroupID"] = GroupID.ToString(); |
560 | 589 | ||
561 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param); | 590 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param); |
562 | 591 | ||
563 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | 592 | List<GroupRolesData> Roles = new List<GroupRolesData>(); |
564 | 593 | ||
@@ -584,12 +613,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
584 | 613 | ||
585 | } | 614 | } |
586 | 615 | ||
587 | public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID) | 616 | public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID) |
588 | { | 617 | { |
589 | Hashtable param = new Hashtable(); | 618 | Hashtable param = new Hashtable(); |
590 | param["GroupID"] = GroupID.ToString(); | 619 | param["GroupID"] = GroupID.ToString(); |
591 | 620 | ||
592 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param); | 621 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param); |
593 | 622 | ||
594 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | 623 | List<GroupRolesData> Roles = new List<GroupRolesData>(); |
595 | 624 | ||
@@ -617,12 +646,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
617 | 646 | ||
618 | 647 | ||
619 | 648 | ||
620 | public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) | 649 | public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) |
621 | { | 650 | { |
622 | Hashtable param = new Hashtable(); | 651 | Hashtable param = new Hashtable(); |
623 | param["GroupID"] = GroupID.ToString(); | 652 | param["GroupID"] = GroupID.ToString(); |
624 | 653 | ||
625 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param); | 654 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param); |
626 | 655 | ||
627 | List<GroupMembersData> members = new List<GroupMembersData>(); | 656 | List<GroupMembersData> members = new List<GroupMembersData>(); |
628 | 657 | ||
@@ -650,12 +679,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
650 | 679 | ||
651 | } | 680 | } |
652 | 681 | ||
653 | public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID) | 682 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) |
654 | { | 683 | { |
655 | Hashtable param = new Hashtable(); | 684 | Hashtable param = new Hashtable(); |
656 | param["GroupID"] = GroupID.ToString(); | 685 | param["GroupID"] = GroupID.ToString(); |
657 | 686 | ||
658 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param); | 687 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param); |
659 | 688 | ||
660 | List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); | 689 | List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); |
661 | 690 | ||
@@ -674,12 +703,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
674 | return members; | 703 | return members; |
675 | } | 704 | } |
676 | 705 | ||
677 | public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID) | 706 | public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) |
678 | { | 707 | { |
679 | Hashtable param = new Hashtable(); | 708 | Hashtable param = new Hashtable(); |
680 | param["GroupID"] = GroupID.ToString(); | 709 | param["GroupID"] = GroupID.ToString(); |
681 | 710 | ||
682 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param); | 711 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param); |
683 | 712 | ||
684 | List<GroupNoticeData> values = new List<GroupNoticeData>(); | 713 | List<GroupNoticeData> values = new List<GroupNoticeData>(); |
685 | 714 | ||
@@ -701,12 +730,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
701 | return values; | 730 | return values; |
702 | 731 | ||
703 | } | 732 | } |
704 | public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID) | 733 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) |
705 | { | 734 | { |
706 | Hashtable param = new Hashtable(); | 735 | Hashtable param = new Hashtable(); |
707 | param["NoticeID"] = noticeID.ToString(); | 736 | param["NoticeID"] = noticeID.ToString(); |
708 | 737 | ||
709 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param); | 738 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param); |
710 | 739 | ||
711 | 740 | ||
712 | if (respData.Contains("error")) | 741 | if (respData.Contains("error")) |
@@ -732,7 +761,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
732 | 761 | ||
733 | return data; | 762 | return data; |
734 | } | 763 | } |
735 | public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) | 764 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) |
736 | { | 765 | { |
737 | string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); | 766 | string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); |
738 | 767 | ||
@@ -745,7 +774,70 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
745 | param["BinaryBucket"] = binBucket; | 774 | param["BinaryBucket"] = binBucket; |
746 | param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); | 775 | param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); |
747 | 776 | ||
748 | XmlRpcCall(requestID, "groups.addGroupNotice", param); | 777 | XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param); |
778 | } | ||
779 | |||
780 | |||
781 | |||
782 | #endregion | ||
783 | |||
784 | #region GroupSessionTracking | ||
785 | |||
786 | public void ResetAgentGroupChatSessions(UUID agentID) | ||
787 | { | ||
788 | foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values) | ||
789 | { | ||
790 | agentList.Remove(agentID); | ||
791 | } | ||
792 | } | ||
793 | |||
794 | public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) | ||
795 | { | ||
796 | // If we're tracking this group, and we can find them in the tracking, then they've been invited | ||
797 | return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID) | ||
798 | && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID); | ||
799 | } | ||
800 | |||
801 | public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) | ||
802 | { | ||
803 | // If we're tracking drops for this group, | ||
804 | // and we find them, well... then they've dropped | ||
805 | return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID) | ||
806 | && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID); | ||
807 | } | ||
808 | |||
809 | public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) | ||
810 | { | ||
811 | if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) | ||
812 | { | ||
813 | // If not in dropped list, add | ||
814 | if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) | ||
815 | { | ||
816 | m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID); | ||
817 | } | ||
818 | } | ||
819 | } | ||
820 | |||
821 | public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) | ||
822 | { | ||
823 | // Add Session Status if it doesn't exist for this session | ||
824 | CreateGroupChatSessionTracking(groupID); | ||
825 | |||
826 | // If nessesary, remove from dropped list | ||
827 | if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) | ||
828 | { | ||
829 | m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID); | ||
830 | } | ||
831 | } | ||
832 | |||
833 | private void CreateGroupChatSessionTracking(UUID groupID) | ||
834 | { | ||
835 | if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) | ||
836 | { | ||
837 | m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>()); | ||
838 | m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>()); | ||
839 | } | ||
840 | |||
749 | } | 841 | } |
750 | #endregion | 842 | #endregion |
751 | 843 | ||
@@ -778,7 +870,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
778 | 870 | ||
779 | private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) | 871 | private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) |
780 | { | 872 | { |
781 | |||
782 | GroupRecord group = new GroupRecord(); | 873 | GroupRecord group = new GroupRecord(); |
783 | group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); | 874 | group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); |
784 | group.GroupName = groupProfile["Name"].ToString(); | 875 | group.GroupName = groupProfile["Name"].ToString(); |
@@ -797,6 +888,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
797 | 888 | ||
798 | return group; | 889 | return group; |
799 | } | 890 | } |
891 | |||
800 | private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) | 892 | private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) |
801 | { | 893 | { |
802 | GroupMembershipData data = new GroupMembershipData(); | 894 | GroupMembershipData data = new GroupMembershipData(); |
@@ -829,6 +921,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
829 | data.MembershipFee = int.Parse((string)respData["MembershipFee"]); | 921 | data.MembershipFee = int.Parse((string)respData["MembershipFee"]); |
830 | data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); | 922 | data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); |
831 | data.ShowInList = ((string)respData["ShowInList"] == "1"); | 923 | data.ShowInList = ((string)respData["ShowInList"] == "1"); |
924 | |||
832 | return data; | 925 | return data; |
833 | } | 926 | } |
834 | 927 | ||
@@ -837,53 +930,86 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
837 | /// <summary> | 930 | /// <summary> |
838 | /// Encapsulate the XmlRpc call to standardize security and error handling. | 931 | /// Encapsulate the XmlRpc call to standardize security and error handling. |
839 | /// </summary> | 932 | /// </summary> |
840 | private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) | 933 | private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) |
841 | { | 934 | { |
842 | if (requestID == null) | 935 | XmlRpcResponse resp = null; |
936 | string CacheKey = null; | ||
937 | |||
938 | // Only bother with the cache if it isn't disabled. | ||
939 | if (m_cacheTimeout > 0) | ||
843 | { | 940 | { |
844 | requestID = new GroupRequestID(); | 941 | if (!function.StartsWith("groups.get")) |
942 | { | ||
943 | // Any and all updates cause the cache to clear | ||
944 | m_memoryCache.Clear(); | ||
945 | } | ||
946 | else | ||
947 | { | ||
948 | StringBuilder sb = new StringBuilder(requestingAgentID + function); | ||
949 | foreach (object key in param.Keys) | ||
950 | { | ||
951 | if (param[key] != null) | ||
952 | { | ||
953 | sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString()); | ||
954 | } | ||
955 | } | ||
956 | |||
957 | CacheKey = sb.ToString(); | ||
958 | m_memoryCache.TryGetValue(CacheKey, out resp); | ||
959 | } | ||
960 | |||
845 | } | 961 | } |
846 | param.Add("RequestingAgentID", requestID.AgentID.ToString()); | ||
847 | param.Add("RequestingAgentUserService", requestID.UserServiceURL); | ||
848 | param.Add("RequestingSessionID", requestID.SessionID.ToString()); | ||
849 | 962 | ||
963 | if( resp == null ) | ||
964 | { | ||
965 | string UserService; | ||
966 | UUID SessionID; | ||
967 | GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); | ||
968 | param.Add("requestingAgentID", requestingAgentID.ToString()); | ||
969 | param.Add("RequestingAgentUserService", UserService); | ||
970 | param.Add("RequestingSessionID", SessionID.ToString()); | ||
850 | 971 | ||
851 | param.Add("ReadKey", m_groupReadKey); | ||
852 | param.Add("WriteKey", m_groupWriteKey); | ||
853 | 972 | ||
973 | param.Add("ReadKey", m_groupReadKey); | ||
974 | param.Add("WriteKey", m_groupWriteKey); | ||
854 | 975 | ||
855 | IList parameters = new ArrayList(); | ||
856 | parameters.Add(param); | ||
857 | 976 | ||
858 | ConfigurableKeepAliveXmlRpcRequest req; | 977 | IList parameters = new ArrayList(); |
859 | req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); | 978 | parameters.Add(param); |
860 | 979 | ||
861 | XmlRpcResponse resp = null; | 980 | ConfigurableKeepAliveXmlRpcRequest req; |
981 | req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); | ||
862 | 982 | ||
863 | try | ||
864 | { | ||
865 | resp = req.Send(m_serviceURL, 10000); | ||
866 | } | ||
867 | catch (Exception e) | ||
868 | { | ||
869 | |||
870 | |||
871 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); | ||
872 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString()); | ||
873 | 983 | ||
874 | foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None)) | 984 | try |
875 | { | 985 | { |
876 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); | 986 | resp = req.Send(m_groupsServerURI, 10000); |
877 | } | 987 | |
988 | if ((m_cacheTimeout > 0) && (CacheKey != null)) | ||
989 | { | ||
990 | m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout)); | ||
991 | } | ||
878 | 992 | ||
879 | foreach (string key in param.Keys) | 993 | } |
994 | catch (Exception e) | ||
880 | { | 995 | { |
881 | m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString()); | 996 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); |
997 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", e.ToString()); | ||
998 | |||
999 | foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) | ||
1000 | { | ||
1001 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine); | ||
1002 | } | ||
1003 | |||
1004 | foreach (string key in param.Keys) | ||
1005 | { | ||
1006 | m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString()); | ||
1007 | } | ||
1008 | |||
1009 | Hashtable respData = new Hashtable(); | ||
1010 | respData.Add("error", e.ToString()); | ||
1011 | return respData; | ||
882 | } | 1012 | } |
883 | |||
884 | Hashtable respData = new Hashtable(); | ||
885 | respData.Add("error", e.ToString()); | ||
886 | return respData; | ||
887 | } | 1013 | } |
888 | 1014 | ||
889 | if (resp.Value is Hashtable) | 1015 | if (resp.Value is Hashtable) |
@@ -897,21 +1023,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
897 | return respData; | 1023 | return respData; |
898 | } | 1024 | } |
899 | 1025 | ||
900 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); | 1026 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); |
901 | 1027 | ||
902 | if (resp.Value is ArrayList) | 1028 | if (resp.Value is ArrayList) |
903 | { | 1029 | { |
904 | ArrayList al = (ArrayList)resp.Value; | 1030 | ArrayList al = (ArrayList)resp.Value; |
905 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count); | 1031 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count); |
906 | 1032 | ||
907 | foreach (object o in al) | 1033 | foreach (object o in al) |
908 | { | 1034 | { |
909 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString()); | 1035 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString()); |
910 | } | 1036 | } |
911 | } | 1037 | } |
912 | else | 1038 | else |
913 | { | 1039 | { |
914 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString()); | 1040 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString()); |
915 | } | 1041 | } |
916 | 1042 | ||
917 | Hashtable error = new Hashtable(); | 1043 | Hashtable error = new Hashtable(); |
@@ -921,30 +1047,64 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
921 | 1047 | ||
922 | private void LogRespDataToConsoleError(Hashtable respData) | 1048 | private void LogRespDataToConsoleError(Hashtable respData) |
923 | { | 1049 | { |
924 | m_log.Error("[XMLRPCGROUPDATA]: Error:"); | 1050 | m_log.Error("[XMLRPC-GROUPS-CONNECTOR]: Error:"); |
925 | 1051 | ||
926 | foreach (string key in respData.Keys) | 1052 | foreach (string key in respData.Keys) |
927 | { | 1053 | { |
928 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key); | 1054 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Key: {0}", key); |
929 | 1055 | ||
930 | string[] lines = respData[key].ToString().Split(new char[] { '\n' }); | 1056 | string[] lines = respData[key].ToString().Split(new char[] { '\n' }); |
931 | foreach (string line in lines) | 1057 | foreach (string line in lines) |
932 | { | 1058 | { |
933 | m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line); | 1059 | m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line); |
934 | } | 1060 | } |
935 | 1061 | ||
936 | } | 1062 | } |
937 | } | 1063 | } |
938 | 1064 | ||
1065 | |||
1066 | /// <summary> | ||
1067 | /// Group Request Tokens are an attempt to allow the groups service to authenticate | ||
1068 | /// requests. | ||
1069 | /// TODO: This broke after the big grid refactor, either find a better way, or discard this | ||
1070 | /// </summary> | ||
1071 | /// <param name="client"></param> | ||
1072 | /// <returns></returns> | ||
1073 | private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID) | ||
1074 | { | ||
1075 | UserServiceURL = ""; | ||
1076 | SessionID = UUID.Zero; | ||
939 | 1077 | ||
940 | } | ||
941 | 1078 | ||
942 | public class GroupNoticeInfo | 1079 | // Need to rework this based on changes to User Services |
943 | { | 1080 | /* |
944 | public GroupNoticeData noticeData = new GroupNoticeData(); | 1081 | UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID); |
945 | public UUID GroupID = UUID.Zero; | 1082 | if (userAccount == null) |
946 | public string Message = string.Empty; | 1083 | { |
947 | public byte[] BinaryBucket = new byte[0]; | 1084 | // This should be impossible. If I've been passed a reference to a client |
1085 | // that client should be registered with the UserService. So something | ||
1086 | // is horribly wrong somewhere. | ||
1087 | |||
1088 | m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID); | ||
1089 | |||
1090 | } | ||
1091 | else if (userProfile is ForeignUserProfileData) | ||
1092 | { | ||
1093 | // They aren't from around here | ||
1094 | ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile; | ||
1095 | UserServiceURL = fupd.UserServerURI; | ||
1096 | SessionID = fupd.CurrentAgent.SessionID; | ||
1097 | |||
1098 | } | ||
1099 | else | ||
1100 | { | ||
1101 | // They're a local user, use this: | ||
1102 | UserServiceURL = m_commManager.NetworkServersInfo.UserURL; | ||
1103 | SessionID = userProfile.CurrentAgent.SessionID; | ||
1104 | } | ||
1105 | */ | ||
1106 | } | ||
1107 | |||
948 | } | 1108 | } |
949 | } | 1109 | } |
950 | 1110 | ||