back port groups changes

0.6.9-post-fixes
unknown 2010-04-08 16:14:02 -07:00 committed by Melanie
parent 6fdd5bfe2d
commit 8a69070b51
7 changed files with 1815 additions and 446 deletions

View File

@ -28,41 +28,30 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using log4net; using log4net;
using Mono.Addins; using Mono.Addins;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.CoreModules.Framework.EventQueue; using OpenSim.Region.CoreModules.Framework.EventQueue;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps; using Caps = OpenSim.Framework.Capabilities.Caps;
namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class GroupsMessagingModule : ISharedRegionModule public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private List<Scene> m_sceneList = new List<Scene>(); private List<Scene> m_sceneList = new List<Scene>();
private IMessageTransferModule m_msgTransferModule = null; private IMessageTransferModule m_msgTransferModule = null;
private IGroupsModule m_groupsModule = null; private IGroupsServicesConnector m_groupData = null;
// TODO: Move this off to the Groups Server
public Dictionary<Guid, List<Guid>> m_agentsInGroupSession = new Dictionary<Guid, List<Guid>>();
public Dictionary<Guid, List<Guid>> m_agentsDroppedSession = new Dictionary<Guid, List<Guid>>();
// Config Options // Config Options
private bool m_groupMessagingEnabled = false; private bool m_groupMessagingEnabled = false;
@ -108,8 +97,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
// NoOp if (!m_groupMessagingEnabled)
return;
scene.RegisterModuleInterface<IGroupsMessagingModule>(this);
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
if (!m_groupMessagingEnabled) if (!m_groupMessagingEnabled)
@ -117,12 +110,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
m_groupsModule = scene.RequestModuleInterface<IGroupsModule>(); m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>();
// No groups module, no groups messaging // No groups module, no groups messaging
if (m_groupsModule == null) if (m_groupData == null)
{ {
m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsModule, GroupsMessagingModule is now disabled."); m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled.");
Close(); Close();
m_groupMessagingEnabled = false; m_groupMessagingEnabled = false;
return; return;
@ -144,7 +137,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
scene.EventManager.OnNewClient += OnNewClient; scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -172,7 +164,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
m_sceneList.Clear(); m_sceneList.Clear();
m_groupsModule = null; m_groupData = null;
m_msgTransferModule = null; m_msgTransferModule = null;
} }
@ -197,6 +189,75 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
#endregion #endregion
/// <summary>
/// Not really needed, but does confirm that the group exists.
/// </summary>
public bool StartGroupChatSession(UUID agentID, UUID groupID)
{
if (m_debugEnabled)
m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
if (groupInfo != null)
{
return true;
}
else
{
return false;
}
}
public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
{
if (m_debugEnabled)
m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID))
{
if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
{
// Don't deliver messages to people who have dropped this session
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
continue;
}
// Copy Message
GridInstantMessage msg = new GridInstantMessage();
msg.imSessionID = groupID.Guid;
msg.fromAgentName = im.fromAgentName;
msg.message = im.message;
msg.dialog = im.dialog;
msg.offline = im.offline;
msg.ParentEstateID = im.ParentEstateID;
msg.Position = im.Position;
msg.RegionID = im.RegionID;
msg.binaryBucket = im.binaryBucket;
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
msg.fromAgentID = im.fromAgentID;
msg.fromGroup = true;
msg.toAgentID = member.AgentID.Guid;
IClientAPI client = GetActiveClient(member.AgentID);
if (client == null)
{
// If they're not local, forward across the grid
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
}
else
{
// Deliver locally, directly
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
ProcessMessageFromGroupSession(msg);
}
}
}
#region SimGridEventHandlers #region SimGridEventHandlers
private void OnNewClient(IClientAPI client) private void OnNewClient(IClientAPI client)
@ -236,42 +297,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
UUID AgentID = new UUID(msg.fromAgentID);
UUID GroupID = new UUID(msg.imSessionID);
switch (msg.dialog) switch (msg.dialog)
{ {
case (byte)InstantMessageDialog.SessionAdd: case (byte)InstantMessageDialog.SessionAdd:
AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID); m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
break; break;
case (byte)InstantMessageDialog.SessionDrop: case (byte)InstantMessageDialog.SessionDrop:
RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID); m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
break; break;
case (byte)InstantMessageDialog.SessionSend: case (byte)InstantMessageDialog.SessionSend:
if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)
&& !m_agentsDroppedSession.ContainsKey(msg.toAgentID)) && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
)
{ {
// Agent not in session and hasn't dropped from session // Agent not in session and hasn't dropped from session
// Add them to the session for now, and Invite them // Add them to the session for now, and Invite them
AddAgentToGroupSession(msg.toAgentID, msg.imSessionID); m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
UUID toAgentID = new UUID(msg.toAgentID); UUID toAgentID = new UUID(msg.toAgentID);
IClientAPI activeClient = GetActiveClient(toAgentID); IClientAPI activeClient = GetActiveClient(toAgentID);
if (activeClient != null) if (activeClient != null)
{ {
UUID groupID = new UUID(msg.fromAgentID); GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
if (groupInfo != null) if (groupInfo != null)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
// Force? open the group session dialog??? // Force? open the group session dialog???
// and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
eq.ChatterboxInvitation( eq.ChatterboxInvitation(
groupID GroupID
, groupInfo.GroupName , groupInfo.GroupName
, new UUID(msg.fromAgentID) , new UUID(msg.fromAgentID)
, msg.message, new UUID(msg.toAgentID) , msg.message
, new UUID(msg.toAgentID)
, msg.fromAgentName , msg.fromAgentName
, msg.dialog , msg.dialog
, msg.timestamp , msg.timestamp
@ -285,7 +350,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
); );
eq.ChatterBoxSessionAgentListUpdates( eq.ChatterBoxSessionAgentListUpdates(
new UUID(groupID) new UUID(GroupID)
, new UUID(msg.fromAgentID) , new UUID(msg.fromAgentID)
, new UUID(msg.toAgentID) , new UUID(msg.toAgentID)
, false //canVoiceChat , false //canVoiceChat
@ -295,7 +360,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
} }
} }
else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID)) else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
{ {
// User hasn't dropped, so they're in the session, // User hasn't dropped, so they're in the session,
// maybe we should deliver it. // maybe we should deliver it.
@ -321,56 +386,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
#endregion #endregion
#region ClientEvents #region ClientEvents
private void RemoveAgentFromGroupSession(Guid agentID, Guid sessionID)
{
if (m_agentsInGroupSession.ContainsKey(sessionID))
{
// If in session remove
if (m_agentsInGroupSession[sessionID].Contains(agentID))
{
m_agentsInGroupSession[sessionID].Remove(agentID);
}
// If not in dropped list, add
if (!m_agentsDroppedSession[sessionID].Contains(agentID))
{
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Dropped {1} from session {0}", sessionID, agentID);
m_agentsDroppedSession[sessionID].Add(agentID);
}
}
}
private void AddAgentToGroupSession(Guid agentID, Guid sessionID)
{
// Add Session Status if it doesn't exist for this session
CreateGroupSessionTracking(sessionID);
// If nessesary, remove from dropped list
if (m_agentsDroppedSession[sessionID].Contains(agentID))
{
m_agentsDroppedSession[sessionID].Remove(agentID);
}
// If nessesary, add to in session list
if (!m_agentsInGroupSession[sessionID].Contains(agentID))
{
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Added {1} to session {0}", sessionID, agentID);
m_agentsInGroupSession[sessionID].Add(agentID);
}
}
private void CreateGroupSessionTracking(Guid sessionID)
{
if (!m_agentsInGroupSession.ContainsKey(sessionID))
{
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Creating session tracking for : {0}", sessionID);
m_agentsInGroupSession.Add(sessionID, new List<Guid>());
m_agentsDroppedSession.Add(sessionID, new List<Guid>());
}
}
private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
{ {
if (m_debugEnabled) if (m_debugEnabled)
@ -383,21 +400,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// Start group IM session // Start group IM session
if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
{ {
UUID groupID = new UUID(im.toAgentID); if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
UUID GroupID = new UUID(im.imSessionID);
UUID AgentID = new UUID(im.fromAgentID);
GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
if (groupInfo != null) if (groupInfo != null)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
AddAgentToGroupSession(im.fromAgentID, im.imSessionID); ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID);
IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
queue.ChatterBoxSessionAgentListUpdates( queue.ChatterBoxSessionAgentListUpdates(
new UUID(groupID) GroupID
, new UUID(im.fromAgentID) , AgentID
, new UUID(im.toAgentID) , new UUID(im.toAgentID)
, false //canVoiceChat , false //canVoiceChat
, false //isModerator , false //isModerator
@ -409,64 +428,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// Send a message from locally connected client to a group // Send a message from locally connected client to a group
if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
{ {
UUID groupID = new UUID(im.toAgentID); UUID GroupID = new UUID(im.imSessionID);
UUID AgentID = new UUID(im.fromAgentID);
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); if (m_debugEnabled)
m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
SendMessageToGroup(im, groupID); //If this agent is sending a message, then they want to be in the session
m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
SendMessageToGroup(im, GroupID);
} }
} }
#endregion #endregion
private void SendMessageToGroup(GridInstantMessage im, UUID groupID)
{
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID))
{
if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid))
{
// Don't deliver messages to people who have dropped this session
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
continue;
}
// Copy Message
GridInstantMessage msg = new GridInstantMessage();
msg.imSessionID = im.imSessionID;
msg.fromAgentName = im.fromAgentName;
msg.message = im.message;
msg.dialog = im.dialog;
msg.offline = im.offline;
msg.ParentEstateID = im.ParentEstateID;
msg.Position = im.Position;
msg.RegionID = im.RegionID;
msg.binaryBucket = im.binaryBucket;
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
// Updat Pertinate fields to make it a "group message"
msg.fromAgentID = groupID.Guid;
msg.fromGroup = true;
msg.toAgentID = member.AgentID.Guid;
IClientAPI client = GetActiveClient(member.AgentID);
if (client == null)
{
// If they're not local, forward across the grid
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
}
else
{
// Deliver locally, directly
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
ProcessMessageFromGroupSession(msg);
}
}
}
void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@ -518,6 +494,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
/// </summary> /// </summary>
private IClientAPI GetActiveClient(UUID agentID) private IClientAPI GetActiveClient(UUID agentID)
{ {
if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
IClientAPI child = null; IClientAPI child = null;
// Try root avatar first // Try root avatar first
@ -529,16 +507,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
ScenePresence user = (ScenePresence)scene.Entities[agentID]; ScenePresence user = (ScenePresence)scene.Entities[agentID];
if (!user.IsChildAgent) if (!user.IsChildAgent)
{ {
if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name);
return user.ControllingClient; return user.ControllingClient;
} }
else else
{ {
if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name);
child = user.ControllingClient; child = user.ControllingClient;
} }
} }
} }
// If we didn't find a root, then just return whichever child we found, or null if none // If we didn't find a root, then just return whichever child we found, or null if none
if (child == null)
{
if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
}
else
{
if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
}
return child; return child;
} }

