29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
37 using OpenSim.Data.Null;
38 using OpenSim.Framework;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
43 namespace OpenSim.Tests.Common
45 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule")]
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 get {
return "MockGroupsServicesConnector"; }
57 public Type ReplaceableInterface
72 m_log.DebugFormat(
"[MOCK GROUPS SERVICES CONNECTOR]: Adding to region {0}", scene.RegionInfo.RegionName);
88 public UUID CreateGroup(UUID requestingAgentID,
string name,
string charter,
bool showInList, UUID insigniaID,
89 int membershipFee,
bool openEnrollment,
bool allowPublish,
90 bool maturePublish, UUID founderID)
94 groupID = UUID.Random(),
95 ownerRoleID =
UUID.Random(),
98 showInList = showInList,
99 insigniaID = insigniaID,
100 membershipFee = membershipFee,
101 openEnrollment = openEnrollment,
102 allowPublish = allowPublish,
103 maturePublish = maturePublish,
104 founderID = founderID,
106 ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers
109 if (m_data.StoreGroup(group))
111 m_log.DebugFormat(
"[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID);
112 return group.groupID;
116 m_log.ErrorFormat(
"[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name);
121 public void UpdateGroup(UUID requestingAgentID, UUID groupID,
string charter,
bool showInList,
122 UUID insigniaID,
int membershipFee,
bool openEnrollment,
123 bool allowPublish,
bool maturePublish)
127 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
128 string title, ulong powers)
136 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
137 string title, ulong powers)
141 private XGroup GetXGroup(UUID groupID,
string name)
143 XGroup group = m_data.GetGroup(groupID);
147 m_log.DebugFormat(
"[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID);
155 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
158 XGroup xg = GetXGroup(groupID, groupName);
165 GroupID = xg.groupID,
167 AllowPublish = xg.allowPublish,
168 MaturePublish = xg.maturePublish,
169 Charter = xg.charter,
170 FounderID = xg.founderID,
172 MembershipFee = xg.membershipFee,
173 OpenEnrollment = xg.openEnrollment,
174 OwnerRoleID = xg.ownerRoleID,
175 ShowInList = xg.showInList
194 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID,
bool acceptNotices,
bool listInProfile)
197 "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}",
198 requestingAgentID, agentID, groupID, acceptNotices, listInProfile);
200 XGroup group = GetXGroup(groupID, null);
206 if (!group.members.TryGetValue(agentID, out xgm))
209 xgm.acceptNotices = acceptNotices;
210 xgm.listInProfile = listInProfile;
212 m_data.StoreGroup(group);
228 public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
231 "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}",
232 requestingAgentID, agentID, groupID, roleID);
234 XGroup group = GetXGroup(groupID, null);
246 group.members[agentID] = groupMember;
248 m_data.StoreGroup(group);
263 public List<DirGroupsReplyData>
FindGroups(UUID requestingAgentID,
string search)
280 return new List<GroupMembershipData>();
288 public List<GroupRolesData>
GetGroupRoles(UUID requestingAgentID, UUID GroupID)
296 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupMembers, requestingAgentID {0}, groupID {1}",
297 requestingAgentID, groupID);
299 List<GroupMembersData> groupMembers =
new List<GroupMembersData>();
301 XGroup group = GetXGroup(groupID, null);
309 gmd.AgentID = xgm.agentID;
310 gmd.IsOwner = group.founderID == gmd.AgentID;
311 gmd.AcceptNotices = xgm.acceptNotices;
312 gmd.ListInProfile = xgm.listInProfile;
314 groupMembers.Add(gmd);
327 XGroup group = GetXGroup(groupID, null);
332 List<GroupNoticeData> notices =
new List<GroupNoticeData>();
338 NoticeID = notice.noticeID,
339 Timestamp = notice.timestamp,
340 FromName = notice.fromName,
341 Subject = notice.subject,
342 HasAttachment = notice.hasAttachment,
355 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupNotices, requestingAgentID {0}, noticeID {1}",
356 requestingAgentID, noticeID);
359 Dictionary<UUID, XGroup> groups = m_data.GetGroups();
361 foreach (
XGroup group
in groups.Values)
363 if (group.
notices.ContainsKey(noticeID))
368 gni.GroupID = n.groupID;
369 gni.Message = n.message;
370 gni.BinaryBucket = n.binaryBucket;
371 gni.noticeData.NoticeID = n.noticeID;
372 gni.noticeData.Timestamp = n.timestamp;
373 gni.noticeData.FromName = n.fromName;
374 gni.noticeData.Subject = n.subject;
375 gni.noticeData.HasAttachment = n.hasAttachment;
376 gni.noticeData.AssetType = (byte)n.
assetType;
385 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID,
string fromName,
string subject,
string message, byte[] binaryBucket)
388 "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}",
389 requestingAgentID, groupID, noticeID, fromName, subject, message, binaryBucket.Length);
391 XGroup group = GetXGroup(groupID, null);
403 timestamp = (uint)Util.UnixTimeSinceEpoch(),
404 hasAttachment =
false,
406 binaryBucket = binaryBucket
409 group.notices[noticeID] = groupNotice;
411 m_data.StoreGroup(group);
const GroupPowers DefaultEveryonePowers
void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
List< GroupNoticeData > GetGroupNotices(UUID requestingAgentID, UUID groupID)
GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
Get the group record.
List< DirGroupsReplyData > FindGroups(UUID requestingAgentID, string search)
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID)
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
Get information about a specific group to which the user belongs.
Dictionary< UUID, XGroupMember > members
void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
Dictionary< UUID, XGroupNotice > notices
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
List< GroupMembershipData > GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
Get information about the groups to which a user belongs.
void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
List< GroupMembersData > GetGroupMembers(UUID requestingAgentID, UUID groupID)
Early stub interface for groups data, not final.
List< GroupRoleMembersData > GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
List< GroupRolesData > GetGroupRoles(UUID requestingAgentID, UUID GroupID)
void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
List< GroupRolesData > GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
void ResetAgentGroupChatSessions(UUID agentID)
void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)