aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs178
1 files changed, 153 insertions, 25 deletions
diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
index 3035cea..7f530d0 100644
--- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
+++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs
@@ -40,7 +40,7 @@ using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; 41using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
42 42
43namespace OpenSim.Tests.Common.Mock 43namespace OpenSim.Tests.Common
44{ 44{
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector 46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector
@@ -138,33 +138,28 @@ namespace OpenSim.Tests.Common.Mock
138 { 138 {
139 } 139 }
140 140
141 private XGroup GetXGroup(UUID groupID, string name)
142 {
143 XGroup group = m_data.GetGroup(groupID);
144
145
146 if (group == null)
147 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID);
148
149 return group;
150 }
151
141 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) 152 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
142 { 153 {
143 m_log.DebugFormat( 154 m_log.DebugFormat(
144 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", 155 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
145 groupID, groupName); 156 groupID, groupName);
146 157
147 XGroup[] groups; 158 XGroup xg = GetXGroup(groupID, groupName);
148 string field, val;
149 159
150 if (groupID != UUID.Zero) 160 if (xg == null)
151 {
152 field = "groupID";
153 val = groupID.ToString();
154 }
155 else
156 {
157 field = "name";
158 val = groupName;
159 }
160
161 groups = m_data.GetGroups(field, val);
162
163 if (groups.Length == 0)
164 return null; 161 return null;
165 162
166 XGroup xg = groups[0];
167
168 GroupRecord gr = new GroupRecord() 163 GroupRecord gr = new GroupRecord()
169 { 164 {
170 GroupID = xg.groupID, 165 GroupID = xg.groupID,
@@ -196,8 +191,25 @@ namespace OpenSim.Tests.Common.Mock
196 { 191 {
197 } 192 }
198 193
199 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 194 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
200 { 195 {
196 m_log.DebugFormat(
197 "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}",
198 requestingAgentID, agentID, groupID, acceptNotices, listInProfile);
199
200 XGroup group = GetXGroup(groupID, null);
201
202 if (group == null)
203 return;
204
205 XGroupMember xgm = null;
206 if (!group.members.TryGetValue(agentID, out xgm))
207 return;
208
209 xgm.acceptNotices = acceptNotices;
210 xgm.listInProfile = listInProfile;
211
212 m_data.StoreGroup(group);
201 } 213 }
202 214
203 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 215 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
@@ -213,8 +225,27 @@ namespace OpenSim.Tests.Common.Mock
213 { 225 {
214 } 226 }
215 227
216 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) 228 public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
217 { 229 {
230 m_log.DebugFormat(
231 "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}",
232 requestingAgentID, agentID, groupID, roleID);
233
234 XGroup group = GetXGroup(groupID, null);
235
236 if (group == null)
237 return;
238
239 XGroupMember groupMember = new XGroupMember()
240 {
241 agentID = agentID,
242 groupID = groupID,
243 roleID = roleID
244 };
245
246 group.members[agentID] = groupMember;
247
248 m_data.StoreGroup(group);
218 } 249 }
219 250
220 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) 251 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
@@ -259,9 +290,31 @@ namespace OpenSim.Tests.Common.Mock
259 return null; 290 return null;
260 } 291 }
261 292
262 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) 293 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID groupID)
263 { 294 {
264 return null; 295 m_log.DebugFormat(
296 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupMembers, requestingAgentID {0}, groupID {1}",
297 requestingAgentID, groupID);
298
299 List<GroupMembersData> groupMembers = new List<GroupMembersData>();
300
301 XGroup group = GetXGroup(groupID, null);
302
303 if (group == null)
304 return groupMembers;
305
306 foreach (XGroupMember xgm in group.members.Values)
307 {
308 GroupMembersData gmd = new GroupMembersData();
309 gmd.AgentID = xgm.agentID;
310 gmd.IsOwner = group.founderID == gmd.AgentID;
311 gmd.AcceptNotices = xgm.acceptNotices;
312 gmd.ListInProfile = xgm.listInProfile;
313
314 groupMembers.Add(gmd);
315 }
316
317 return groupMembers;
265 } 318 }
266 319
267 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) 320 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
@@ -269,18 +322,93 @@ namespace OpenSim.Tests.Common.Mock
269 return null; 322 return null;
270 } 323 }
271 324
272 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) 325 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID groupID)
273 { 326 {
274 return null; 327 XGroup group = GetXGroup(groupID, null);
328
329 if (group == null)
330 return null;
331
332 List<GroupNoticeData> notices = new List<GroupNoticeData>();
333
334 foreach (XGroupNotice notice in group.notices.Values)
335 {
336 GroupNoticeData gnd = new GroupNoticeData()
337 {
338 NoticeID = notice.noticeID,
339 Timestamp = notice.timestamp,
340 FromName = notice.fromName,
341 Subject = notice.subject,
342 HasAttachment = notice.hasAttachment,
343 AssetType = (byte)notice.assetType
344 };
345
346 notices.Add(gnd);
347 }
348
349 return notices;
275 } 350 }
276 351
277 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) 352 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
278 { 353 {
354 m_log.DebugFormat(
355 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupNotices, requestingAgentID {0}, noticeID {1}",
356 requestingAgentID, noticeID);
357
358 // Yes, not an efficient way to do it.
359 Dictionary<UUID, XGroup> groups = m_data.GetGroups();
360
361 foreach (XGroup group in groups.Values)
362 {
363 if (group.notices.ContainsKey(noticeID))
364 {
365 XGroupNotice n = group.notices[noticeID];
366
367 GroupNoticeInfo gni = new GroupNoticeInfo();
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;
377
378 return gni;
379 }
380 }
381
279 return null; 382 return null;
280 } 383 }
281 384
282 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) 385 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
283 { 386 {
387 m_log.DebugFormat(
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);
390
391 XGroup group = GetXGroup(groupID, null);
392
393 if (group == null)
394 return;
395
396 XGroupNotice groupNotice = new XGroupNotice()
397 {
398 groupID = groupID,
399 noticeID = noticeID,
400 fromName = fromName,
401 subject = subject,
402 message = message,
403 timestamp = (uint)Util.UnixTimeSinceEpoch(),
404 hasAttachment = false,
405 assetType = 0,
406 binaryBucket = binaryBucket
407 };
408
409 group.notices[noticeID] = groupNotice;
410
411 m_data.StoreGroup(group);
284 } 412 }
285 413
286 public void ResetAgentGroupChatSessions(UUID agentID) 414 public void ResetAgentGroupChatSessions(UUID agentID)