View File

@ -87,16 +87,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private IGroupsServicesConnector m_groupData = null; private IGroupsServicesConnector m_groupData = null;
class GroupRequestIDInfo
{
public GroupRequestID RequestID = new GroupRequestID();
public DateTime LastUsedTMStamp = DateTime.MinValue;
}
private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
private Timer m_clientRequestIDFlushTimer;
// Configuration settings // Configuration settings
private bool m_groupsEnabled = false; private bool m_groupsEnabled = false;
private bool m_groupNoticesEnabled = true; private bool m_groupNoticesEnabled = true;
@ -133,30 +123,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
m_clientRequestIDFlushTimer = new Timer();
m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
m_clientRequestIDFlushTimer.AutoReset = true;
m_clientRequestIDFlushTimer.Start();
}
}
void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
{
lock (m_clientRequestIDInfo)
{
TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
foreach (UUID key in CurrentKeys)
{
if (m_clientRequestIDInfo.ContainsKey(key))
{
if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
{
m_clientRequestIDInfo.Remove(key);
}
}
}
} }
} }
@ -234,8 +200,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return; return;
if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
m_clientRequestIDFlushTimer.Stop();
} }
public Type ReplaceableInterface public Type ReplaceableInterface
@ -272,14 +236,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// Used for Notices and Group Invites/Accept/Reject // Used for Notices and Group Invites/Accept/Reject
client.OnInstantMessage += OnInstantMessage; client.OnInstantMessage += OnInstantMessage;
lock (m_clientRequestIDInfo) // Send client thier groups information.
{
if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
{
// flush any old RequestID information
m_clientRequestIDInfo.Remove(client.AgentId);
}
}
SendAgentGroupDataUpdate(client, client.AgentId); SendAgentGroupDataUpdate(client, client.AgentId);
} }
@ -287,7 +244,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
//GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
} }
@ -331,10 +288,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
{ {
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); 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);
// TODO: This currently ignores pretty much all the query flags including Mature and sort order // TODO: This currently ignores pretty much all the query flags including Mature and sort order
remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray());
} }
} }
@ -348,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
string activeGroupName = string.Empty; string activeGroupName = string.Empty;
ulong activeGroupPowers = (ulong)GroupPowers.None; ulong activeGroupPowers = (ulong)GroupPowers.None;
GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
if (membership != null) if (membership != null)
{ {
activeGroupID = membership.GroupID; activeGroupID = membership.GroupID;
@ -367,7 +327,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
string GroupName; string GroupName;
GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
if (group != null) if (group != null)
{ {
GroupName = group.GroupName; GroupName = group.GroupName;
@ -388,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
{ {
UUID inviteID = new UUID(im.imSessionID); UUID inviteID = new UUID(im.imSessionID);
GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
if (inviteInfo == null) if (inviteInfo == null)
{ {
@ -407,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
// and the sessionid is the role // and the sessionid is the role
m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
GridInstantMessage msg = new GridInstantMessage(); GridInstantMessage msg = new GridInstantMessage();
msg.imSessionID = UUID.Zero.Guid; msg.imSessionID = UUID.Zero.Guid;
@ -431,14 +391,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// TODO: If the inviter is still online, they need an agent dataupdate // TODO: If the inviter is still online, they need an agent dataupdate
// and maybe group membership updates for the invitee // and maybe group membership updates for the invitee
m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
} }
// Reject // Reject
if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
} }
} }
} }
@ -452,7 +412,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
UUID GroupID = new UUID(im.toAgentID); UUID GroupID = new UUID(im.toAgentID);
if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null)
{ {
UUID NoticeID = UUID.Random(); UUID NoticeID = UUID.Random();
string Subject = im.message.Substring(0, im.message.IndexOf('|')); string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@ -496,14 +456,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
if (OnNewGroupNotice != null) if (OnNewGroupNotice != null)
{ {
OnNewGroupNotice(GroupID, NoticeID); OnNewGroupNotice(GroupID, NoticeID);
} }
// Send notice out to everyone that wants notices // Send notice out to everyone that wants notices
foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID))
{ {
if (m_debugEnabled) if (m_debugEnabled)
{ {
@ -549,7 +509,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
IClientAPI ejectee = GetActiveClient(ejecteeID); IClientAPI ejectee = GetActiveClient(ejecteeID);
if (ejectee != null) if (ejectee != null)
{ {
UUID groupID = new UUID(im.fromAgentID); UUID groupID = new UUID(im.imSessionID);
ejectee.SendAgentDropGroup(groupID); ejectee.SendAgentDropGroup(groupID);
} }
} }
@ -588,20 +548,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public GroupRecord GetGroupRecord(UUID GroupID) public GroupRecord GetGroupRecord(UUID GroupID)
{ {
return m_groupData.GetGroupRecord(null, GroupID, null); return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
}
public GroupRecord GetGroupRecord(string name)
{
return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
} }
public void ActivateGroup(IClientAPI remoteClient, UUID groupID) public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
// Changing active group changes title, active powers, all kinds of things // Changing active group changes title, active powers, all kinds of things
// anyone who is in any region that can see this client, should probably be // anyone who is in any region that can see this client, should probably be
// updated with new group info. At a minimum, they should get ScenePresence // updated with new group info. At a minimum, they should get ScenePresence
// updated with new title. // updated with new title.
UpdateAllClientsWithGroupInfo(remoteClient.AgentId); UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
} }
/// <summary> /// <summary>
@ -611,10 +576,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
GroupRequestID grID = GetClientGroupRequestID(remoteClient);
List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
List<GroupTitlesData> titles = new List<GroupTitlesData>(); List<GroupTitlesData> titles = new List<GroupTitlesData>();
foreach (GroupRolesData role in agentRoles) foreach (GroupRolesData role in agentRoles)
@ -636,8 +600,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); if (m_debugEnabled)
{
foreach (GroupMembersData member in data)
{
m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
}
}
return data; return data;
@ -647,21 +618,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID);
return data; return data;
} }
public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID);
if (m_debugEnabled)
{
foreach (GroupRoleMembersData member in data)
{
m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
}
}
return data; return data;
} }
public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID)
@ -670,17 +645,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
GroupProfileData profile = new GroupProfileData(); GroupProfileData profile = new GroupProfileData();
GroupRequestID grID = GetClientGroupRequestID(remoteClient);
GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
if (groupInfo != null) if (groupInfo != null)
{ {
profile.AllowPublish = groupInfo.AllowPublish; profile.AllowPublish = groupInfo.AllowPublish;
profile.Charter = groupInfo.Charter; profile.Charter = groupInfo.Charter;
profile.FounderID = groupInfo.FounderID; profile.FounderID = groupInfo.FounderID;
profile.GroupID = groupID; profile.GroupID = groupID;
profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count;
profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count;
profile.InsigniaID = groupInfo.GroupPicture; profile.InsigniaID = groupInfo.GroupPicture;
profile.MaturePublish = groupInfo.MaturePublish; profile.MaturePublish = groupInfo.MaturePublish;
profile.MembershipFee = groupInfo.MembershipFee; profile.MembershipFee = groupInfo.MembershipFee;
@ -691,7 +665,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
profile.ShowInList = groupInfo.ShowInList; profile.ShowInList = groupInfo.ShowInList;
} }
GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
if (memberInfo != null) if (memberInfo != null)
{ {
profile.MemberTitle = memberInfo.GroupTitle; profile.MemberTitle = memberInfo.GroupTitle;
@ -705,40 +679,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray();
} }
public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled)
m_log.DebugFormat(
"[GROUPS]: {0} called with groupID={1}, agentID={2}",
System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
return m_groupData.GetAgentGroupMembership(null, agentID, groupID); return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
} }
public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
// TODO: Security Check? // Note: Permissions checking for modification rights is handled by the Groups Server/Service
m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
} }
public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
{ {
// TODO: Security Check? // Note: Permissions checking for modification rights is handled by the Groups Server/Service
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile);
} }
public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
GroupRequestID grID = GetClientGroupRequestID(remoteClient); if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null)
if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
{ {
remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
return UUID.Zero; return UUID.Zero;
@ -754,12 +728,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
money.ApplyGroupCreationCharge(remoteClient.AgentId); money.ApplyGroupCreationCharge(remoteClient.AgentId);
} }
UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
// Update the founder with new group information. // Update the founder with new group information.
SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
return groupID; return groupID;
} }
@ -770,7 +744,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// ToDo: check if agent is a member of group and is allowed to see notices? // ToDo: check if agent is a member of group and is allowed to see notices?
return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray();
} }
/// <summary> /// <summary>
@ -780,7 +754,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID);
if (membership != null) if (membership != null)
{ {
return membership.GroupTitle; return membership.GroupTitle;
@ -795,13 +769,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID);
// TODO: Not sure what all is needed here, but if the active group role change is for the group // TODO: Not sure what all is needed here, but if the active group role change is for the group
// the client currently has set active, then we need to do a scene presence update too // the client currently has set active, then we need to do a scene presence update too
// if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID) // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
UpdateAllClientsWithGroupInfo(remoteClient.AgentId); UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
} }
@ -811,16 +785,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// Security Checks are handled in the Groups Service. // Security Checks are handled in the Groups Service.
GroupRequestID grID = GetClientGroupRequestID(remoteClient);
switch ((OpenMetaverse.GroupRoleUpdate)updateType) switch ((OpenMetaverse.GroupRoleUpdate)updateType)
{ {
case OpenMetaverse.GroupRoleUpdate.Create: case OpenMetaverse.GroupRoleUpdate.Create:
m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers);
break; break;
case OpenMetaverse.GroupRoleUpdate.Delete: case OpenMetaverse.GroupRoleUpdate.Delete:
m_groupData.RemoveGroupRole(grID, groupID, roleID); m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID);
break; break;
case OpenMetaverse.GroupRoleUpdate.UpdateAll: case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@ -831,7 +803,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
GroupPowers gp = (GroupPowers)powers; GroupPowers gp = (GroupPowers)powers;
m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
} }
m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers);
break; break;
case OpenMetaverse.GroupRoleUpdate.NoUpdate: case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@ -842,7 +814,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
// TODO: This update really should send out updates for everyone in the role that just got changed. // TODO: This update really should send out updates for everyone in the role that just got changed.
SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
} }
public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@ -850,18 +822,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
// Todo: Security check // Todo: Security check
GroupRequestID grID = GetClientGroupRequestID(remoteClient);
switch (changes) switch (changes)
{ {
case 0: case 0:
// Add // Add
m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
break; break;
case 1: case 1:
// Remove // Remove
m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
break; break;
default: default:
@ -870,25 +840,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
// TODO: This update really should send out updates for everyone in the role that just got changed. // TODO: This update really should send out updates for everyone in the role that just got changed.
SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
} }
public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
GroupRequestID grID = GetClientGroupRequestID(remoteClient); GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID);
GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
if (data != null) if (data != null)
{ {
GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null);
GridInstantMessage msg = new GridInstantMessage(); GridInstantMessage msg = new GridInstantMessage();
msg.imSessionID = UUID.Zero.Guid; msg.imSessionID = UUID.Zero.Guid;
msg.fromAgentID = data.GroupID.Guid; msg.fromAgentID = data.GroupID.Guid;
msg.toAgentID = remoteClient.AgentId.Guid; msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
msg.message = data.noticeData.Subject + "|" + data.Message; msg.message = data.noticeData.Subject + "|" + data.Message;
@ -900,7 +868,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.RegionID = UUID.Zero.Guid; msg.RegionID = UUID.Zero.Guid;
msg.binaryBucket = data.BinaryBucket; msg.binaryBucket = data.BinaryBucket;
OutgoingInstantMessage(msg, remoteClient.AgentId); OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
} }
} }
@ -920,7 +888,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.Position = Vector3.Zero; msg.Position = Vector3.Zero;
msg.RegionID = UUID.Zero.Guid; msg.RegionID = UUID.Zero.Guid;
GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID);
if (info != null) if (info != null)
{ {
msg.fromAgentID = info.GroupID.Guid; msg.fromAgentID = info.GroupID.Guid;
@ -947,7 +915,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
// Send agent information about his groups // Send agent information about his groups
SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
} }
public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@ -955,19 +923,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
// Should check to see if OpenEnrollment, or if there's an outstanding invitation // Should check to see if OpenEnrollment, or if there's an outstanding invitation
m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
remoteClient.SendJoinGroupReply(groupID, true); remoteClient.SendJoinGroupReply(groupID, true);
// Should this send updates to everyone in the group? // Should this send updates to everyone in the group?
SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
} }
public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
remoteClient.SendLeaveGroupReply(groupID, true); remoteClient.SendLeaveGroupReply(groupID, true);
@ -975,21 +943,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// SL sends out notifcations to the group messaging session that the person has left // SL sends out notifcations to the group messaging session that the person has left
// Should this also update everyone who is in the group? // Should this also update everyone who is in the group?
SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
} }
public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
GroupRequestID grID = GetClientGroupRequestID(remoteClient);
// Todo: Security check? // Todo: Security check?
m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID);
remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true);
GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
if ((groupInfo == null) || (userProfile == null)) if ((groupInfo == null) || (userProfile == null))
@ -1002,7 +969,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
GridInstantMessage msg = new GridInstantMessage(); GridInstantMessage msg = new GridInstantMessage();
msg.imSessionID = UUID.Zero.Guid; msg.imSessionID = UUID.Zero.Guid;
msg.fromAgentID = remoteClient.AgentId.Guid; msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
// msg.fromAgentID = info.GroupID; // msg.fromAgentID = info.GroupID;
msg.toAgentID = ejecteeID.Guid; msg.toAgentID = ejecteeID.Guid;
//msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@ -1028,8 +995,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg = new GridInstantMessage(); msg = new GridInstantMessage();
msg.imSessionID = UUID.Zero.Guid; msg.imSessionID = UUID.Zero.Guid;
msg.fromAgentID = remoteClient.AgentId.Guid; msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
msg.toAgentID = remoteClient.AgentId.Guid; msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
msg.timestamp = 0; msg.timestamp = 0;
msg.fromAgentName = remoteClient.Name; msg.fromAgentName = remoteClient.Name;
if (userProfile != null) if (userProfile != null)
@ -1047,7 +1014,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.Position = Vector3.Zero; msg.Position = Vector3.Zero;
msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
msg.binaryBucket = new byte[0]; msg.binaryBucket = new byte[0];
OutgoingInstantMessage(msg, remoteClient.AgentId); OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
// SL sends out messages to everyone in the group // SL sends out messages to everyone in the group
@ -1061,13 +1028,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// Todo: Security check, probably also want to send some kind of notification // Todo: Security check, probably also want to send some kind of notification
UUID InviteID = UUID.Random(); UUID InviteID = UUID.Random();
GroupRequestID grid = GetClientGroupRequestID(remoteClient);
m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID);
// Check to see if the invite went through, if it did not then it's possible // Check to see if the invite went through, if it did not then it's possible
// the remoteClient did not validate or did not have permission to invite. // the remoteClient did not validate or did not have permission to invite.
GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID);
if (inviteInfo != null) if (inviteInfo != null)
{ {
@ -1079,7 +1045,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.imSessionID = inviteUUID; msg.imSessionID = inviteUUID;
// msg.fromAgentID = remoteClient.AgentId.Guid; // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
msg.fromAgentID = groupID.Guid; msg.fromAgentID = groupID.Guid;
msg.toAgentID = invitedAgentID.Guid; msg.toAgentID = invitedAgentID.Guid;
//msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@ -1132,57 +1098,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return child; return child;
} }
private GroupRequestID GetClientGroupRequestID(IClientAPI client)
{
if (client == null)
{
return new GroupRequestID();
}
lock (m_clientRequestIDInfo)
{
if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
{
GroupRequestIDInfo info = new GroupRequestIDInfo();
info.RequestID.AgentID = client.AgentId;
info.RequestID.SessionID = client.SessionId;
UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
if (userProfile == null)
{
// This should be impossible. If I've been passed a reference to a client
// that client should be registered with the UserService. So something
// is horribly wrong somewhere.
m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);
// Default to local user service and hope for the best?
info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
}
else if (userProfile is ForeignUserProfileData)
{
// They aren't from around here
ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
info.RequestID.UserServiceURL = fupd.UserServerURI;
}
else
{
// They're a local user, use this:
info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
}
m_clientRequestIDInfo.Add(client.AgentId, info);
}
m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
return m_clientRequestIDInfo[client.AgentId].RequestID;
}
// Unreachable code!
// return new GroupRequestID();
}
/// <summary> /// <summary>
/// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
/// </summary> /// </summary>
@ -1231,6 +1146,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
llDataStruct.Add("GroupData", GroupData); llDataStruct.Add("GroupData", GroupData);
llDataStruct.Add("NewGroupData", NewGroupData); llDataStruct.Add("NewGroupData", NewGroupData);
if (m_debugEnabled)
{
m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
}
IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
if (queue != null) if (queue != null)
@ -1308,7 +1228,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
/// <returns></returns> /// <returns></returns>
private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
{ {
List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID);
GroupMembershipData[] membershipArray; GroupMembershipData[] membershipArray;
if (requestingClient.AgentId != dataForAgentID) if (requestingClient.AgentId != dataForAgentID)
@ -1330,7 +1250,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
foreach (GroupMembershipData membership in membershipArray) foreach (GroupMembershipData membership in membershipArray)
{ {
m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers);
} }
} }
@ -1389,6 +1309,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
#endregion #endregion
private UUID GetRequestingAgentID(IClientAPI client)
{
UUID requestingAgentID = UUID.Zero;
if (client != null)
{
requestingAgentID = client.AgentId;
}
return requestingAgentID;
}
} }
public class GroupNoticeInfo
{
public GroupNoticeData noticeData = new GroupNoticeData();
public UUID GroupID = UUID.Zero;
public string Message = string.Empty;
public byte[] BinaryBucket = new byte[0];
}
} }

