From 71918eeab4beee076d53469e8d19addab49135b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 7 Mar 2014 01:04:40 +0000 Subject: Add regression test for sending group notices via xmlrpc groups connector. --- OpenSim/Data/IXGroupData.cs | 59 +++++++++++++++++++++++++++++++++---- OpenSim/Data/Null/NullXGroupData.cs | 34 ++++++++++----------- 2 files changed, 68 insertions(+), 25 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/IXGroupData.cs b/OpenSim/Data/IXGroupData.cs index 2965e8c..e5821ef 100644 --- a/OpenSim/Data/IXGroupData.cs +++ b/OpenSim/Data/IXGroupData.cs @@ -48,9 +48,57 @@ namespace OpenSim.Data public ulong everyonePowers; public ulong ownersPowers; + public Dictionary members = new Dictionary(); + public Dictionary notices = new Dictionary(); + public XGroup Clone() { - return (XGroup)MemberwiseClone(); + XGroup clone = (XGroup)MemberwiseClone(); + clone.members = new Dictionary(); + clone.notices = new Dictionary(); + + foreach (KeyValuePair kvp in members) + clone.members[kvp.Key] = kvp.Value.Clone(); + + foreach (KeyValuePair kvp in notices) + clone.notices[kvp.Key] = kvp.Value.Clone(); + + return clone; + } + } + + public class XGroupMember + { + public UUID agentID; + public UUID groupID; + public UUID roleID; + public bool acceptNotices = true; + public bool listInProfile = true; + + public XGroupMember Clone() + { + return (XGroupMember)MemberwiseClone(); + } + } + + public class XGroupNotice + { + public UUID groupID; + public UUID noticeID; + public uint timestamp; + public string fromName; + public string subject; + public string message; + public byte[] binaryBucket; + public bool hasAttachment; + public int assetType; + + public XGroupNotice Clone() + { + XGroupNotice clone = (XGroupNotice)MemberwiseClone(); + clone.binaryBucket = (byte[])binaryBucket.Clone(); + + return clone; } } @@ -58,14 +106,13 @@ namespace OpenSim.Data /// Early stub interface for groups data, not final. /// /// - /// Currently in-use only for regression test purposes. Needs to be filled out over time. + /// Currently in-use only for regression test purposes. /// public interface IXGroupData { bool StoreGroup(XGroup group); - XGroup[] GetGroups(string field, string val); - XGroup[] GetGroups(string[] fields, string[] vals); - bool DeleteGroups(string field, string val); - bool DeleteGroups(string[] fields, string[] vals); + XGroup GetGroup(UUID groupID); + Dictionary GetGroups(); + bool DeleteGroup(UUID groupID); } } \ No newline at end of file diff --git a/OpenSim/Data/Null/NullXGroupData.cs b/OpenSim/Data/Null/NullXGroupData.cs index 7a86b9f..3fa9451 100644 --- a/OpenSim/Data/Null/NullXGroupData.cs +++ b/OpenSim/Data/Null/NullXGroupData.cs @@ -38,7 +38,7 @@ using OpenSim.Data; namespace OpenSim.Data.Null { - public class NullXGroupData : NullGenericDataHandler, IXGroupData + public class NullXGroupData : IXGroupData { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -56,35 +56,31 @@ namespace OpenSim.Data.Null return true; } - public XGroup[] GetGroups(string field, string val) + public XGroup GetGroup(UUID groupID) { - return GetGroups(new string[] { field }, new string[] { val }); - } + XGroup group = null; - public XGroup[] GetGroups(string[] fields, string[] vals) - { lock (m_groups) - { - List origGroups = Get(fields, vals, m_groups.Values.ToList()); + m_groups.TryGetValue(groupID, out group); - return origGroups.Select(g => g.Clone()).ToArray(); - } + return group; } - public bool DeleteGroups(string field, string val) + public Dictionary GetGroups() { - return DeleteGroups(new string[] { field }, new string[] { val }); + Dictionary groupsClone = new Dictionary(); + + lock (m_groups) + foreach (XGroup group in m_groups.Values) + groupsClone[group.groupID] = group.Clone(); + + return groupsClone; } - public bool DeleteGroups(string[] fields, string[] vals) + public bool DeleteGroup(UUID groupID) { lock (m_groups) - { - XGroup[] groupsToDelete = GetGroups(fields, vals); - Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID)); - } - - return true; + return m_groups.Remove(groupID); } } } \ No newline at end of file -- cgit v1.1