* Allows both old and new OpenSim.ini params for the XmlRpc Groups Service Connector

* Fix problem with RequestingAgentID not being sent correctly to server resulting in failed xmlrpc calls

* Improved debug output
0.6.9-post-fixes
unknown 2010-05-14 15:06:13 -07:00 committed by Justin Clark-Casey (justincc)
parent 91cfce3758
commit 2c8d25a110
2 changed files with 80 additions and 31 deletions

View File

@ -342,7 +342,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
{ {
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_log.DebugFormat("[GROUPS]: remoteClient ({0}) im ({1})", remoteClient, im);
}
// Group invitations // Group invitations
if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
@ -481,7 +487,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (member.AcceptNotices) if (member.AcceptNotices)
{ {
// Build notice IIM // Build notice IIM
GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); GridInstantMessage msg = CreateGroupNoticeIM(GetRequestingAgentID(remoteClient), NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice);
msg.toAgentID = member.AgentID.Guid; msg.toAgentID = member.AgentID.Guid;
OutgoingInstantMessage(msg, member.AgentID); OutgoingInstantMessage(msg, member.AgentID);
@ -1024,12 +1030,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
{ {
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_log.DebugFormat("[GROUPS]: remoteClient({0}) groupID({0}) invitedAgentID({0}) roleID({0})", remoteClient, groupID, invitedAgentID, roleID);
}
// 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();
m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID); UUID requestingAgentID = GetRequestingAgentID(remoteClient);
if (requestingAgentID == UUID.Zero)
{
m_log.Error("[GROUPS] Group Invite Requires a valid requesting agent to be specified");
}
m_groupData.AddAgentToGroupInvite(requestingAgentID, 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.

View File

@ -40,6 +40,7 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
@ -66,6 +67,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private string m_groupReadKey = string.Empty; private string m_groupReadKey = string.Empty;
private string m_groupWriteKey = string.Empty; private string m_groupWriteKey = string.Empty;
private IUserService m_userService = null;
private CommunicationsManager m_commManager = null;
private bool m_debugEnabled = false;
// Used to track which agents are have dropped from a group chat session // Used to track which agents are have dropped from a group chat session
// Should be reset per agent, on logon // Should be reset per agent, on logon
@ -110,7 +116,7 @@ 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_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", groupsConfig.GetString("XmlRpcServiceURL", string.Empty));
if ((m_groupsServerURI == null) || if ((m_groupsServerURI == null) ||
(m_groupsServerURI == string.Empty)) (m_groupsServerURI == string.Empty))
{ {
@ -124,7 +130,7 @@ 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);
m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
// 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
@ -142,6 +148,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (m_connectorEnabled) if (m_connectorEnabled)
{ {
scene.RegisterModuleInterface<IGroupsServicesConnector>(this); scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
if (m_userService == null)
{
m_userService = scene.CommsManager.UserService;
m_commManager = scene.CommsManager;
}
} }
} }
@ -912,7 +924,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
string UserService; string UserService;
UUID SessionID; UUID SessionID;
GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
param.Add("requestingAgentID", requestingAgentID.ToString()); param.Add("RequestingAgentID", requestingAgentID.ToString());
param.Add("RequestingAgentUserService", UserService); param.Add("RequestingAgentUserService", UserService);
param.Add("RequestingSessionID", SessionID.ToString()); param.Add("RequestingSessionID", SessionID.ToString());
@ -920,6 +932,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
param.Add("ReadKey", m_groupReadKey); param.Add("ReadKey", m_groupReadKey);
param.Add("WriteKey", m_groupWriteKey); param.Add("WriteKey", m_groupWriteKey);
if (m_debugEnabled)
{
m_log.Debug("[XMLRPCGROUPDATA] XmlRpcCall Params:");
foreach (string key in param.Keys)
{
m_log.DebugFormat("[XMLRPCGROUPDATA] {0} : {1}", key, param[key]);
}
}
IList parameters = new ArrayList(); IList parameters = new ArrayList();
parameters.Add(param); parameters.Add(param);
@ -940,10 +960,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString()); m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None)) if ((req != null) && (req.RequestResponse != null))
{
foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
{ {
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine);
} }
}
foreach (string key in param.Keys) foreach (string key in param.Keys)
{ {
@ -955,12 +978,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return respData; return respData;
} }
if (resp.Value is Hashtable) if (resp.Value is Hashtable)
{ {
Hashtable respData = (Hashtable)resp.Value; Hashtable respData = (Hashtable)resp.Value;
if (respData.Contains("error") && !respData.Contains("succeed")) if (respData.Contains("error") && !respData.Contains("succeed"))
{ {
LogRespDataToConsoleError(respData); LogRespDataToConsoleError(function, respData);
} }
return respData; return respData;
@ -988,19 +1012,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return error; return error;
} }
private void LogRespDataToConsoleError(Hashtable respData) private void LogRespDataToConsoleError(string function, Hashtable respData)
{ {
m_log.ErrorFormat("[XMLRPCGROUPDATA]: Error data from XmlRpcGroups server method: {0}", function);
m_log.Error("[XMLRPCGROUPDATA]: Error:"); m_log.Error("[XMLRPCGROUPDATA]: Error:");
foreach (string key in respData.Keys) foreach (string key in respData.Keys)
{ {
m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key); m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key);
if ((respData != null) && (respData.ContainsKey(key)) && (respData[key]!=null))
{
string[] lines = respData[key].ToString().Split(new char[] { '\n' }); string[] lines = respData[key].ToString().Split(new char[] { '\n' });
foreach (string line in lines) foreach (string line in lines)
{ {
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line); m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line);
} }
}
else
{
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} : Empty/NULL", key);
}
} }
} }
@ -1015,23 +1047,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
/// <returns></returns> /// <returns></returns>
private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID) private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
{ {
UserServiceURL = ""; // Default to local grid user service
UserServiceURL = m_commManager.NetworkServersInfo.UserURL; ;
// if AgentID == UUID, there will be no SessionID. This will be true when
// the region is requesting information for region use (object permissions for example)
SessionID = UUID.Zero; SessionID = UUID.Zero;
// Attempt to get User Profile, for SessionID
UserProfileData userProfile = m_userService.GetUserProfile(AgentID);
// Need to rework this based on changes to User Services if ((userProfile != null) && (userProfile is ForeignUserProfileData))
/*
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 // They aren't from around here
ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile; ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
@ -1039,13 +1065,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
SessionID = fupd.CurrentAgent.SessionID; SessionID = fupd.CurrentAgent.SessionID;
} }
else else if (userProfile != null)
{ {
// They're a local user, use this: // Local, just use the local SessionID
UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
SessionID = userProfile.CurrentAgent.SessionID; SessionID = userProfile.CurrentAgent.SessionID;
} }
*/ else if (AgentID != UUID.Zero)
{
// 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("[XMLRPCGROUPDATA]: Could not find a UserServiceURL for {0}", AgentID);
}
} }
} }