View File

@ -36,42 +36,47 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
interface IGroupsServicesConnector interface IGroupsServicesConnector
{ {
UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID);
void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); void UpdateGroup(UUID RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName); GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName);
List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search); List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search);
List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID); List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID);
void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); void AddGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); void UpdateGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID); void RemoveGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID);
List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID); List<GroupRolesData> GetGroupRoles(UUID RequestingAgentID, UUID GroupID);
List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID); List<GroupRoleMembersData> GetGroupRoleMembers(UUID RequestingAgentID, UUID GroupID);
void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); void AddAgentToGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); void RemoveAgentFromGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID); void AddAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID);
GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); GroupInviteInfo GetAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID);
void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); void RemoveAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID);
void AddAgentToGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
void RemoveAgentFromGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
List<GroupRolesData> GetAgentGroupRoles(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); void SetAgentActiveGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); GroupMembershipData GetAgentActiveMembership(UUID RequestingAgentID, UUID AgentID);
List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID);
void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID); void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile);
void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID);
GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID); void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID); GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID);
List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID);
void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); void ResetAgentGroupChatSessions(UUID agentID);
GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID); bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID);
List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID); bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID);
void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID);
void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID);
} }
public class GroupInviteInfo public class GroupInviteInfo
@ -81,11 +86,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public UUID AgentID = UUID.Zero; public UUID AgentID = UUID.Zero;
public UUID InviteID = UUID.Zero; public UUID InviteID = UUID.Zero;
} }
public class GroupRequestID
{
public UUID AgentID = UUID.Zero;
public string UserServiceURL = string.Empty;
public UUID SessionID = UUID.Zero;
}
} }

