aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2010-05-05 16:03:20 +0100
committerMelanie2010-05-05 16:03:20 +0100
commit6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29 (patch)
treed7997b254fe40ff6a4e79e5b45c457e088fe5361
parentPatch from mcortez: Update groups, add ALPHA Siman grid connector for groups (diff)
downloadopensim-SC_OLD-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.zip
opensim-SC_OLD-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.tar.gz
opensim-SC_OLD-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.tar.bz2
opensim-SC_OLD-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.tar.xz
Revert "Patch from mcortez: Update groups, add ALPHA Siman grid connector for groups"
The patch was for 0.7 This reverts commit 608bb0dfefbbc97aded6d1357dd9d350053411fb.
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs341
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs62
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs1278
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs209
4 files changed, 320 insertions, 1570 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 6b942cb..8d32e66 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -43,8 +43,6 @@ using OpenSim.Region.CoreModules.Framework.EventQueue;
43using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
45 45
46using OpenSim.Services.Interfaces;
47
48using Caps = OpenSim.Framework.Capabilities.Caps; 46using Caps = OpenSim.Framework.Capabilities.Caps;
49using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; 47using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags;
50 48
@@ -89,6 +87,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
89 87
90 private IGroupsServicesConnector m_groupData = null; 88 private IGroupsServicesConnector m_groupData = null;
91 89
90 class GroupRequestIDInfo
91 {
92 public GroupRequestID RequestID = new GroupRequestID();
93 public DateTime LastUsedTMStamp = DateTime.MinValue;
94 }
95 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
96 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
97 private Timer m_clientRequestIDFlushTimer;
98
99
92 // Configuration settings 100 // Configuration settings
93 private bool m_groupsEnabled = false; 101 private bool m_groupsEnabled = false;
94 private bool m_groupNoticesEnabled = true; 102 private bool m_groupNoticesEnabled = true;
@@ -125,6 +133,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
125 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); 133 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
126 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 134 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
127 135
136 m_clientRequestIDFlushTimer = new Timer();
137 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
138 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
139 m_clientRequestIDFlushTimer.AutoReset = true;
140 m_clientRequestIDFlushTimer.Start();
141 }
142 }
143
144 void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
145 {
146 lock (m_clientRequestIDInfo)
147 {
148 TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
149 UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
150 foreach (UUID key in CurrentKeys)
151 {
152 if (m_clientRequestIDInfo.ContainsKey(key))
153 {
154 if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
155 {
156 m_clientRequestIDInfo.Remove(key);
157 }
158 }
159 }
128 } 160 }
129 } 161 }
130 162
@@ -202,6 +234,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
202 return; 234 return;
203 235
204 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 236 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
237
238 m_clientRequestIDFlushTimer.Stop();
205 } 239 }
206 240
207 public Type ReplaceableInterface 241 public Type ReplaceableInterface
@@ -238,7 +272,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
238 // Used for Notices and Group Invites/Accept/Reject 272 // Used for Notices and Group Invites/Accept/Reject
239 client.OnInstantMessage += OnInstantMessage; 273 client.OnInstantMessage += OnInstantMessage;
240 274
241 // Send client thier groups information. 275 lock (m_clientRequestIDInfo)
276 {
277 if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
278 {
279 // flush any old RequestID information
280 m_clientRequestIDInfo.Remove(client.AgentId);
281 }
282 }
242 SendAgentGroupDataUpdate(client, client.AgentId); 283 SendAgentGroupDataUpdate(client, client.AgentId);
243 } 284 }
244 285
@@ -246,7 +287,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
246 { 287 {
247 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 288 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
248 289
249 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray(); 290 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray();
250 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 291 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
251 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 292 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
252 } 293 }
@@ -285,17 +326,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
285 } 326 }
286 */ 327 */
287 328
329
288 void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) 330 void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
289 { 331 {
290 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) 332 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
291 { 333 {
292 if (m_debugEnabled) 334 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);
293 m_log.DebugFormat(
294 "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
295 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
296 335
297 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 336 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
298 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray()); 337 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray());
299 } 338 }
300 339
301 } 340 }
@@ -309,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
309 string activeGroupName = string.Empty; 348 string activeGroupName = string.Empty;
310 ulong activeGroupPowers = (ulong)GroupPowers.None; 349 ulong activeGroupPowers = (ulong)GroupPowers.None;
311 350
312 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID); 351 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID);
313 if (membership != null) 352 if (membership != null)
314 { 353 {
315 activeGroupID = membership.GroupID; 354 activeGroupID = membership.GroupID;
@@ -322,13 +361,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
322 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 361 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
323 } 362 }
324 363
325 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) 364 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient)
326 { 365 {
327 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 366 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
328 367
329 string GroupName; 368 string GroupName;
330 369
331 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null); 370 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null);
332 if (group != null) 371 if (group != null)
333 { 372 {
334 GroupName = group.GroupName; 373 GroupName = group.GroupName;
@@ -349,7 +388,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
349 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 388 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
350 { 389 {
351 UUID inviteID = new UUID(im.imSessionID); 390 UUID inviteID = new UUID(im.imSessionID);
352 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); 391 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
353 392
354 if (inviteInfo == null) 393 if (inviteInfo == null)
355 { 394 {
@@ -368,7 +407,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
368 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 407 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
369 408
370 // and the sessionid is the role 409 // and the sessionid is the role
371 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 410 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
372 411
373 GridInstantMessage msg = new GridInstantMessage(); 412 GridInstantMessage msg = new GridInstantMessage();
374 msg.imSessionID = UUID.Zero.Guid; 413 msg.imSessionID = UUID.Zero.Guid;
@@ -392,14 +431,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
392 // TODO: If the inviter is still online, they need an agent dataupdate 431 // TODO: If the inviter is still online, they need an agent dataupdate
393 // and maybe group membership updates for the invitee 432 // and maybe group membership updates for the invitee
394 433
395 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); 434 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
396 } 435 }
397 436
398 // Reject 437 // Reject
399 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 438 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
400 { 439 {
401 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 440 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
402 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); 441 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
403 } 442 }
404 } 443 }
405 } 444 }
@@ -413,7 +452,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
413 } 452 }
414 453
415 UUID GroupID = new UUID(im.toAgentID); 454 UUID GroupID = new UUID(im.toAgentID);
416 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null) 455 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null)
417 { 456 {
418 UUID NoticeID = UUID.Random(); 457 UUID NoticeID = UUID.Random();
419 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 458 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -457,21 +496,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
457 } 496 }
458 497
459 498
460 m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 499 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
461 if (OnNewGroupNotice != null) 500 if (OnNewGroupNotice != null)
462 { 501 {
463 OnNewGroupNotice(GroupID, NoticeID); 502 OnNewGroupNotice(GroupID, NoticeID);
464 } 503 }
465 504
466 // Send notice out to everyone that wants notices 505 // Send notice out to everyone that wants notices
467 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID)) 506 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID))
468 { 507 {
469 if (m_debugEnabled) 508 if (m_debugEnabled)
470 { 509 {
471 UserAccount targetUser = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, member.AgentID); 510 UserProfileData targetUserProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(member.AgentID);
472 if (targetUser != null) 511 if (targetUserProfile != null)
473 { 512 {
474 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices); 513 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUserProfile.Name, member.AcceptNotices);
475 } 514 }
476 else 515 else
477 { 516 {
@@ -549,25 +588,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
549 588
550 public GroupRecord GetGroupRecord(UUID GroupID) 589 public GroupRecord GetGroupRecord(UUID GroupID)
551 { 590 {
552 return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); 591 return m_groupData.GetGroupRecord(null, GroupID, null);
553 } 592 }
554 593
555 public GroupRecord GetGroupRecord(string name)
556 {
557 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
558 }
559
560 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 594 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
561 { 595 {
562 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 596 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
563 597
564 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 598 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
565 599
566 // Changing active group changes title, active powers, all kinds of things 600 // Changing active group changes title, active powers, all kinds of things
567 // anyone who is in any region that can see this client, should probably be 601 // anyone who is in any region that can see this client, should probably be
568 // updated with new group info. At a minimum, they should get ScenePresence 602 // updated with new group info. At a minimum, they should get ScenePresence
569 // updated with new title. 603 // updated with new title.
570 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); 604 UpdateAllClientsWithGroupInfo(remoteClient.AgentId);
571 } 605 }
572 606
573 /// <summary> 607 /// <summary>
@@ -577,9 +611,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
577 { 611 {
578 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 612 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
579 613
614 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
580 615
581 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 616 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID);
582 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 617 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
583 618
584 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 619 List<GroupTitlesData> titles = new List<GroupTitlesData>();
585 foreach (GroupRolesData role in agentRoles) 620 foreach (GroupRolesData role in agentRoles)
@@ -601,15 +636,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
601 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 636 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
602 { 637 {
603 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 638 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
604 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID); 639
605 640 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID);
606 if (m_debugEnabled)
607 {
608 foreach (GroupMembersData member in data)
609 {
610 m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
611 }
612 }
613 641
614 return data; 642 return data;
615 643
@@ -619,25 +647,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
619 { 647 {
620 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 648 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
621 649
622 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID); 650 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID);
623 651
624 return data; 652 return data;
653
625 } 654 }
626 655
627 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) 656 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID)
628 { 657 {
629 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 658 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
630 659
631 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID); 660 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID);
632 661
633 if (m_debugEnabled)
634 {
635 foreach (GroupRoleMembersData member in data)
636 {
637 m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
638 }
639 }
640 return data; 662 return data;
663
664
641 } 665 }
642 666
643 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) 667 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID)
@@ -646,16 +670,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
646 670
647 GroupProfileData profile = new GroupProfileData(); 671 GroupProfileData profile = new GroupProfileData();
648 672
673 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
649 674
650 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); 675 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null);
651 if (groupInfo != null) 676 if (groupInfo != null)
652 { 677 {
653 profile.AllowPublish = groupInfo.AllowPublish; 678 profile.AllowPublish = groupInfo.AllowPublish;
654 profile.Charter = groupInfo.Charter; 679 profile.Charter = groupInfo.Charter;
655 profile.FounderID = groupInfo.FounderID; 680 profile.FounderID = groupInfo.FounderID;
656 profile.GroupID = groupID; 681 profile.GroupID = groupID;
657 profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count; 682 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count;
658 profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count; 683 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count;
659 profile.InsigniaID = groupInfo.GroupPicture; 684 profile.InsigniaID = groupInfo.GroupPicture;
660 profile.MaturePublish = groupInfo.MaturePublish; 685 profile.MaturePublish = groupInfo.MaturePublish;
661 profile.MembershipFee = groupInfo.MembershipFee; 686 profile.MembershipFee = groupInfo.MembershipFee;
@@ -666,7 +691,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
666 profile.ShowInList = groupInfo.ShowInList; 691 profile.ShowInList = groupInfo.ShowInList;
667 } 692 }
668 693
669 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 694 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
670 if (memberInfo != null) 695 if (memberInfo != null)
671 { 696 {
672 profile.MemberTitle = memberInfo.GroupTitle; 697 profile.MemberTitle = memberInfo.GroupTitle;
@@ -680,46 +705,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
680 { 705 {
681 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 706 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
682 707
683 return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray(); 708 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray();
684 } 709 }
685 710
686 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 711 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
687 { 712 {
688 if (m_debugEnabled) 713 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
689 m_log.DebugFormat(
690 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
691 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
692 714
693 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID); 715 return m_groupData.GetAgentGroupMembership(null, agentID, groupID);
694 } 716 }
695 717
696 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 718 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
697 { 719 {
698 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 720 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
699 721
700 // Note: Permissions checking for modification rights is handled by the Groups Server/Service 722 // TODO: Security Check?
701 m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); 723
724 m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
702 } 725 }
703 726
704 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 727 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
705 { 728 {
706 // Note: Permissions checking for modification rights is handled by the Groups Server/Service 729 // TODO: Security Check?
707 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 730 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
708 731
709 m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile); 732 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile);
710 } 733 }
711 734
712 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 735 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
713 { 736 {
714 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 737 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
715 738
716 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null) 739 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
740
741 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
717 { 742 {
718 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 743 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
719 return UUID.Zero; 744 return UUID.Zero;
720 } 745 }
721 // is there is a money module present ? 746 // is there is a money module present ?
722 IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>(); 747 IMoneyModule money=remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
723 if (money != null) 748 if (money != null)
724 { 749 {
725 // do the transaction, that is if the agent has got sufficient funds 750 // do the transaction, that is if the agent has got sufficient funds
@@ -727,14 +752,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
727 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); 752 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
728 return UUID.Zero; 753 return UUID.Zero;
729 } 754 }
730 money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient)); 755 money.ApplyGroupCreationCharge(remoteClient.AgentId);
731 } 756 }
732 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient)); 757 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId);
733 758
734 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 759 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
735 760
736 // Update the founder with new group information. 761 // Update the founder with new group information.
737 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 762 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
738 763
739 return groupID; 764 return groupID;
740 } 765 }
@@ -745,7 +770,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
745 770
746 // ToDo: check if agent is a member of group and is allowed to see notices? 771 // ToDo: check if agent is a member of group and is allowed to see notices?
747 772
748 return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray(); 773 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray();
749 } 774 }
750 775
751 /// <summary> 776 /// <summary>
@@ -755,7 +780,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
755 { 780 {
756 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 781 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
757 782
758 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID); 783 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID);
759 if (membership != null) 784 if (membership != null)
760 { 785 {
761 return membership.GroupTitle; 786 return membership.GroupTitle;
@@ -770,13 +795,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
770 { 795 {
771 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 796 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
772 797
773 m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID); 798 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID);
774 799
775 // TODO: Not sure what all is needed here, but if the active group role change is for the group 800 // TODO: Not sure what all is needed here, but if the active group role change is for the group
776 // the client currently has set active, then we need to do a scene presence update too 801 // the client currently has set active, then we need to do a scene presence update too
777 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) 802 // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID)
778 803
779 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); 804 UpdateAllClientsWithGroupInfo(remoteClient.AgentId);
780 } 805 }
781 806
782 807
@@ -786,14 +811,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
786 811
787 // Security Checks are handled in the Groups Service. 812 // Security Checks are handled in the Groups Service.
788 813
814 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
815
789 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 816 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
790 { 817 {
791 case OpenMetaverse.GroupRoleUpdate.Create: 818 case OpenMetaverse.GroupRoleUpdate.Create:
792 m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers); 819 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers);
793 break; 820 break;
794 821
795 case OpenMetaverse.GroupRoleUpdate.Delete: 822 case OpenMetaverse.GroupRoleUpdate.Delete:
796 m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID); 823 m_groupData.RemoveGroupRole(grID, groupID, roleID);
797 break; 824 break;
798 825
799 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 826 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@@ -804,7 +831,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
804 GroupPowers gp = (GroupPowers)powers; 831 GroupPowers gp = (GroupPowers)powers;
805 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); 832 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
806 } 833 }
807 m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers); 834 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers);
808 break; 835 break;
809 836
810 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 837 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -815,7 +842,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
815 } 842 }
816 843
817 // TODO: This update really should send out updates for everyone in the role that just got changed. 844 // TODO: This update really should send out updates for everyone in the role that just got changed.
818 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 845 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
819 } 846 }
820 847
821 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 848 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -823,16 +850,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
823 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 850 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
824 // Todo: Security check 851 // Todo: Security check
825 852
853 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
854
826 switch (changes) 855 switch (changes)
827 { 856 {
828 case 0: 857 case 0:
829 // Add 858 // Add
830 m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); 859 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID);
831 860
832 break; 861 break;
833 case 1: 862 case 1:
834 // Remove 863 // Remove
835 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); 864 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID);
836 865
837 break; 866 break;
838 default: 867 default:
@@ -841,23 +870,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
841 } 870 }
842 871
843 // TODO: This update really should send out updates for everyone in the role that just got changed. 872 // TODO: This update really should send out updates for everyone in the role that just got changed.
844 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 873 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
845 } 874 }
846 875
847 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 876 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
848 { 877 {
849 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 878 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
850 879
851 GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID); 880 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
881
882 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
852 883
853 if (data != null) 884 if (data != null)
854 { 885 {
855 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); 886 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null);
856 887
857 GridInstantMessage msg = new GridInstantMessage(); 888 GridInstantMessage msg = new GridInstantMessage();
858 msg.imSessionID = UUID.Zero.Guid; 889 msg.imSessionID = UUID.Zero.Guid;
859 msg.fromAgentID = data.GroupID.Guid; 890 msg.fromAgentID = data.GroupID.Guid;
860 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; 891 msg.toAgentID = remoteClient.AgentId.Guid;
861 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 892 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
862 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; 893 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
863 msg.message = data.noticeData.Subject + "|" + data.Message; 894 msg.message = data.noticeData.Subject + "|" + data.Message;
@@ -869,7 +900,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
869 msg.RegionID = UUID.Zero.Guid; 900 msg.RegionID = UUID.Zero.Guid;
870 msg.binaryBucket = data.BinaryBucket; 901 msg.binaryBucket = data.BinaryBucket;
871 902
872 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); 903 OutgoingInstantMessage(msg, remoteClient.AgentId);
873 } 904 }
874 905
875 } 906 }
@@ -889,7 +920,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
889 msg.Position = Vector3.Zero; 920 msg.Position = Vector3.Zero;
890 msg.RegionID = UUID.Zero.Guid; 921 msg.RegionID = UUID.Zero.Guid;
891 922
892 GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID); 923 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID);
893 if (info != null) 924 if (info != null)
894 { 925 {
895 msg.fromAgentID = info.GroupID.Guid; 926 msg.fromAgentID = info.GroupID.Guid;
@@ -916,7 +947,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
916 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 947 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
917 948
918 // Send agent information about his groups 949 // Send agent information about his groups
919 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 950 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
920 } 951 }
921 952
922 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 953 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -924,19 +955,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
924 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 955 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
925 956
926 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 957 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
927 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero); 958 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero);
928 959
929 remoteClient.SendJoinGroupReply(groupID, true); 960 remoteClient.SendJoinGroupReply(groupID, true);
930 961
931 // Should this send updates to everyone in the group? 962 // Should this send updates to everyone in the group?
932 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 963 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
933 } 964 }
934 965
935 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 966 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
936 { 967 {
937 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 968 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
938 969
939 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 970 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
940 971
941 remoteClient.SendLeaveGroupReply(groupID, true); 972 remoteClient.SendLeaveGroupReply(groupID, true);
942 973
@@ -944,32 +975,34 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
944 975
945 // SL sends out notifcations to the group messaging session that the person has left 976 // SL sends out notifcations to the group messaging session that the person has left
946 // Should this also update everyone who is in the group? 977 // Should this also update everyone who is in the group?
947 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 978 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
948 } 979 }
949 980
950 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 981 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
951 { 982 {
952 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 983 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
953 984
985 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
954 986
955 // Todo: Security check? 987 // Todo: Security check?
956 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID); 988 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID);
957 989
958 remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true); 990 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true);
959 991
960 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); 992 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
993 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
961 994
962 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); 995 if ((groupInfo == null) || (userProfile == null))
963 if ((groupInfo == null) || (account == null))
964 { 996 {
965 return; 997 return;
966 } 998 }
999
967 1000
968 // Send Message to Ejectee 1001 // Send Message to Ejectee
969 GridInstantMessage msg = new GridInstantMessage(); 1002 GridInstantMessage msg = new GridInstantMessage();
970 1003
971 msg.imSessionID = UUID.Zero.Guid; 1004 msg.imSessionID = UUID.Zero.Guid;
972 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; 1005 msg.fromAgentID = remoteClient.AgentId.Guid;
973 // msg.fromAgentID = info.GroupID; 1006 // msg.fromAgentID = info.GroupID;
974 msg.toAgentID = ejecteeID.Guid; 1007 msg.toAgentID = ejecteeID.Guid;
975 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1008 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -995,13 +1028,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
995 1028
996 msg = new GridInstantMessage(); 1029 msg = new GridInstantMessage();
997 msg.imSessionID = UUID.Zero.Guid; 1030 msg.imSessionID = UUID.Zero.Guid;
998 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; 1031 msg.fromAgentID = remoteClient.AgentId.Guid;
999 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; 1032 msg.toAgentID = remoteClient.AgentId.Guid;
1000 msg.timestamp = 0; 1033 msg.timestamp = 0;
1001 msg.fromAgentName = remoteClient.Name; 1034 msg.fromAgentName = remoteClient.Name;
1002 if (account != null) 1035 if (userProfile != null)
1003 { 1036 {
1004 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName); 1037 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, userProfile.Name);
1005 } 1038 }
1006 else 1039 else
1007 { 1040 {
@@ -1014,7 +1047,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1014 msg.Position = Vector3.Zero; 1047 msg.Position = Vector3.Zero;
1015 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; 1048 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
1016 msg.binaryBucket = new byte[0]; 1049 msg.binaryBucket = new byte[0];
1017 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); 1050 OutgoingInstantMessage(msg, remoteClient.AgentId);
1018 1051
1019 1052
1020 // SL sends out messages to everyone in the group 1053 // SL sends out messages to everyone in the group
@@ -1028,12 +1061,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1028 1061
1029 // Todo: Security check, probably also want to send some kind of notification 1062 // Todo: Security check, probably also want to send some kind of notification
1030 UUID InviteID = UUID.Random(); 1063 UUID InviteID = UUID.Random();
1064 GroupRequestID grid = GetClientGroupRequestID(remoteClient);
1031 1065
1032 m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID); 1066 m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID);
1033 1067
1034 // Check to see if the invite went through, if it did not then it's possible 1068 // Check to see if the invite went through, if it did not then it's possible
1035 // the remoteClient did not validate or did not have permission to invite. 1069 // the remoteClient did not validate or did not have permission to invite.
1036 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID); 1070 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID);
1037 1071
1038 if (inviteInfo != null) 1072 if (inviteInfo != null)
1039 { 1073 {
@@ -1045,7 +1079,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1045 1079
1046 msg.imSessionID = inviteUUID; 1080 msg.imSessionID = inviteUUID;
1047 1081
1048 // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; 1082 // msg.fromAgentID = remoteClient.AgentId.Guid;
1049 msg.fromAgentID = groupID.Guid; 1083 msg.fromAgentID = groupID.Guid;
1050 msg.toAgentID = invitedAgentID.Guid; 1084 msg.toAgentID = invitedAgentID.Guid;
1051 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1085 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1098,6 +1132,57 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1098 return child; 1132 return child;
1099 } 1133 }
1100 1134
1135 private GroupRequestID GetClientGroupRequestID(IClientAPI client)
1136 {
1137 if (client == null)
1138 {
1139 return new GroupRequestID();
1140 }
1141
1142 lock (m_clientRequestIDInfo)
1143 {
1144 if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
1145 {
1146 GroupRequestIDInfo info = new GroupRequestIDInfo();
1147 info.RequestID.AgentID = client.AgentId;
1148 info.RequestID.SessionID = client.SessionId;
1149
1150 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1151 if (userProfile == null)
1152 {
1153 // This should be impossible. If I've been passed a reference to a client
1154 // that client should be registered with the UserService. So something
1155 // is horribly wrong somewhere.
1156
1157 m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);
1158
1159 // Default to local user service and hope for the best?
1160 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1161
1162 }
1163 else if (userProfile is ForeignUserProfileData)
1164 {
1165 // They aren't from around here
1166 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1167 info.RequestID.UserServiceURL = fupd.UserServerURI;
1168 }
1169 else
1170 {
1171 // They're a local user, use this:
1172 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1173 }
1174
1175 m_clientRequestIDInfo.Add(client.AgentId, info);
1176 }
1177
1178 m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
1179
1180 return m_clientRequestIDInfo[client.AgentId].RequestID;
1181 }
1182// Unreachable code!
1183// return new GroupRequestID();
1184 }
1185
1101 /// <summary> 1186 /// <summary>
1102 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1187 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1103 /// </summary> 1188 /// </summary>
@@ -1116,7 +1201,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1116 1201
1117 foreach (GroupMembershipData membership in data) 1202 foreach (GroupMembershipData membership in data)
1118 { 1203 {
1119 if (GetRequestingAgentID(remoteClient) != dataForAgentID) 1204 if (remoteClient.AgentId != dataForAgentID)
1120 { 1205 {
1121 if (!membership.ListInProfile) 1206 if (!membership.ListInProfile)
1122 { 1207 {
@@ -1144,18 +1229,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1144 OSDMap llDataStruct = new OSDMap(3); 1229 OSDMap llDataStruct = new OSDMap(3);
1145 llDataStruct.Add("AgentData", AgentData); 1230 llDataStruct.Add("AgentData", AgentData);
1146 llDataStruct.Add("GroupData", GroupData); 1231 llDataStruct.Add("GroupData", GroupData);
1147 llDataStruct.Add("NewGroupData", NewGroupData); 1232 llDataStruct.Add("NewGroupData", NewGroupData);
1148
1149 if (m_debugEnabled)
1150 {
1151 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1152 }
1153 1233
1154 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 1234 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1155 1235
1156 if (queue != null) 1236 if (queue != null)
1157 { 1237 {
1158 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); 1238 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId);
1159 } 1239 }
1160 1240
1161 } 1241 }
@@ -1228,7 +1308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1228 /// <returns></returns> 1308 /// <returns></returns>
1229 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) 1309 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
1230 { 1310 {
1231 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID); 1311 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID);
1232 GroupMembershipData[] membershipArray; 1312 GroupMembershipData[] membershipArray;
1233 1313
1234 if (requestingClient.AgentId != dataForAgentID) 1314 if (requestingClient.AgentId != dataForAgentID)
@@ -1250,7 +1330,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1250 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1330 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
1251 foreach (GroupMembershipData membership in membershipArray) 1331 foreach (GroupMembershipData membership in membershipArray)
1252 { 1332 {
1253 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers); 1333 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle);
1254 } 1334 }
1255 } 1335 }
1256 1336
@@ -1262,12 +1342,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1262 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1342 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1263 1343
1264 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1344 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1265 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); 1345 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(dataForAgentID);
1266 string firstname, lastname; 1346 string firstname, lastname;
1267 if (account != null) 1347 if (userProfile != null)
1268 { 1348 {
1269 firstname = account.FirstName; 1349 firstname = userProfile.FirstName;
1270 lastname = account.LastName; 1350 lastname = userProfile.SurName;
1271 } 1351 }
1272 else 1352 else
1273 { 1353 {
@@ -1308,24 +1388,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1308 // 1388 //
1309 } 1389 }
1310 1390
1311 #endregion 1391 #endregion
1312
1313 private UUID GetRequestingAgentID(IClientAPI client)
1314 {
1315 UUID requestingAgentID = UUID.Zero;
1316 if (client != null)
1317 {
1318 requestingAgentID = client.AgentId;
1319 }
1320 return requestingAgentID;
1321 }
1322 } 1392 }
1323 1393
1324 public class GroupNoticeInfo
1325 {
1326 public GroupNoticeData noticeData = new GroupNoticeData();
1327 public UUID GroupID = UUID.Zero;
1328 public string Message = string.Empty;
1329 public byte[] BinaryBucket = new byte[0];
1330 }
1331} 1394}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 6487967..9e0fa2d 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -36,41 +36,42 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
36{ 36{
37 interface IGroupsServicesConnector 37 interface IGroupsServicesConnector
38 { 38 {
39 UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); 39 UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID);
40 void UpdateGroup(UUID RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); 40 void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
41 GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName); 41 GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName);
42 List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search); 42 List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search);
43 List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID); 43 List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID);
44 44
45 void AddGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); 45 void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
46 void UpdateGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); 46 void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
47 void RemoveGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID); 47 void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID);
48 List<GroupRolesData> GetGroupRoles(UUID RequestingAgentID, UUID GroupID); 48 List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID);
49 List<GroupRoleMembersData> GetGroupRoleMembers(UUID RequestingAgentID, UUID GroupID); 49 List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID);
50 50
51 void AddAgentToGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); 51 void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
52 void RemoveAgentFromGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID); 52 void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID);
53 53
54 void AddAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID); 54 void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID);
55 GroupInviteInfo GetAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID); 55 GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID);
56 void RemoveAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID); 56 void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID);
57 57
58 void AddAgentToGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
59 void RemoveAgentFromGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
60 List<GroupRolesData> GetAgentGroupRoles(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
61 58
62 void SetAgentActiveGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID); 59 void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
63 GroupMembershipData GetAgentActiveMembership(UUID RequestingAgentID, UUID AgentID); 60 void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
61 List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID);
64 62
65 void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); 63 void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID);
66 void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); 64 GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID);
67 65
68 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID); 66 void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
69 List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID); 67 void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile);
70 68
71 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 69 GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID);
72 GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID); 70 List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID);
73 List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID); 71
72 void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
73 GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID);
74 List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID);
74 } 75 }
75 76
76 public class GroupInviteInfo 77 public class GroupInviteInfo
@@ -80,4 +81,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
80 public UUID AgentID = UUID.Zero; 81 public UUID AgentID = UUID.Zero;
81 public UUID InviteID = UUID.Zero; 82 public UUID InviteID = UUID.Zero;
82 } 83 }
84
85 public class GroupRequestID
86 {
87 public UUID AgentID = UUID.Zero;
88 public string UserServiceURL = string.Empty;
89 public UUID SessionID = UUID.Zero;
90 }
83} 91}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
deleted file mode 100644
index 590753e..0000000
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ /dev/null
@@ -1,1278 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Collections.Specialized;
32using System.Reflection;
33
34using Nwc.XmlRpc;
35
36using log4net;
37using Mono.Addins;
38using Nini.Config;
39
40using OpenMetaverse;
41using OpenMetaverse.StructuredData;
42
43using OpenSim.Framework;
44using OpenSim.Framework.Communications;
45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Services.Interfaces;
47
48/***************************************************************************
49 * Simian Data Map
50 * ===============
51 *
52 * OwnerID -> Type -> Key
53 * -----------------------
54 *
55 * UserID -> Group -> ActiveGroup
56 * + GroupID
57 *
58 * UserID -> GroupMember -> GroupID
59 * + SelectedRoleID [UUID]
60 * + AcceptNotices [bool]
61 * + ListInProfile [bool]
62 * + Contribution [int]
63 *
64 * UserID -> GroupRole[GroupID] -> RoleID
65 *
66 * GroupID -> Group -> GroupName
67 * + Charter
68 * + ShowInList
69 * + InsigniaID
70 * + MembershipFee
71 * + OpenEnrollment
72 * + AllowPublish
73 * + MaturePublish
74 * + FounderID
75 * + EveryonePowers
76 * + OwnerRoleID
77 * + OwnersPowers
78 *
79 * GroupID -> GroupRole -> RoleID
80 * + Name
81 * + Description
82 * + Title
83 * + Powers
84 *
85 * GroupID -> GroupMemberInvite -> InviteID
86 * + AgentID
87 * + RoleID
88 *
89 * GroupID -> GroupNotice -> NoticeID
90 * + TimeStamp [uint]
91 * + FromName [string]
92 * + Subject [string]
93 * + Message [string]
94 * + BinaryBucket [byte[]]
95 *
96 * */
97
98namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
99{
100 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
101 public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
102 {
103 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
104
105 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
106 GroupPowers.Accountable |
107 GroupPowers.JoinChat |
108 GroupPowers.AllowVoiceChat |
109 GroupPowers.ReceiveNotices |
110 GroupPowers.StartProposal |
111 GroupPowers.VoteOnProposal;
112
113 // Would this be cleaner as (GroupPowers)ulong.MaxValue;
114 public const GroupPowers m_DefaultOwnerPowers = GroupPowers.Accountable
115 | GroupPowers.AllowEditLand
116 | GroupPowers.AllowFly
117 | GroupPowers.AllowLandmark
118 | GroupPowers.AllowRez
119 | GroupPowers.AllowSetHome
120 | GroupPowers.AllowVoiceChat
121 | GroupPowers.AssignMember
122 | GroupPowers.AssignMemberLimited
123 | GroupPowers.ChangeActions
124 | GroupPowers.ChangeIdentity
125 | GroupPowers.ChangeMedia
126 | GroupPowers.ChangeOptions
127 | GroupPowers.CreateRole
128 | GroupPowers.DeedObject
129 | GroupPowers.DeleteRole
130 | GroupPowers.Eject
131 | GroupPowers.FindPlaces
132 | GroupPowers.Invite
133 | GroupPowers.JoinChat
134 | GroupPowers.LandChangeIdentity
135 | GroupPowers.LandDeed
136 | GroupPowers.LandDivideJoin
137 | GroupPowers.LandEdit
138 | GroupPowers.LandEjectAndFreeze
139 | GroupPowers.LandGardening
140 | GroupPowers.LandManageAllowed
141 | GroupPowers.LandManageBanned
142 | GroupPowers.LandManagePasses
143 | GroupPowers.LandOptions
144 | GroupPowers.LandRelease
145 | GroupPowers.LandSetSale
146 | GroupPowers.ModerateChat
147 | GroupPowers.ObjectManipulate
148 | GroupPowers.ObjectSetForSale
149 | GroupPowers.ReceiveNotices
150 | GroupPowers.RemoveMember
151 | GroupPowers.ReturnGroupOwned
152 | GroupPowers.ReturnGroupSet
153 | GroupPowers.ReturnNonGroup
154 | GroupPowers.RoleProperties
155 | GroupPowers.SendNotices
156 | GroupPowers.SetLandingPoint
157 | GroupPowers.StartProposal
158 | GroupPowers.VoteOnProposal;
159
160 private bool m_connectorEnabled = false;
161
162 private string m_serviceURL = string.Empty;
163
164 private bool m_debugEnabled = false;
165
166 // private IUserAccountService m_accountService = null;
167
168
169 #region IRegionModuleBase Members
170
171 public string Name
172 {
173 get { return "SimianGroupsServicesConnector"; }
174 }
175
176 // this module is not intended to be replaced, but there should only be 1 of them.
177 public Type ReplaceableInterface
178 {
179 get { return null; }
180 }
181
182 public void Initialise(IConfigSource config)
183 {
184 IConfig groupsConfig = config.Configs["Groups"];
185
186 if (groupsConfig == null)
187 {
188 // Do not run this module by default.
189 return;
190 }
191 else
192 {
193 // if groups aren't enabled, we're not needed.
194 // if we're not specified as the connector to use, then we're not wanted
195 if ((groupsConfig.GetBoolean("Enabled", false) == false)
196 || (groupsConfig.GetString("ServicesConnectorModule", "Default") != Name))
197 {
198 m_connectorEnabled = false;
199 return;
200 }
201
202 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
203
204 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty);
205 if ((m_serviceURL == null) ||
206 (m_serviceURL == string.Empty))
207 {
208 m_log.ErrorFormat("Please specify a valid Simian Server URL for XmlRpcServiceURL in OpenSim.ini, [Groups]");
209 m_connectorEnabled = false;
210 return;
211 }
212
213 // If we got all the config options we need, lets start'er'up
214 m_connectorEnabled = true;
215
216 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
217
218 }
219 }
220
221 public void Close()
222 {
223 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name);
224 }
225
226 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
227 {
228 if (m_connectorEnabled)
229 {
230 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
231 }
232 }
233
234 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
235 {
236 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
237 {
238 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
239 }
240 }
241
242 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
243 {
244 // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info
245 // scene.EventManager.OnNewClient += OnNewClient;
246 }
247
248 #endregion
249
250 #region ISharedRegionModule Members
251
252 public void PostInitialise()
253 {
254 // NoOp
255 }
256
257 #endregion
258
259
260
261
262 #region IGroupsServicesConnector Members
263
264 /// <summary>
265 /// 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.
266 /// </summary>
267 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
268 int membershipFee, bool openEnrollment, bool allowPublish,
269 bool maturePublish, UUID founderID)
270 {
271 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
272
273 UUID GroupID = UUID.Random();
274 UUID OwnerRoleID = UUID.Random();
275
276 OSDMap GroupInfoMap = new OSDMap();
277 GroupInfoMap["Charter"] = OSD.FromString(charter);
278 GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
279 GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
280 GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
281 GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
282 GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
283 GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
284 GroupInfoMap["FounderID"] = OSD.FromUUID(founderID);
285 GroupInfoMap["EveryonePowers"] = OSD.FromULong((ulong)m_DefaultEveryonePowers);
286 GroupInfoMap["OwnerRoleID"] = OSD.FromUUID(OwnerRoleID);
287 GroupInfoMap["OwnersPowers"] = OSD.FromULong((ulong)m_DefaultOwnerPowers);
288
289 if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap))
290 {
291 AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers);
292 AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers);
293
294 AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID);
295
296 return GroupID;
297 }
298 else
299 {
300 return UUID.Zero;
301 }
302 }
303
304
305 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
306 UUID insigniaID, int membershipFee, bool openEnrollment,
307 bool allowPublish, bool maturePublish)
308 {
309 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
310 // TODO: Check to make sure requestingAgentID has permission to update group
311
312 string GroupName;
313 OSDMap GroupInfoMap;
314 if( SimianGetFirstGenericEntry(groupID, "GroupInfo", out GroupName, out GroupInfoMap) )
315 {
316 GroupInfoMap["Charter"] = OSD.FromString(charter);
317 GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
318 GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
319 GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
320 GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
321 GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
322 GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
323
324 SimianAddGeneric(groupID, "Group", GroupName, GroupInfoMap);
325 }
326
327 }
328
329
330 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
331 string title, ulong powers)
332 {
333 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
334
335 OSDMap GroupRoleInfo = new OSDMap();
336 GroupRoleInfo["Name"] = OSD.FromString(name);
337 GroupRoleInfo["Description"] = OSD.FromString(description);
338 GroupRoleInfo["Title"] = OSD.FromString(title);
339 GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
340
341 // TODO: Add security, make sure that requestingAgentID has permision to add roles
342 SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
343 }
344
345 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
346 {
347 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
348
349 // TODO: Add security
350
351 // Can't delete the Everyone Role
352 if (roleID != UUID.Zero)
353 {
354 // Remove all GroupRole Members from Role
355 Dictionary<UUID, OSDMap> GroupRoleMembers;
356 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
357 if (SimianGetGenericEntries(GroupRoleMemberType, roleID.ToString(), out GroupRoleMembers))
358 {
359 foreach(UUID UserID in GroupRoleMembers.Keys)
360 {
361 EnsureRoleNotSelectedByMember(groupID, roleID, UserID);
362
363 SimianRemoveGenericEntry(UserID, GroupRoleMemberType, roleID.ToString());
364 }
365 }
366
367 // Remove role
368 SimianRemoveGenericEntry(groupID, "GroupRole", roleID.ToString());
369 }
370 }
371
372
373 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
374 string title, ulong powers)
375 {
376 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
377
378 // TODO: Security, check that requestingAgentID is allowed to update group roles
379
380 OSDMap GroupRoleInfo;
381 if (SimianGetGenericEntry(groupID, "GroupRole", roleID.ToString(), out GroupRoleInfo))
382 {
383 if (name != null)
384 {
385 GroupRoleInfo["Name"] = OSD.FromString(name);
386 }
387 if (description != null)
388 {
389 GroupRoleInfo["Description"] = OSD.FromString(description);
390 }
391 if (title != null)
392 {
393 GroupRoleInfo["Title"] = OSD.FromString(title);
394 }
395 GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
396
397 }
398
399
400 SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
401 }
402
403 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
404 {
405 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
406
407 OSDMap GroupInfoMap = null;
408 if (groupID != UUID.Zero)
409 {
410 if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out GroupInfoMap))
411 {
412 return null;
413 }
414 }
415 else if ((groupName != null) && (groupName != string.Empty))
416 {
417 if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap))
418 {
419 return null;
420 }
421 }
422
423 GroupRecord GroupInfo = new GroupRecord();
424
425 GroupInfo.GroupID = groupID;
426 GroupInfo.GroupName = groupName;
427 GroupInfo.Charter = GroupInfoMap["Charter"].AsString();
428 GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean();
429 GroupInfo.GroupPicture = GroupInfoMap["InsigniaID"].AsUUID();
430 GroupInfo.MembershipFee = GroupInfoMap["MembershipFee"].AsInteger();
431 GroupInfo.OpenEnrollment = GroupInfoMap["OpenEnrollment"].AsBoolean();
432 GroupInfo.AllowPublish = GroupInfoMap["AllowPublish"].AsBoolean();
433 GroupInfo.MaturePublish = GroupInfoMap["MaturePublish"].AsBoolean();
434 GroupInfo.FounderID = GroupInfoMap["FounderID"].AsUUID();
435 GroupInfo.OwnerRoleID = GroupInfoMap["OwnerRoleID"].AsUUID();
436
437 return GroupInfo;
438
439 }
440
441 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID groupID, UUID memberID)
442 {
443 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
444
445 OSDMap groupProfile;
446 string groupName;
447 if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out groupProfile))
448 {
449 // GroupProfileData is not nullable
450 return new GroupProfileData();
451 }
452
453 GroupProfileData MemberGroupProfile = new GroupProfileData();
454 MemberGroupProfile.GroupID = groupID;
455 MemberGroupProfile.Name = groupName;
456
457 if (groupProfile["Charter"] != null)
458 {
459 MemberGroupProfile.Charter = groupProfile["Charter"].AsString();
460 }
461
462 MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1";
463 MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID();
464 MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger();
465 MemberGroupProfile.OpenEnrollment = groupProfile["OpenEnrollment"].AsBoolean();
466 MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean();
467 MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean();
468 MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();;
469 MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID();
470
471 Dictionary<UUID, OSDMap> Members;
472 if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members))
473 {
474 MemberGroupProfile.GroupMembershipCount = Members.Count;
475 }
476
477 Dictionary<string, OSDMap> Roles;
478 if (SimianGetGenericEntries(groupID, "GroupRole", out Roles))
479 {
480 MemberGroupProfile.GroupRolesCount = Roles.Count;
481 }
482
483 // TODO: Get Group Money balance from somewhere
484 // group.Money = 0;
485
486 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, memberID, groupID);
487
488 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
489 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
490
491 return MemberGroupProfile;
492 }
493
494 public void SetAgentActiveGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
495 {
496 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
497
498 OSDMap ActiveGroup = new OSDMap();
499 ActiveGroup.Add("GroupID", OSD.FromUUID(groupID));
500 SimianAddGeneric(agentID, "Group", "ActiveGroup", ActiveGroup);
501 }
502
503 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
504 {
505 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
506
507 OSDMap GroupMemberInfo;
508 if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
509 {
510 GroupMemberInfo = new OSDMap();
511 }
512
513 GroupMemberInfo["SelectedRoleID"] = OSD.FromUUID(roleID);
514 SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
515 }
516
517 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
518 {
519 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
520
521 OSDMap GroupMemberInfo;
522 if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
523 {
524 GroupMemberInfo = new OSDMap();
525 }
526
527 GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices);
528 GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile);
529 GroupMemberInfo["Contribution"] = OSD.FromInteger(0);
530 GroupMemberInfo["SelectedRole"] = OSD.FromUUID(UUID.Zero);
531 SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
532 }
533
534 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
535 {
536 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
537
538 OSDMap Invite = new OSDMap();
539 Invite["AgentID"] = OSD.FromUUID(agentID);
540 Invite["RoleID"] = OSD.FromUUID(roleID);
541
542 SimianAddGeneric(groupID, "GroupMemberInvite", inviteID.ToString(), Invite);
543 }
544
545 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
546 {
547 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
548
549 OSDMap GroupMemberInvite;
550 UUID GroupID;
551 if (!SimianGetFirstGenericEntry("GroupMemberInvite", inviteID.ToString(), out GroupID, out GroupMemberInvite))
552 {
553 return null;
554 }
555
556 GroupInviteInfo inviteInfo = new GroupInviteInfo();
557 inviteInfo.InviteID = inviteID;
558 inviteInfo.GroupID = GroupID;
559 inviteInfo.AgentID = GroupMemberInvite["AgentID"].AsUUID();
560 inviteInfo.RoleID = GroupMemberInvite["RoleID"].AsUUID();
561
562 return inviteInfo;
563 }
564
565 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
566 {
567 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
568
569 GroupInviteInfo invite = GetAgentToGroupInvite(requestingAgentID, inviteID);
570 SimianRemoveGenericEntry(invite.GroupID, "GroupMemberInvite", inviteID.ToString());
571 }
572
573 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
574 {
575 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
576
577 // Setup Agent/Group information
578 SetAgentGroupInfo(requestingAgentID, AgentID, GroupID, true, true);
579
580 // Add agent to Everyone Group
581 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, UUID.Zero);
582
583 // Add agent to Specified Role
584 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
585
586 // Set selected role in this group to specified role
587 SetAgentActiveGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
588 }
589
590 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
591 {
592 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
593
594 // If current active group is the group the agent is being removed from, change their group to UUID.Zero
595 GroupMembershipData memberActiveMembership = GetAgentActiveMembership(requestingAgentID, agentID);
596 if (memberActiveMembership.GroupID == groupID)
597 {
598 SetAgentActiveGroup(agentID, agentID, UUID.Zero);
599 }
600
601 // Remove Group Member information for this group
602 SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString());
603
604 // By using a Simian Generics Type consisting of a prefix and a groupID,
605 // combined with RoleID as key allows us to get a list of roles a particular member
606 // of a group is assigned to.
607 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
608
609 // Take Agent out of all other group roles
610 Dictionary<string, OSDMap> GroupRoles;
611 if (SimianGetGenericEntries(agentID, GroupRoleMemberType, out GroupRoles))
612 {
613 foreach (string roleID in GroupRoles.Keys)
614 {
615 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID);
616 }
617 }
618 }
619
620 public void AddAgentToGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
621 {
622 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
623
624 SimianAddGeneric(agentID, "GroupRole" + groupID.ToString(), roleID.ToString(), new OSDMap());
625 }
626
627 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
628 {
629 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
630
631 // Cannot remove members from the Everyone Role
632 if (roleID != UUID.Zero)
633 {
634 EnsureRoleNotSelectedByMember(groupID, roleID, agentID);
635
636 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
637 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID.ToString());
638 }
639 }
640
641 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
642 {
643 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
644
645 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
646
647 NameValueCollection requestArgs = new NameValueCollection
648 {
649 { "RequestMethod", "GetGenerics" },
650 { "Type", "Group" },
651 { "Key", search },
652 { "Fuzzy", "1" }
653 };
654
655
656 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
657 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
658 {
659 OSDArray entryArray = (OSDArray)response["Entries"];
660 foreach (OSDMap entryMap in entryArray)
661 {
662 DirGroupsReplyData data = new DirGroupsReplyData();
663 data.groupID = entryMap["OwnerID"].AsUUID();
664 data.groupName = entryMap["Key"].AsString();
665
666 // TODO: is there a better way to do this?
667 Dictionary<UUID, OSDMap> Members;
668 if (SimianGetGenericEntries("GroupMember", data.groupID.ToString(), out Members))
669 {
670 data.members = Members.Count;
671 }
672 else
673 {
674 data.members = 0;
675 }
676
677 // TODO: sort results?
678 // data.searchOrder = order;
679
680 findings.Add(data);
681 }
682 }
683
684
685 return findings;
686 }
687
688 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID)
689 {
690 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
691
692 GroupMembershipData data = new GroupMembershipData();
693
694 ///////////////////////////////
695 // Agent Specific Information:
696 //
697 OSDMap UserActiveGroup;
698 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
699 {
700 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
701 }
702
703 OSDMap UserGroupMemberInfo;
704 if( SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo) )
705 {
706 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
707 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
708 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
709 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();
710
711 ///////////////////////////////
712 // Role Specific Information:
713 //
714
715 OSDMap GroupRoleInfo;
716 if( SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo) )
717 {
718 data.GroupTitle = GroupRoleInfo["Title"].AsString();
719 data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
720 }
721 }
722
723 ///////////////////////////////
724 // Group Specific Information:
725 //
726 OSDMap GroupInfo;
727 string GroupName;
728 if( SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo) )
729 {
730 data.GroupID = groupID;
731 data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean();
732 data.Charter = GroupInfo["Charter"].AsString();
733 data.FounderID = GroupInfo["FounderID"].AsUUID();
734 data.GroupName = GroupName;
735 data.GroupPicture = GroupInfo["InsigniaID"].AsUUID();
736 data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean();
737 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
738 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
739 data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
740 }
741
742 return data;
743 }
744
745 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID agentID)
746 {
747 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
748
749 UUID GroupID = UUID.Zero;
750 OSDMap UserActiveGroup;
751 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
752 {
753 GroupID = UserActiveGroup["GroupID"].AsUUID();
754 }
755
756 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString());
757 return GetAgentGroupMembership(requestingAgentID, agentID, GroupID);
758 }
759
760 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID agentID)
761 {
762 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
763
764 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
765
766 Dictionary<string,OSDMap> GroupMemberShips;
767 if (SimianGetGenericEntries(agentID, "GroupMember", out GroupMemberShips))
768 {
769 foreach (string key in GroupMemberShips.Keys)
770 {
771 memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key)));
772 }
773 }
774
775 return memberships;
776 }
777
778 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID agentID, UUID groupID)
779 {
780 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
781
782 List<GroupRolesData> Roles = new List<GroupRolesData>();
783
784 Dictionary<string, OSDMap> GroupRoles;
785 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
786 {
787 Dictionary<string, OSDMap> MemberRoles;
788 if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles))
789 {
790 foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles)
791 {
792 GroupRolesData data = new GroupRolesData();
793 data.RoleID = UUID.Parse(kvp.Key);
794 data.Name = GroupRoles[kvp.Key]["Name"].AsString();
795 data.Description = GroupRoles[kvp.Key]["Description"].AsString();
796 data.Title = GroupRoles[kvp.Key]["Title"].AsString();
797 data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong();
798
799 Roles.Add(data);
800 }
801 }
802 }
803 return Roles;
804 }
805
806 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID groupID)
807 {
808 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
809
810 List<GroupRolesData> Roles = new List<GroupRolesData>();
811
812 Dictionary<string, OSDMap> GroupRoles;
813 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
814 {
815 foreach (KeyValuePair<string, OSDMap> role in GroupRoles)
816 {
817 GroupRolesData data = new GroupRolesData();
818
819 data.RoleID = UUID.Parse(role.Key);
820
821 data.Name = role.Value["Name"].AsString();
822 data.Description = role.Value["Description"].AsString();
823 data.Title = role.Value["Title"].AsString();
824 data.Powers = role.Value["Powers"].AsULong();
825
826 Dictionary<UUID, OSDMap> GroupRoleMembers;
827 if (SimianGetGenericEntries("GroupRole" + groupID.ToString(), role.Key, out GroupRoleMembers))
828 {
829 data.Members = GroupRoleMembers.Count;
830 }
831 else
832 {
833 data.Members = 0;
834 }
835
836 Roles.Add(data);
837 }
838 }
839
840 return Roles;
841
842 }
843
844
845
846 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
847 {
848 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
849
850 List<GroupMembersData> members = new List<GroupMembersData>();
851
852 OSDMap GroupInfo;
853 string GroupName;
854 UUID GroupOwnerRoleID = UUID.Zero;
855 if (!SimianGetFirstGenericEntry(GroupID, "Group", out GroupName, out GroupInfo))
856 {
857 return members;
858 }
859 GroupOwnerRoleID = GroupInfo["OwnerRoleID"].AsUUID();
860
861 // Locally cache group roles, since we'll be needing this data for each member
862 Dictionary<string,OSDMap> GroupRoles;
863 SimianGetGenericEntries(GroupID, "GroupRole", out GroupRoles);
864
865 // Locally cache list of group owners
866 Dictionary<UUID, OSDMap> GroupOwners;
867 SimianGetGenericEntries("GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners);
868
869
870 Dictionary<UUID, OSDMap> GroupMembers;
871 if (SimianGetGenericEntries("GroupMember", GroupID.ToString(), out GroupMembers))
872 {
873 foreach (KeyValuePair<UUID, OSDMap> member in GroupMembers)
874 {
875 GroupMembersData data = new GroupMembersData();
876
877 data.AgentID = member.Key;
878
879 UUID SelectedRoleID = member.Value["SelectedRoleID"].AsUUID();
880
881 data.AcceptNotices = member.Value["AcceptNotices"].AsBoolean();
882 data.ListInProfile = member.Value["ListInProfile"].AsBoolean();
883 data.Contribution = member.Value["Contribution"].AsInteger();
884
885 data.IsOwner = GroupOwners.ContainsKey(member.Key);
886
887 OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()];
888 data.Title = GroupRoleInfo["Title"].AsString();
889 data.AgentPowers = GroupRoleInfo["Powers"].AsULong();
890
891 members.Add(data);
892 }
893 }
894
895 return members;
896
897 }
898
899 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID groupID)
900 {
901 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
902
903 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
904
905 Dictionary<string, OSDMap> GroupRoles;
906 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
907 {
908 foreach( KeyValuePair<string, OSDMap> Role in GroupRoles )
909 {
910 Dictionary<UUID, OSDMap> GroupRoleMembers;
911 if( SimianGetGenericEntries("GroupRole"+groupID.ToString(), Role.Key, out GroupRoleMembers) )
912 {
913 foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers )
914 {
915 GroupRoleMembersData data = new GroupRoleMembersData();
916
917 data.MemberID = GroupRoleMember.Key;
918 data.RoleID = UUID.Parse(Role.Key);
919
920 members.Add(data);
921 }
922 }
923 }
924 }
925
926 return members;
927 }
928
929 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
930 {
931 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
932
933 List<GroupNoticeData> values = new List<GroupNoticeData>();
934
935 Dictionary<string, OSDMap> Notices;
936 if (SimianGetGenericEntries(GroupID, "GroupNotice", out Notices))
937 {
938 foreach (KeyValuePair<string, OSDMap> Notice in Notices)
939 {
940 GroupNoticeData data = new GroupNoticeData();
941 data.NoticeID = UUID.Parse(Notice.Key);
942 data.Timestamp = Notice.Value["TimeStamp"].AsUInteger();
943 data.FromName = Notice.Value["FromName"].AsString();
944 data.Subject = Notice.Value["Subject"].AsString();
945 data.HasAttachment = Notice.Value["BinaryBucket"].AsBinary().Length > 0;
946
947 //TODO: Figure out how to get this
948 data.AssetType = 0;
949
950 values.Add(data);
951 }
952 }
953
954 return values;
955
956 }
957 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
958 {
959 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
960
961 OSDMap GroupNotice;
962 UUID GroupID;
963 if (SimianGetFirstGenericEntry("GroupNotice", noticeID.ToString(), out GroupID, out GroupNotice))
964 {
965 GroupNoticeInfo data = new GroupNoticeInfo();
966 data.GroupID = GroupID;
967 data.Message = GroupNotice["Message"].AsString();
968 data.BinaryBucket = GroupNotice["BinaryBucket"].AsBinary();
969 data.noticeData.NoticeID = noticeID;
970 data.noticeData.Timestamp = GroupNotice["TimeStamp"].AsUInteger();
971 data.noticeData.FromName = GroupNotice["FromName"].AsString();
972 data.noticeData.Subject = GroupNotice["Subject"].AsString();
973 data.noticeData.HasAttachment = data.BinaryBucket.Length > 0;
974 data.noticeData.AssetType = 0;
975
976 if (data.Message == null)
977 {
978 data.Message = string.Empty;
979 }
980
981 return data;
982 }
983 return null;
984 }
985 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
986 {
987 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
988
989 OSDMap Notice = new OSDMap();
990 Notice["TimeStamp"] = OSD.FromUInteger((uint)Util.UnixTimeSinceEpoch());
991 Notice["FromName"] = OSD.FromString(fromName);
992 Notice["Subject"] = OSD.FromString(subject);
993 Notice["Message"] = OSD.FromString(message);
994 Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket);
995
996 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice);
997
998 }
999 #endregion
1000
1001
1002 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
1003 {
1004 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1005
1006 // If member's SelectedRole is roleID, change their selected role to Everyone
1007 // before removing them from the role
1008 OSDMap UserGroupInfo;
1009 if (SimianGetGenericEntry(userID, "GroupMember", groupID.ToString(), out UserGroupInfo))
1010 {
1011 if (UserGroupInfo["SelectedRoleID"].AsUUID() == roleID)
1012 {
1013 UserGroupInfo["SelectedRoleID"] = OSD.FromUUID(UUID.Zero);
1014 }
1015 SimianAddGeneric(userID, "GroupMember", groupID.ToString(), UserGroupInfo);
1016 }
1017 }
1018
1019
1020 #region Simian Util Methods
1021 private bool SimianAddGeneric(UUID ownerID, string type, string key, OSDMap map)
1022 {
1023 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1024
1025 string value = OSDParser.SerializeJsonString(map);
1026
1027 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] value: {0}", value);
1028
1029 NameValueCollection RequestArgs = new NameValueCollection
1030 {
1031 { "RequestMethod", "AddGeneric" },
1032 { "OwnerID", ownerID.ToString() },
1033 { "Type", type },
1034 { "Key", key },
1035 { "Value", value}
1036 };
1037
1038
1039 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1040 if (Response["Success"].AsBoolean())
1041 {
1042 return true;
1043 }
1044 else
1045 {
1046 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, Response["Message"]);
1047 return false;
1048 }
1049 }
1050
1051 /// <summary>
1052 /// Returns the first of possibly many entries for Owner/Type pair
1053 /// </summary>
1054 private bool SimianGetFirstGenericEntry(UUID ownerID, string type, out string key, out OSDMap map)
1055 {
1056 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type);
1057
1058 NameValueCollection RequestArgs = new NameValueCollection
1059 {
1060 { "RequestMethod", "GetGenerics" },
1061 { "OwnerID", ownerID.ToString() },
1062 { "Type", type }
1063 };
1064
1065
1066 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1067 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1068 {
1069 OSDArray entryArray = (OSDArray)Response["Entries"];
1070 if (entryArray.Count >= 1)
1071 {
1072 OSDMap entryMap = entryArray[0] as OSDMap;
1073 key = entryMap["Key"].AsString();
1074 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1075
1076 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1077
1078 return true;
1079 }
1080 else
1081 {
1082 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1083 }
1084 }
1085 else
1086 {
1087 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1088 }
1089 key = null;
1090 map = null;
1091 return false;
1092 }
1093 private bool SimianGetFirstGenericEntry(string type, string key, out UUID ownerID, out OSDMap map)
1094 {
1095 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1096
1097
1098 NameValueCollection RequestArgs = new NameValueCollection
1099 {
1100 { "RequestMethod", "GetGenerics" },
1101 { "Type", type },
1102 { "Key", key}
1103 };
1104
1105
1106 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1107 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1108 {
1109 OSDArray entryArray = (OSDArray)Response["Entries"];
1110 if (entryArray.Count >= 1)
1111 {
1112 OSDMap entryMap = entryArray[0] as OSDMap;
1113 ownerID = entryMap["OwnerID"].AsUUID();
1114 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1115
1116 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1117
1118 return true;
1119 }
1120 else
1121 {
1122 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1123 }
1124 }
1125 else
1126 {
1127 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1128 }
1129 ownerID = UUID.Zero;
1130 map = null;
1131 return false;
1132 }
1133
1134 private bool SimianGetGenericEntry(UUID ownerID, string type, string key, out OSDMap map)
1135 {
1136 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1137
1138 NameValueCollection RequestArgs = new NameValueCollection
1139 {
1140 { "RequestMethod", "GetGenerics" },
1141 { "OwnerID", ownerID.ToString() },
1142 { "Type", type },
1143 { "Key", key}
1144 };
1145
1146
1147 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1148 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1149 {
1150 OSDArray entryArray = (OSDArray)Response["Entries"];
1151 if (entryArray.Count == 1)
1152 {
1153 OSDMap entryMap = entryArray[0] as OSDMap;
1154 key = entryMap["Key"].AsString();
1155 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1156
1157 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1158
1159 return true;
1160 }
1161 else
1162 {
1163 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1164 }
1165 }
1166 else
1167 {
1168 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1169 }
1170 map = null;
1171 return false;
1172 }
1173
1174 private bool SimianGetGenericEntries(UUID ownerID, string type, out Dictionary<string, OSDMap> maps)
1175 {
1176 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name,ownerID, type);
1177
1178 NameValueCollection requestArgs = new NameValueCollection
1179 {
1180 { "RequestMethod", "GetGenerics" },
1181 { "OwnerID", ownerID.ToString() },
1182 { "Type", type }
1183 };
1184
1185
1186
1187 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
1188 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1189 {
1190 maps = new Dictionary<string, OSDMap>();
1191
1192 OSDArray entryArray = (OSDArray)response["Entries"];
1193 foreach (OSDMap entryMap in entryArray)
1194 {
1195 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1196 maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1197 }
1198 if(maps.Count == 0)
1199 {
1200 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1201 }
1202
1203 return true;
1204 }
1205 else
1206 {
1207 maps = null;
1208 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
1209 }
1210 return false;
1211 }
1212 private bool SimianGetGenericEntries(string type, string key, out Dictionary<UUID, OSDMap> maps)
1213 {
1214 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1215
1216 NameValueCollection requestArgs = new NameValueCollection
1217 {
1218 { "RequestMethod", "GetGenerics" },
1219 { "Type", type },
1220 { "Key", key }
1221 };
1222
1223
1224
1225 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
1226 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1227 {
1228 maps = new Dictionary<UUID, OSDMap>();
1229
1230 OSDArray entryArray = (OSDArray)response["Entries"];
1231 foreach (OSDMap entryMap in entryArray)
1232 {
1233 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1234 maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1235 }
1236 if (maps.Count == 0)
1237 {
1238 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1239 }
1240 return true;
1241 }
1242 else
1243 {
1244 maps = null;
1245 m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
1246 }
1247 return false;
1248 }
1249
1250 private bool SimianRemoveGenericEntry(UUID ownerID, string type, string key)
1251 {
1252 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1253
1254 NameValueCollection requestArgs = new NameValueCollection
1255 {
1256 { "RequestMethod", "RemoveGeneric" },
1257 { "OwnerID", ownerID.ToString() },
1258 { "Type", type },
1259 { "Key", key }
1260 };
1261
1262
1263 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
1264 if (response["Success"].AsBoolean())
1265 {
1266 return true;
1267 }
1268 else
1269 {
1270 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, response["Message"]);
1271 return false;
1272 }
1273 }
1274 #endregion
1275 }
1276
1277}
1278
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index ab343c8..964d0bb 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -40,16 +40,16 @@ using OpenMetaverse;
40using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
41 41
42using OpenSim.Framework; 42using OpenSim.Framework;
43using OpenSim.Framework.Communications;
44using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces;
46 44
47namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 45namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
48{ 46{
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
50 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector 48 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
51 { 49 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log =
51 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 53
54 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | 54 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
55 GroupPowers.Accountable | 55 GroupPowers.Accountable |
@@ -68,8 +68,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
68 private string m_groupReadKey = string.Empty; 68 private string m_groupReadKey = string.Empty;
69 private string m_groupWriteKey = string.Empty; 69 private string m_groupWriteKey = string.Empty;
70 70
71 private IUserAccountService m_accountService = null;
72
73 71
74 #region IRegionModuleBase Members 72 #region IRegionModuleBase Members
75 73
@@ -120,9 +118,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
120 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 118 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
121 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 119 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
122 120
123
124
125
126 // If we got all the config options we need, lets start'er'up 121 // If we got all the config options we need, lets start'er'up
127 m_connectorEnabled = true; 122 m_connectorEnabled = true;
128 } 123 }
@@ -136,24 +131,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
136 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 131 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
137 { 132 {
138 if (m_connectorEnabled) 133 if (m_connectorEnabled)
139 {
140
141 if (m_accountService == null)
142 {
143 m_accountService = scene.UserAccountService;
144 }
145
146
147 scene.RegisterModuleInterface<IGroupsServicesConnector>(this); 134 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
148 }
149 } 135 }
150 136
151 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) 137 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
152 { 138 {
153 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) 139 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
154 {
155 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); 140 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
156 }
157 } 141 }
158 142
159 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) 143 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -173,12 +157,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
173 157
174 #endregion 158 #endregion
175 159
160
161
176 #region IGroupsServicesConnector Members 162 #region IGroupsServicesConnector Members
177 163
178 /// <summary> 164 /// <summary>
179 /// 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. 165 /// 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.
180 /// </summary> 166 /// </summary>
181 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, 167 public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID,
182 int membershipFee, bool openEnrollment, bool allowPublish, 168 int membershipFee, bool openEnrollment, bool allowPublish,
183 bool maturePublish, UUID founderID) 169 bool maturePublish, UUID founderID)
184 { 170 {
@@ -250,7 +236,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
250 236
251 237
252 238
253 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param); 239 Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param);
254 240
255 if (respData.Contains("error")) 241 if (respData.Contains("error"))
256 { 242 {
@@ -262,7 +248,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
262 return UUID.Parse((string)respData["GroupID"]); 248 return UUID.Parse((string)respData["GroupID"]);
263 } 249 }
264 250
265 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, 251 public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList,
266 UUID insigniaID, int membershipFee, bool openEnrollment, 252 UUID insigniaID, int membershipFee, bool openEnrollment,
267 bool allowPublish, bool maturePublish) 253 bool allowPublish, bool maturePublish)
268 { 254 {
@@ -276,10 +262,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
276 param["AllowPublish"] = allowPublish == true ? 1 : 0; 262 param["AllowPublish"] = allowPublish == true ? 1 : 0;
277 param["MaturePublish"] = maturePublish == true ? 1 : 0; 263 param["MaturePublish"] = maturePublish == true ? 1 : 0;
278 264
279 XmlRpcCall(requestingAgentID, "groups.updateGroup", param); 265 XmlRpcCall(requestID, "groups.updateGroup", param);
280 } 266 }
281 267
282 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, 268 public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description,
283 string title, ulong powers) 269 string title, ulong powers)
284 { 270 {
285 Hashtable param = new Hashtable(); 271 Hashtable param = new Hashtable();
@@ -290,19 +276,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
290 param["Title"] = title; 276 param["Title"] = title;
291 param["Powers"] = powers.ToString(); 277 param["Powers"] = powers.ToString();
292 278
293 XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param); 279 XmlRpcCall(requestID, "groups.addRoleToGroup", param);
294 } 280 }
295 281
296 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID) 282 public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID)
297 { 283 {
298 Hashtable param = new Hashtable(); 284 Hashtable param = new Hashtable();
299 param["GroupID"] = groupID.ToString(); 285 param["GroupID"] = groupID.ToString();
300 param["RoleID"] = roleID.ToString(); 286 param["RoleID"] = roleID.ToString();
301 287
302 XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param); 288 XmlRpcCall(requestID, "groups.removeRoleFromGroup", param);
303 } 289 }
304 290
305 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, 291 public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description,
306 string title, ulong powers) 292 string title, ulong powers)
307 { 293 {
308 Hashtable param = new Hashtable(); 294 Hashtable param = new Hashtable();
@@ -322,10 +308,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
322 } 308 }
323 param["Powers"] = powers.ToString(); 309 param["Powers"] = powers.ToString();
324 310
325 XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param); 311 XmlRpcCall(requestID, "groups.updateGroupRole", param);
326 } 312 }
327 313
328 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName) 314 public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName)
329 { 315 {
330 Hashtable param = new Hashtable(); 316 Hashtable param = new Hashtable();
331 if (GroupID != UUID.Zero) 317 if (GroupID != UUID.Zero)
@@ -337,7 +323,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
337 param["Name"] = GroupName.ToString(); 323 param["Name"] = GroupName.ToString();
338 } 324 }
339 325
340 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param); 326 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);
341 327
342 if (respData.Contains("error")) 328 if (respData.Contains("error"))
343 { 329 {
@@ -348,12 +334,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
348 334
349 } 335 }
350 336
351 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID) 337 public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID)
352 { 338 {
353 Hashtable param = new Hashtable(); 339 Hashtable param = new Hashtable();
354 param["GroupID"] = GroupID.ToString(); 340 param["GroupID"] = GroupID.ToString();
355 341
356 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param); 342 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);
357 343
358 if (respData.Contains("error")) 344 if (respData.Contains("error"))
359 { 345 {
@@ -361,35 +347,38 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
361 return new GroupProfileData(); 347 return new GroupProfileData();
362 } 348 }
363 349
364 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID); 350 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID);
365 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); 351 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
366 352
367 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; 353 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
368 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; 354 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
369 355
370 return MemberGroupProfile; 356 return MemberGroupProfile;
357
371 } 358 }
372 359
373 public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) 360
361
362 public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
374 { 363 {
375 Hashtable param = new Hashtable(); 364 Hashtable param = new Hashtable();
376 param["AgentID"] = AgentID.ToString(); 365 param["AgentID"] = AgentID.ToString();
377 param["GroupID"] = GroupID.ToString(); 366 param["GroupID"] = GroupID.ToString();
378 367
379 XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param); 368 XmlRpcCall(requestID, "groups.setAgentActiveGroup", param);
380 } 369 }
381 370
382 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) 371 public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
383 { 372 {
384 Hashtable param = new Hashtable(); 373 Hashtable param = new Hashtable();
385 param["AgentID"] = AgentID.ToString(); 374 param["AgentID"] = AgentID.ToString();
386 param["GroupID"] = GroupID.ToString(); 375 param["GroupID"] = GroupID.ToString();
387 param["SelectedRoleID"] = RoleID.ToString(); 376 param["SelectedRoleID"] = RoleID.ToString();
388 377
389 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param); 378 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param);
390 } 379 }
391 380
392 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 381 public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
393 { 382 {
394 Hashtable param = new Hashtable(); 383 Hashtable param = new Hashtable();
395 param["AgentID"] = AgentID.ToString(); 384 param["AgentID"] = AgentID.ToString();
@@ -397,11 +386,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
397 param["AcceptNotices"] = AcceptNotices ? "1" : "0"; 386 param["AcceptNotices"] = AcceptNotices ? "1" : "0";
398 param["ListInProfile"] = ListInProfile ? "1" : "0"; 387 param["ListInProfile"] = ListInProfile ? "1" : "0";
399 388
400 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param); 389 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param);
401 390
402 } 391 }
403 392
404 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 393 public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
405 { 394 {
406 Hashtable param = new Hashtable(); 395 Hashtable param = new Hashtable();
407 param["InviteID"] = inviteID.ToString(); 396 param["InviteID"] = inviteID.ToString();
@@ -409,16 +398,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
409 param["RoleID"] = roleID.ToString(); 398 param["RoleID"] = roleID.ToString();
410 param["GroupID"] = groupID.ToString(); 399 param["GroupID"] = groupID.ToString();
411 400
412 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param); 401 XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param);
413 402
414 } 403 }
415 404
416 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) 405 public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
417 { 406 {
418 Hashtable param = new Hashtable(); 407 Hashtable param = new Hashtable();
419 param["InviteID"] = inviteID.ToString(); 408 param["InviteID"] = inviteID.ToString();
420 409
421 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param); 410 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param);
422 411
423 if (respData.Contains("error")) 412 if (respData.Contains("error"))
424 { 413 {
@@ -434,59 +423,60 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
434 return inviteInfo; 423 return inviteInfo;
435 } 424 }
436 425
437 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) 426 public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
438 { 427 {
439 Hashtable param = new Hashtable(); 428 Hashtable param = new Hashtable();
440 param["InviteID"] = inviteID.ToString(); 429 param["InviteID"] = inviteID.ToString();
441 430
442 XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param); 431 XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param);
443 } 432 }
444 433
445 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) 434 public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
446 { 435 {
447 Hashtable param = new Hashtable(); 436 Hashtable param = new Hashtable();
448 param["AgentID"] = AgentID.ToString(); 437 param["AgentID"] = AgentID.ToString();
449 param["GroupID"] = GroupID.ToString(); 438 param["GroupID"] = GroupID.ToString();
450 param["RoleID"] = RoleID.ToString(); 439 param["RoleID"] = RoleID.ToString();
451 440
452 XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param); 441 XmlRpcCall(requestID, "groups.addAgentToGroup", param);
453 } 442 }
454 443
455 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) 444 public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
456 { 445 {
457 Hashtable param = new Hashtable(); 446 Hashtable param = new Hashtable();
458 param["AgentID"] = AgentID.ToString(); 447 param["AgentID"] = AgentID.ToString();
459 param["GroupID"] = GroupID.ToString(); 448 param["GroupID"] = GroupID.ToString();
460 449
461 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param); 450 XmlRpcCall(requestID, "groups.removeAgentFromGroup", param);
462 } 451 }
463 452
464 public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) 453 public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
465 { 454 {
466 Hashtable param = new Hashtable(); 455 Hashtable param = new Hashtable();
467 param["AgentID"] = AgentID.ToString(); 456 param["AgentID"] = AgentID.ToString();
468 param["GroupID"] = GroupID.ToString(); 457 param["GroupID"] = GroupID.ToString();
469 param["RoleID"] = RoleID.ToString(); 458 param["RoleID"] = RoleID.ToString();
470 459
471 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param); 460 XmlRpcCall(requestID, "groups.addAgentToGroupRole", param);
472 } 461 }
473 462
474 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) 463 public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
475 { 464 {
476 Hashtable param = new Hashtable(); 465 Hashtable param = new Hashtable();
477 param["AgentID"] = AgentID.ToString(); 466 param["AgentID"] = AgentID.ToString();
478 param["GroupID"] = GroupID.ToString(); 467 param["GroupID"] = GroupID.ToString();
479 param["RoleID"] = RoleID.ToString(); 468 param["RoleID"] = RoleID.ToString();
480 469
481 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param); 470 XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param);
482 } 471 }
483 472
484 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search) 473
474 public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
485 { 475 {
486 Hashtable param = new Hashtable(); 476 Hashtable param = new Hashtable();
487 param["Search"] = search; 477 param["Search"] = search;
488 478
489 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param); 479 Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param);
490 480
491 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); 481 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
492 482
@@ -508,13 +498,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
508 return findings; 498 return findings;
509 } 499 }
510 500
511 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID) 501 public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID)
512 { 502 {
513 Hashtable param = new Hashtable(); 503 Hashtable param = new Hashtable();
514 param["AgentID"] = AgentID.ToString(); 504 param["AgentID"] = AgentID.ToString();
515 param["GroupID"] = GroupID.ToString(); 505 param["GroupID"] = GroupID.ToString();
516 506
517 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param); 507 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param);
518 508
519 if (respData.Contains("error")) 509 if (respData.Contains("error"))
520 { 510 {
@@ -526,12 +516,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
526 return data; 516 return data;
527 } 517 }
528 518
529 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID) 519 public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID)
530 { 520 {
531 Hashtable param = new Hashtable(); 521 Hashtable param = new Hashtable();
532 param["AgentID"] = AgentID.ToString(); 522 param["AgentID"] = AgentID.ToString();
533 523
534 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param); 524 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param);
535 525
536 if (respData.Contains("error")) 526 if (respData.Contains("error"))
537 { 527 {
@@ -541,12 +531,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
541 return HashTableToGroupMembershipData(respData); 531 return HashTableToGroupMembershipData(respData);
542 } 532 }
543 533
544 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID) 534
535 public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
545 { 536 {
546 Hashtable param = new Hashtable(); 537 Hashtable param = new Hashtable();
547 param["AgentID"] = AgentID.ToString(); 538 param["AgentID"] = AgentID.ToString();
548 539
549 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param); 540 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param);
550 541
551 List<GroupMembershipData> memberships = new List<GroupMembershipData>(); 542 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
552 543
@@ -561,13 +552,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
561 return memberships; 552 return memberships;
562 } 553 }
563 554
564 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID) 555 public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID)
565 { 556 {
566 Hashtable param = new Hashtable(); 557 Hashtable param = new Hashtable();
567 param["AgentID"] = AgentID.ToString(); 558 param["AgentID"] = AgentID.ToString();
568 param["GroupID"] = GroupID.ToString(); 559 param["GroupID"] = GroupID.ToString();
569 560
570 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param); 561 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param);
571 562
572 List<GroupRolesData> Roles = new List<GroupRolesData>(); 563 List<GroupRolesData> Roles = new List<GroupRolesData>();
573 564
@@ -593,12 +584,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
593 584
594 } 585 }
595 586
596 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID) 587 public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID)
597 { 588 {
598 Hashtable param = new Hashtable(); 589 Hashtable param = new Hashtable();
599 param["GroupID"] = GroupID.ToString(); 590 param["GroupID"] = GroupID.ToString();
600 591
601 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param); 592 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param);
602 593
603 List<GroupRolesData> Roles = new List<GroupRolesData>(); 594 List<GroupRolesData> Roles = new List<GroupRolesData>();
604 595
@@ -626,12 +617,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
626 617
627 618
628 619
629 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) 620 public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID)
630 { 621 {
631 Hashtable param = new Hashtable(); 622 Hashtable param = new Hashtable();
632 param["GroupID"] = GroupID.ToString(); 623 param["GroupID"] = GroupID.ToString();
633 624
634 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param); 625 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param);
635 626
636 List<GroupMembersData> members = new List<GroupMembersData>(); 627 List<GroupMembersData> members = new List<GroupMembersData>();
637 628
@@ -659,12 +650,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
659 650
660 } 651 }
661 652
662 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) 653 public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID)
663 { 654 {
664 Hashtable param = new Hashtable(); 655 Hashtable param = new Hashtable();
665 param["GroupID"] = GroupID.ToString(); 656 param["GroupID"] = GroupID.ToString();
666 657
667 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param); 658 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param);
668 659
669 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); 660 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
670 661
@@ -683,12 +674,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
683 return members; 674 return members;
684 } 675 }
685 676
686 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) 677 public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID)
687 { 678 {
688 Hashtable param = new Hashtable(); 679 Hashtable param = new Hashtable();
689 param["GroupID"] = GroupID.ToString(); 680 param["GroupID"] = GroupID.ToString();
690 681
691 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param); 682 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param);
692 683
693 List<GroupNoticeData> values = new List<GroupNoticeData>(); 684 List<GroupNoticeData> values = new List<GroupNoticeData>();
694 685
@@ -710,12 +701,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
710 return values; 701 return values;
711 702
712 } 703 }
713 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) 704 public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID)
714 { 705 {
715 Hashtable param = new Hashtable(); 706 Hashtable param = new Hashtable();
716 param["NoticeID"] = noticeID.ToString(); 707 param["NoticeID"] = noticeID.ToString();
717 708
718 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param); 709 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param);
719 710
720 711
721 if (respData.Contains("error")) 712 if (respData.Contains("error"))
@@ -741,7 +732,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
741 732
742 return data; 733 return data;
743 } 734 }
744 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) 735 public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
745 { 736 {
746 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); 737 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
747 738
@@ -754,7 +745,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
754 param["BinaryBucket"] = binBucket; 745 param["BinaryBucket"] = binBucket;
755 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); 746 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
756 747
757 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param); 748 XmlRpcCall(requestID, "groups.addGroupNotice", param);
758 } 749 }
759 #endregion 750 #endregion
760 751
@@ -787,6 +778,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
787 778
788 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) 779 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
789 { 780 {
781
790 GroupRecord group = new GroupRecord(); 782 GroupRecord group = new GroupRecord();
791 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); 783 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
792 group.GroupName = groupProfile["Name"].ToString(); 784 group.GroupName = groupProfile["Name"].ToString();
@@ -805,7 +797,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
805 797
806 return group; 798 return group;
807 } 799 }
808
809 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) 800 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
810 { 801 {
811 GroupMembershipData data = new GroupMembershipData(); 802 GroupMembershipData data = new GroupMembershipData();
@@ -838,7 +829,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
838 data.MembershipFee = int.Parse((string)respData["MembershipFee"]); 829 data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
839 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); 830 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
840 data.ShowInList = ((string)respData["ShowInList"] == "1"); 831 data.ShowInList = ((string)respData["ShowInList"] == "1");
841
842 return data; 832 return data;
843 } 833 }
844 834
@@ -847,14 +837,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
847 /// <summary> 837 /// <summary>
848 /// Encapsulate the XmlRpc call to standardize security and error handling. 838 /// Encapsulate the XmlRpc call to standardize security and error handling.
849 /// </summary> 839 /// </summary>
850 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) 840 private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param)
851 { 841 {
852 string UserService; 842 if (requestID == null)
853 UUID SessionID; 843 {
854 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); 844 requestID = new GroupRequestID();
855 param.Add("requestingAgentID", requestingAgentID.ToString()); 845 }
856 param.Add("RequestingAgentUserService", UserService); 846 param.Add("RequestingAgentID", requestID.AgentID.ToString());
857 param.Add("RequestingSessionID", SessionID.ToString()); 847 param.Add("RequestingAgentUserService", requestID.UserServiceURL);
848 param.Add("RequestingSessionID", requestID.SessionID.ToString());
858 849
859 850
860 param.Add("ReadKey", m_groupReadKey); 851 param.Add("ReadKey", m_groupReadKey);
@@ -945,49 +936,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
945 } 936 }
946 } 937 }
947 938
948
949 /// <summary>
950 /// Group Request Tokens are an attempt to allow the groups service to authenticate
951 /// requests. Currently uses UserService, AgentID, and SessionID
952 /// TODO: Find a better way to do this.
953 /// </summary>
954 /// <param name="client"></param>
955 /// <returns></returns>
956 private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
957 {
958 UserServiceURL = "";
959 SessionID = UUID.Zero;
960
961
962 // Need to rework this based on changes to User Services
963 /*
964 UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
965 if (userAccount == null)
966 {
967 // This should be impossible. If I've been passed a reference to a client
968 // that client should be registered with the UserService. So something
969 // is horribly wrong somewhere.
970
971 m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
972 939
973 } 940 }
974 else if (userProfile is ForeignUserProfileData)
975 {
976 // They aren't from around here
977 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
978 UserServiceURL = fupd.UserServerURI;
979 SessionID = fupd.CurrentAgent.SessionID;
980 941
981 } 942 public class GroupNoticeInfo
982 else 943 {
983 { 944 public GroupNoticeData noticeData = new GroupNoticeData();
984 // They're a local user, use this: 945 public UUID GroupID = UUID.Zero;
985 UserServiceURL = m_commManager.NetworkServersInfo.UserURL; 946 public string Message = string.Empty;
986 SessionID = userProfile.CurrentAgent.SessionID; 947 public byte[] BinaryBucket = new byte[0];
987 }
988 */
989 }
990
991 } 948 }
992} 949}
993 950