View File

@ -47,9 +47,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
{ {
private static readonly ILog m_log = private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
GroupPowers.Accountable | GroupPowers.Accountable |
@ -61,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private bool m_connectorEnabled = false; private bool m_connectorEnabled = false;
private string m_serviceURL = string.Empty; private string m_groupsServerURI = string.Empty;
private bool m_disableKeepAlive = false; private bool m_disableKeepAlive = false;
@ -69,6 +67,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private string m_groupWriteKey = string.Empty; private string m_groupWriteKey = string.Empty;
// Used to track which agents are have dropped from a group chat session
// Should be reset per agent, on logon
// TODO: move this to Flotsam XmlRpc Service
// SessionID, List<AgentID>
private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
#region IRegionModuleBase Members #region IRegionModuleBase Members
public string Name public string Name
@ -104,11 +110,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
if ((m_serviceURL == null) || if ((m_groupsServerURI == null) ||
(m_serviceURL == string.Empty)) (m_groupsServerURI == string.Empty))
{ {
m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
m_connectorEnabled = false; m_connectorEnabled = false;
return; return;
} }
@ -118,6 +124,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
// If we got all the config options we need, lets start'er'up // If we got all the config options we need, lets start'er'up
m_connectorEnabled = true; m_connectorEnabled = true;
} }
@ -131,14 +140,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
{ {
if (m_connectorEnabled) if (m_connectorEnabled)
{
scene.RegisterModuleInterface<IGroupsServicesConnector>(this); scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
} }
}
public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
{ {
if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
{
scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
} }
}
public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
{ {
@ -157,14 +170,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
#endregion #endregion
#region IGroupsServicesConnector Members #region IGroupsServicesConnector Members
/// <summary> /// <summary>
/// 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. /// 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.
/// </summary> /// </summary>
public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
int membershipFee, bool openEnrollment, bool allowPublish, int membershipFee, bool openEnrollment, bool allowPublish,
bool maturePublish, UUID founderID) bool maturePublish, UUID founderID)
{ {
@ -236,7 +247,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param);
if (respData.Contains("error")) if (respData.Contains("error"))
{ {
@ -248,7 +259,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return UUID.Parse((string)respData["GroupID"]); return UUID.Parse((string)respData["GroupID"]);
} }
public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
UUID insigniaID, int membershipFee, bool openEnrollment, UUID insigniaID, int membershipFee, bool openEnrollment,
bool allowPublish, bool maturePublish) bool allowPublish, bool maturePublish)
{ {
@ -262,10 +273,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
param["AllowPublish"] = allowPublish == true ? 1 : 0; param["AllowPublish"] = allowPublish == true ? 1 : 0;
param["MaturePublish"] = maturePublish == true ? 1 : 0; param["MaturePublish"] = maturePublish == true ? 1 : 0;
XmlRpcCall(requestID, "groups.updateGroup", param); XmlRpcCall(requestingAgentID, "groups.updateGroup", param);
} }
public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
string title, ulong powers) string title, ulong powers)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
@ -276,19 +287,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
param["Title"] = title; param["Title"] = title;
param["Powers"] = powers.ToString(); param["Powers"] = powers.ToString();
XmlRpcCall(requestID, "groups.addRoleToGroup", param); XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param);
} }
public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID) public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["GroupID"] = groupID.ToString(); param["GroupID"] = groupID.ToString();
param["RoleID"] = roleID.ToString(); param["RoleID"] = roleID.ToString();
XmlRpcCall(requestID, "groups.removeRoleFromGroup", param); XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param);
} }
public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
string title, ulong powers) string title, ulong powers)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
@ -308,10 +319,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
param["Powers"] = powers.ToString(); param["Powers"] = powers.ToString();
XmlRpcCall(requestID, "groups.updateGroupRole", param); XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param);
} }
public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName) public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
if (GroupID != UUID.Zero) if (GroupID != UUID.Zero)
@ -323,7 +334,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
param["Name"] = GroupName.ToString(); param["Name"] = GroupName.ToString();
} }
Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
if (respData.Contains("error")) if (respData.Contains("error"))
{ {
@ -334,12 +345,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID) public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
if (respData.Contains("error")) if (respData.Contains("error"))
{ {
@ -347,38 +358,35 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return new GroupProfileData(); return new GroupProfileData();
} }
GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID); GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
return MemberGroupProfile; return MemberGroupProfile;
} }
public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
XmlRpcCall(requestID, "groups.setAgentActiveGroup", param); XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param);
} }
public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
param["SelectedRoleID"] = RoleID.ToString(); param["SelectedRoleID"] = RoleID.ToString();
XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
} }
public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
@ -386,11 +394,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
param["AcceptNotices"] = AcceptNotices ? "1" : "0"; param["AcceptNotices"] = AcceptNotices ? "1" : "0";
param["ListInProfile"] = ListInProfile ? "1" : "0"; param["ListInProfile"] = ListInProfile ? "1" : "0";
XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
} }
public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["InviteID"] = inviteID.ToString(); param["InviteID"] = inviteID.ToString();
@ -398,16 +406,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
param["RoleID"] = roleID.ToString(); param["RoleID"] = roleID.ToString();
param["GroupID"] = groupID.ToString(); param["GroupID"] = groupID.ToString();
XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param); XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param);
} }
public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["InviteID"] = inviteID.ToString(); param["InviteID"] = inviteID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param);
if (respData.Contains("error")) if (respData.Contains("error"))
{ {
@ -423,60 +431,59 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return inviteInfo; return inviteInfo;
} }
public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["InviteID"] = inviteID.ToString(); param["InviteID"] = inviteID.ToString();
XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param); XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param);
} }
public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
param["RoleID"] = RoleID.ToString(); param["RoleID"] = RoleID.ToString();
XmlRpcCall(requestID, "groups.addAgentToGroup", param); XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param);
} }
public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
XmlRpcCall(requestID, "groups.removeAgentFromGroup", param); XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param);
} }
public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
param["RoleID"] = RoleID.ToString(); param["RoleID"] = RoleID.ToString();
XmlRpcCall(requestID, "groups.addAgentToGroupRole", param); XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param);
} }
public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
param["RoleID"] = RoleID.ToString(); param["RoleID"] = RoleID.ToString();
XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param); XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param);
} }
public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["Search"] = search; param["Search"] = search;
Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param);
List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
@ -498,13 +505,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return findings; return findings;
} }
public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID) public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param);
if (respData.Contains("error")) if (respData.Contains("error"))
{ {
@ -516,12 +523,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return data; return data;
} }
public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID) public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param);
if (respData.Contains("error")) if (respData.Contains("error"))
{ {
@ -531,13 +538,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return HashTableToGroupMembershipData(respData); return HashTableToGroupMembershipData(respData);
} }
public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param);
List<GroupMembershipData> memberships = new List<GroupMembershipData>(); List<GroupMembershipData> memberships = new List<GroupMembershipData>();
@ -552,13 +558,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return memberships; return memberships;
} }
public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID) public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["AgentID"] = AgentID.ToString(); param["AgentID"] = AgentID.ToString();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param);
List<GroupRolesData> Roles = new List<GroupRolesData>(); List<GroupRolesData> Roles = new List<GroupRolesData>();
@ -584,12 +590,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID) public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param);
List<GroupRolesData> Roles = new List<GroupRolesData>(); List<GroupRolesData> Roles = new List<GroupRolesData>();
@ -617,12 +623,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param);
List<GroupMembersData> members = new List<GroupMembersData>(); List<GroupMembersData> members = new List<GroupMembersData>();
@ -650,12 +656,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID) public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param);
List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
@ -674,12 +680,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return members; return members;
} }
public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID) public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["GroupID"] = GroupID.ToString(); param["GroupID"] = GroupID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param);
List<GroupNoticeData> values = new List<GroupNoticeData>(); List<GroupNoticeData> values = new List<GroupNoticeData>();
@ -701,12 +707,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return values; return values;
} }
public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID) public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
{ {
Hashtable param = new Hashtable(); Hashtable param = new Hashtable();
param["NoticeID"] = noticeID.ToString(); param["NoticeID"] = noticeID.ToString();
Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param);
if (respData.Contains("error")) if (respData.Contains("error"))
@ -732,7 +738,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return data; return data;
} }
public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
{ {
string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
@ -745,7 +751,70 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
param["BinaryBucket"] = binBucket; param["BinaryBucket"] = binBucket;
param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
XmlRpcCall(requestID, "groups.addGroupNotice", param); XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
}
#endregion
#region GroupSessionTracking
public void ResetAgentGroupChatSessions(UUID agentID)
{
foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
{
agentList.Remove(agentID);
}
}
public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
{
// If we're tracking this group, and we can find them in the tracking, then they've been invited
return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
&& m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
}
public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
{
// If we're tracking drops for this group,
// and we find them, well... then they've dropped
return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
&& m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
}
public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
{
if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
{
// If not in dropped list, add
if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
{
m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
}
}
}
public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
{
// Add Session Status if it doesn't exist for this session
CreateGroupChatSessionTracking(groupID);
// If nessesary, remove from dropped list
if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
{
m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
}
}
private void CreateGroupChatSessionTracking(UUID groupID)
{
if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
{
m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
}
} }
#endregion #endregion
@ -778,7 +847,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
{ {
GroupRecord group = new GroupRecord(); GroupRecord group = new GroupRecord();
group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
group.GroupName = groupProfile["Name"].ToString(); group.GroupName = groupProfile["Name"].ToString();
@ -797,6 +865,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return group; return group;
} }
private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
{ {
GroupMembershipData data = new GroupMembershipData(); GroupMembershipData data = new GroupMembershipData();
@ -829,6 +898,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
data.MembershipFee = int.Parse((string)respData["MembershipFee"]); data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
data.ShowInList = ((string)respData["ShowInList"] == "1"); data.ShowInList = ((string)respData["ShowInList"] == "1");
return data; return data;
} }
@ -837,15 +907,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
/// <summary> /// <summary>
/// Encapsulate the XmlRpc call to standardize security and error handling. /// Encapsulate the XmlRpc call to standardize security and error handling.
/// </summary> /// </summary>
private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
{ {
if (requestID == null) string UserService;
{ UUID SessionID;
requestID = new GroupRequestID(); GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
} param.Add("requestingAgentID", requestingAgentID.ToString());
param.Add("RequestingAgentID", requestID.AgentID.ToString()); param.Add("RequestingAgentUserService", UserService);
param.Add("RequestingAgentUserService", requestID.UserServiceURL); param.Add("RequestingSessionID", SessionID.ToString());
param.Add("RequestingSessionID", requestID.SessionID.ToString());
param.Add("ReadKey", m_groupReadKey); param.Add("ReadKey", m_groupReadKey);
@ -862,7 +931,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
try try
{ {
resp = req.Send(m_serviceURL, 10000); resp = req.Send(m_groupsServerURI, 10000);
} }
catch (Exception e) catch (Exception e)
{ {
@ -937,14 +1006,48 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
/// <summary>
/// Group Request Tokens are an attempt to allow the groups service to authenticate
/// requests.
/// TODO: This broke after the big grid refactor, either find a better way, or discard this
/// </summary>
/// <param name="client"></param>
/// <returns></returns>
private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
{
UserServiceURL = "";
SessionID = UUID.Zero;
// Need to rework this based on changes to User Services
/*
UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
if (userAccount == null)
{
// This should be impossible. If I've been passed a reference to a client
// that client should be registered with the UserService. So something
// is horribly wrong somewhere.
m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
}
else if (userProfile is ForeignUserProfileData)
{
// They aren't from around here
ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
UserServiceURL = fupd.UserServerURI;
SessionID = fupd.CurrentAgent.SessionID;
}
else
{
// They're a local user, use this:
UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
SessionID = userProfile.CurrentAgent.SessionID;
}
*/
} }
public class GroupNoticeInfo
{
public GroupNoticeData noticeData = new GroupNoticeData();
public UUID GroupID = UUID.Zero;
public string Message = string.Empty;
public byte[] BinaryBucket = new byte[0];
} }
} }

View File

@ -1302,10 +1302,18 @@
;MessagingModule = GroupsMessagingModule ;MessagingModule = GroupsMessagingModule
;MessagingEnabled = true ;MessagingEnabled = true
; Service connector to Groups Service [Select One] ; Service connector to Groups Service [Select One] ServicesConnectorModule
; XmlRpc Service Connector to the Flotsam XmlRpc Groups Service Implementation
; Simian Grid Service for Groups
;ServicesConnectorModule = SimianGroupsServicesConnector
;GroupsServerURI = http://mygridserver.com:82/Grid/
; XmlRpc Service Connector to the Flotsam XmlRpc Groups Service settings
;ServicesConnectorModule = XmlRpcGroupsServicesConnector ;ServicesConnectorModule = XmlRpcGroupsServicesConnector
;XmlRpcServiceURL = http://yourxmlrpcserver.com/xmlrpc.php ;GroupsServerURI = http://yourxmlrpcserver.com/xmlrpc.php
; XmlRpc Service Settings
;XmlRpcServiceReadKey = 1234 ;XmlRpcServiceReadKey = 1234
;XmlRpcServiceWriteKey = 1234 ;XmlRpcServiceWriteKey = 1234

View File

@ -20,6 +20,12 @@
; change this to your grid-wide grid server ; change this to your grid-wide grid server
; ;
GridServerURI = "http://mygridserver.com:8003" GridServerURI = "http://mygridserver.com:8003"
[Groups]
;
; change this to your grid-wide groups server
;
GroupsServerURI = "http://mygridserver.com:82/Grid/"
[Modules] [Modules]
;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.