aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs321
1 files changed, 115 insertions, 206 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index eb630de..6b942cb 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -89,16 +89,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
89 89
90 private IGroupsServicesConnector m_groupData = null; 90 private IGroupsServicesConnector m_groupData = null;
91 91
92 class GroupRequestIDInfo
93 {
94 public GroupRequestID RequestID = new GroupRequestID();
95 public DateTime LastUsedTMStamp = DateTime.MinValue;
96 }
97 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
98 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
99 private Timer m_clientRequestIDFlushTimer;
100
101
102 // Configuration settings 92 // Configuration settings
103 private bool m_groupsEnabled = false; 93 private bool m_groupsEnabled = false;
104 private bool m_groupNoticesEnabled = true; 94 private bool m_groupNoticesEnabled = true;
@@ -135,30 +125,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
135 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); 125 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
136 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 126 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
137 127
138 m_clientRequestIDFlushTimer = new Timer();
139 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
140 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
141 m_clientRequestIDFlushTimer.AutoReset = true;
142 m_clientRequestIDFlushTimer.Start();
143 }
144 }
145
146 void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
147 {
148 lock (m_clientRequestIDInfo)
149 {
150 TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
151 UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
152 foreach (UUID key in CurrentKeys)
153 {
154 if (m_clientRequestIDInfo.ContainsKey(key))
155 {
156 if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
157 {
158 m_clientRequestIDInfo.Remove(key);
159 }
160 }
161 }
162 } 128 }
163 } 129 }
164 130
@@ -236,8 +202,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
236 return; 202 return;
237 203
238 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 204 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
239
240 m_clientRequestIDFlushTimer.Stop();
241 } 205 }
242 206
243 public Type ReplaceableInterface 207 public Type ReplaceableInterface
@@ -274,14 +238,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
274 // Used for Notices and Group Invites/Accept/Reject 238 // Used for Notices and Group Invites/Accept/Reject
275 client.OnInstantMessage += OnInstantMessage; 239 client.OnInstantMessage += OnInstantMessage;
276 240
277 lock (m_clientRequestIDInfo) 241 // Send client thier groups information.
278 {
279 if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
280 {
281 // flush any old RequestID information
282 m_clientRequestIDInfo.Remove(client.AgentId);
283 }
284 }
285 SendAgentGroupDataUpdate(client, client.AgentId); 242 SendAgentGroupDataUpdate(client, client.AgentId);
286 } 243 }
287 244
@@ -289,7 +246,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
289 { 246 {
290 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 247 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
291 248
292 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); 249 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
293 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 250 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
294 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 251 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
295 } 252 }
@@ -338,9 +295,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
338 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); 295 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
339 296
340 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 297 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
341 remoteClient.SendDirGroupsReply( 298 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray());
342 queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); 299 }
343 } 300
344 } 301 }
345 302
346 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) 303 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
@@ -352,7 +309,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
352 string activeGroupName = string.Empty; 309 string activeGroupName = string.Empty;
353 ulong activeGroupPowers = (ulong)GroupPowers.None; 310 ulong activeGroupPowers = (ulong)GroupPowers.None;
354 311
355 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); 312 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
356 if (membership != null) 313 if (membership != null)
357 { 314 {
358 activeGroupID = membership.GroupID; 315 activeGroupID = membership.GroupID;
@@ -371,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
371 328
372 string GroupName; 329 string GroupName;
373 330
374 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); 331 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
375 if (group != null) 332 if (group != null)
376 { 333 {
377 GroupName = group.GroupName; 334 GroupName = group.GroupName;
@@ -392,7 +349,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
392 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 349 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
393 { 350 {
394 UUID inviteID = new UUID(im.imSessionID); 351 UUID inviteID = new UUID(im.imSessionID);
395 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 352 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
396 353
397 if (inviteInfo == null) 354 if (inviteInfo == null)
398 { 355 {
@@ -411,7 +368,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
411 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 368 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
412 369
413 // and the sessionid is the role 370 // and the sessionid is the role
414 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 371 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
415 372
416 GridInstantMessage msg = new GridInstantMessage(); 373 GridInstantMessage msg = new GridInstantMessage();
417 msg.imSessionID = UUID.Zero.Guid; 374 msg.imSessionID = UUID.Zero.Guid;
@@ -435,14 +392,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
435 // TODO: If the inviter is still online, they need an agent dataupdate 392 // TODO: If the inviter is still online, they need an agent dataupdate
436 // and maybe group membership updates for the invitee 393 // and maybe group membership updates for the invitee
437 394
438 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 395 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
439 } 396 }
440 397
441 // Reject 398 // Reject
442 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 399 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
443 { 400 {
444 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 401 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
445 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 402 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
446 } 403 }
447 } 404 }
448 } 405 }
@@ -456,7 +413,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
456 } 413 }
457 414
458 UUID GroupID = new UUID(im.toAgentID); 415 UUID GroupID = new UUID(im.toAgentID);
459 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) 416 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null)
460 { 417 {
461 UUID NoticeID = UUID.Random(); 418 UUID NoticeID = UUID.Random();
462 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 419 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -500,14 +457,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
500 } 457 }
501 458
502 459
503 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 460 m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
504 if (OnNewGroupNotice != null) 461 if (OnNewGroupNotice != null)
505 { 462 {
506 OnNewGroupNotice(GroupID, NoticeID); 463 OnNewGroupNotice(GroupID, NoticeID);
507 } 464 }
508 465
509 // Send notice out to everyone that wants notices 466 // Send notice out to everyone that wants notices
510 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) 467 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID))
511 { 468 {
512 if (m_debugEnabled) 469 if (m_debugEnabled)
513 { 470 {
@@ -592,45 +549,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
592 549
593 public GroupRecord GetGroupRecord(UUID GroupID) 550 public GroupRecord GetGroupRecord(UUID GroupID)
594 { 551 {
595 return m_groupData.GetGroupRecord(null, GroupID, null); 552 return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
596 } 553 }
597 554
598 public GroupRecord GetGroupRecord(string name) 555 public GroupRecord GetGroupRecord(string name)
599 { 556 {
600 if (m_debugEnabled) 557 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
601 m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
602
603 // XXX: Two call implementation. This could be done in a single call if the server itself were to
604 // implement the code below.
605
606 List<DirGroupsReplyData> groups = m_groupData.FindGroups(null, name);
607
608 DirGroupsReplyData? foundGroup = null;
609
610 foreach (DirGroupsReplyData group in groups)
611 {
612 // We must have an exact match - I believe FindGroups will return partial matches
613 if (group.groupName == name)
614 foundGroup = group;
615 }
616
617 if (null == foundGroup)
618 return null;
619
620 return GetGroupRecord(((DirGroupsReplyData)foundGroup).groupID);
621 } 558 }
622 559
623 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 560 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
624 { 561 {
625 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 562 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
626 563
627 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 564 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
628 565
629 // Changing active group changes title, active powers, all kinds of things 566 // Changing active group changes title, active powers, all kinds of things
630 // anyone who is in any region that can see this client, should probably be 567 // anyone who is in any region that can see this client, should probably be
631 // updated with new group info. At a minimum, they should get ScenePresence 568 // updated with new group info. At a minimum, they should get ScenePresence
632 // updated with new title. 569 // updated with new title.
633 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 570 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
634 } 571 }
635 572
636 /// <summary> 573 /// <summary>
@@ -640,10 +577,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
640 { 577 {
641 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 578 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
642 579
643 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
644 580
645 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); 581 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
646 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 582 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
647 583
648 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 584 List<GroupTitlesData> titles = new List<GroupTitlesData>();
649 foreach (GroupRolesData role in agentRoles) 585 foreach (GroupRolesData role in agentRoles)
@@ -665,8 +601,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
665 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 601 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
666 { 602 {
667 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 603 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
668 604 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
669 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); 605
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 }
670 613
671 return data; 614 return data;
672 615
@@ -676,7 +619,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
676 { 619 {
677 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 620 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
678 621
679 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); 622 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID);
680 623
681 return data; 624 return data;
682 } 625 }
@@ -685,8 +628,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
685 { 628 {
686 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 629 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
687 630
688 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); 631 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID);
689 632
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 }
690 return data; 640 return data;
691 } 641 }
692 642
@@ -696,17 +646,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
696 646
697 GroupProfileData profile = new GroupProfileData(); 647 GroupProfileData profile = new GroupProfileData();
698 648
699 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
700 649
701 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); 650 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
702 if (groupInfo != null) 651 if (groupInfo != null)
703 { 652 {
704 profile.AllowPublish = groupInfo.AllowPublish; 653 profile.AllowPublish = groupInfo.AllowPublish;
705 profile.Charter = groupInfo.Charter; 654 profile.Charter = groupInfo.Charter;
706 profile.FounderID = groupInfo.FounderID; 655 profile.FounderID = groupInfo.FounderID;
707 profile.GroupID = groupID; 656 profile.GroupID = groupID;
708 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; 657 profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count;
709 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; 658 profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count;
710 profile.InsigniaID = groupInfo.GroupPicture; 659 profile.InsigniaID = groupInfo.GroupPicture;
711 profile.MaturePublish = groupInfo.MaturePublish; 660 profile.MaturePublish = groupInfo.MaturePublish;
712 profile.MembershipFee = groupInfo.MembershipFee; 661 profile.MembershipFee = groupInfo.MembershipFee;
@@ -717,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
717 profile.ShowInList = groupInfo.ShowInList; 666 profile.ShowInList = groupInfo.ShowInList;
718 } 667 }
719 668
720 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 669 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
721 if (memberInfo != null) 670 if (memberInfo != null)
722 { 671 {
723 profile.MemberTitle = memberInfo.GroupTitle; 672 profile.MemberTitle = memberInfo.GroupTitle;
@@ -731,7 +680,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
731 { 680 {
732 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 681 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
733 682
734 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); 683 return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray();
735 } 684 }
736 685
737 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 686 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
@@ -741,33 +690,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
741 "[GROUPS]: {0} called with groupID={1}, agentID={2}", 690 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
742 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); 691 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
743 692
744 return m_groupData.GetAgentGroupMembership(null, agentID, groupID); 693 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
745 } 694 }
746 695
747 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 696 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
748 { 697 {
749 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 698 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
750 699
751 // TODO: Security Check? 700 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
752 701 m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
753 m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
754 } 702 }
755 703
756 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 704 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
757 { 705 {
758 // TODO: Security Check? 706 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
759 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 707 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
760 708
761 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); 709 m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile);
762 } 710 }
763 711
764 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 712 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
765 { 713 {
766 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 714 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
767 715
768 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 716 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null)
769
770 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
771 { 717 {
772 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 718 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
773 return UUID.Zero; 719 return UUID.Zero;
@@ -781,14 +727,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
781 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); 727 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
782 return UUID.Zero; 728 return UUID.Zero;
783 } 729 }
784 money.ApplyGroupCreationCharge(remoteClient.AgentId); 730 money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient));
785 } 731 }
786 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); 732 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
787 733
788 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 734 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
789 735
790 // Update the founder with new group information. 736 // Update the founder with new group information.
791 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 737 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
792 738
793 return groupID; 739 return groupID;
794 } 740 }
@@ -799,7 +745,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
799 745
800 // ToDo: check if agent is a member of group and is allowed to see notices? 746 // ToDo: check if agent is a member of group and is allowed to see notices?
801 747
802 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); 748 return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray();
803 } 749 }
804 750
805 /// <summary> 751 /// <summary>
@@ -809,7 +755,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
809 { 755 {
810 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 756 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
811 757
812 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); 758 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID);
813 if (membership != null) 759 if (membership != null)
814 { 760 {
815 return membership.GroupTitle; 761 return membership.GroupTitle;
@@ -824,13 +770,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
824 { 770 {
825 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 771 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
826 772
827 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); 773 m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID);
828 774
829 // TODO: Not sure what all is needed here, but if the active group role change is for the group 775 // TODO: Not sure what all is needed here, but if the active group role change is for the group
830 // the client currently has set active, then we need to do a scene presence update too 776 // the client currently has set active, then we need to do a scene presence update too
831 // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID) 777 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
832 778
833 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 779 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
834 } 780 }
835 781
836 782
@@ -840,16 +786,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
840 786
841 // Security Checks are handled in the Groups Service. 787 // Security Checks are handled in the Groups Service.
842 788
843 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
844
845 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 789 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
846 { 790 {
847 case OpenMetaverse.GroupRoleUpdate.Create: 791 case OpenMetaverse.GroupRoleUpdate.Create:
848 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); 792 m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers);
849 break; 793 break;
850 794
851 case OpenMetaverse.GroupRoleUpdate.Delete: 795 case OpenMetaverse.GroupRoleUpdate.Delete:
852 m_groupData.RemoveGroupRole(grID, groupID, roleID); 796 m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID);
853 break; 797 break;
854 798
855 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 799 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@@ -860,7 +804,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
860 GroupPowers gp = (GroupPowers)powers; 804 GroupPowers gp = (GroupPowers)powers;
861 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); 805 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
862 } 806 }
863 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); 807 m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers);
864 break; 808 break;
865 809
866 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 810 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -871,7 +815,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
871 } 815 }
872 816
873 // TODO: This update really should send out updates for everyone in the role that just got changed. 817 // TODO: This update really should send out updates for everyone in the role that just got changed.
874 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 818 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
875 } 819 }
876 820
877 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 821 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -879,18 +823,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
879 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 823 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
880 // Todo: Security check 824 // Todo: Security check
881 825
882 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
883
884 switch (changes) 826 switch (changes)
885 { 827 {
886 case 0: 828 case 0:
887 // Add 829 // Add
888 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); 830 m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
889 831
890 break; 832 break;
891 case 1: 833 case 1:
892 // Remove 834 // Remove
893 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); 835 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
894 836
895 break; 837 break;
896 default: 838 default:
@@ -899,25 +841,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
899 } 841 }
900 842
901 // TODO: This update really should send out updates for everyone in the role that just got changed. 843 // TODO: This update really should send out updates for everyone in the role that just got changed.
902 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 844 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
903 } 845 }
904 846
905 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 847 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
906 { 848 {
907 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 849 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
908 850
909 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 851 GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID);
910
911 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
912 852
913 if (data != null) 853 if (data != null)
914 { 854 {
915 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); 855 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null);
916 856
917 GridInstantMessage msg = new GridInstantMessage(); 857 GridInstantMessage msg = new GridInstantMessage();
918 msg.imSessionID = UUID.Zero.Guid; 858 msg.imSessionID = UUID.Zero.Guid;
919 msg.fromAgentID = data.GroupID.Guid; 859 msg.fromAgentID = data.GroupID.Guid;
920 msg.toAgentID = remoteClient.AgentId.Guid; 860 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
921 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 861 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
922 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; 862 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
923 msg.message = data.noticeData.Subject + "|" + data.Message; 863 msg.message = data.noticeData.Subject + "|" + data.Message;
@@ -929,7 +869,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
929 msg.RegionID = UUID.Zero.Guid; 869 msg.RegionID = UUID.Zero.Guid;
930 msg.binaryBucket = data.BinaryBucket; 870 msg.binaryBucket = data.BinaryBucket;
931 871
932 OutgoingInstantMessage(msg, remoteClient.AgentId); 872 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
933 } 873 }
934 874
935 } 875 }
@@ -949,7 +889,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
949 msg.Position = Vector3.Zero; 889 msg.Position = Vector3.Zero;
950 msg.RegionID = UUID.Zero.Guid; 890 msg.RegionID = UUID.Zero.Guid;
951 891
952 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); 892 GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID);
953 if (info != null) 893 if (info != null)
954 { 894 {
955 msg.fromAgentID = info.GroupID.Guid; 895 msg.fromAgentID = info.GroupID.Guid;
@@ -976,7 +916,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
976 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 916 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
977 917
978 // Send agent information about his groups 918 // Send agent information about his groups
979 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 919 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
980 } 920 }
981 921
982 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 922 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -984,19 +924,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
984 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 924 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
985 925
986 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 926 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
987 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); 927 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
988 928
989 remoteClient.SendJoinGroupReply(groupID, true); 929 remoteClient.SendJoinGroupReply(groupID, true);
990 930
991 // Should this send updates to everyone in the group? 931 // Should this send updates to everyone in the group?
992 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 932 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
993 } 933 }
994 934
995 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 935 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
996 { 936 {
997 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 937 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
998 938
999 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 939 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
1000 940
1001 remoteClient.SendLeaveGroupReply(groupID, true); 941 remoteClient.SendLeaveGroupReply(groupID, true);
1002 942
@@ -1004,33 +944,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1004 944
1005 // SL sends out notifcations to the group messaging session that the person has left 945 // SL sends out notifcations to the group messaging session that the person has left
1006 // Should this also update everyone who is in the group? 946 // Should this also update everyone who is in the group?
1007 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 947 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
1008 } 948 }
1009 949
1010 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 950 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
1011 { 951 {
1012 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 952 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1013 953
1014 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
1015 954
1016 // Todo: Security check? 955 // Todo: Security check?
1017 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); 956 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID);
1018 957
1019 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 958 remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true);
959
960 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
1020 961
1021 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
1022 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); 962 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID);
1023 if ((groupInfo == null) || (account == null)) 963 if ((groupInfo == null) || (account == null))
1024 { 964 {
1025 return; 965 return;
1026 } 966 }
1027
1028 967
1029 // Send Message to Ejectee 968 // Send Message to Ejectee
1030 GridInstantMessage msg = new GridInstantMessage(); 969 GridInstantMessage msg = new GridInstantMessage();
1031 970
1032 msg.imSessionID = UUID.Zero.Guid; 971 msg.imSessionID = UUID.Zero.Guid;
1033 msg.fromAgentID = remoteClient.AgentId.Guid; 972 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1034 // msg.fromAgentID = info.GroupID; 973 // msg.fromAgentID = info.GroupID;
1035 msg.toAgentID = ejecteeID.Guid; 974 msg.toAgentID = ejecteeID.Guid;
1036 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 975 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1056,8 +995,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1056 995
1057 msg = new GridInstantMessage(); 996 msg = new GridInstantMessage();
1058 msg.imSessionID = UUID.Zero.Guid; 997 msg.imSessionID = UUID.Zero.Guid;
1059 msg.fromAgentID = remoteClient.AgentId.Guid; 998 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1060 msg.toAgentID = remoteClient.AgentId.Guid; 999 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
1061 msg.timestamp = 0; 1000 msg.timestamp = 0;
1062 msg.fromAgentName = remoteClient.Name; 1001 msg.fromAgentName = remoteClient.Name;
1063 if (account != null) 1002 if (account != null)
@@ -1075,7 +1014,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1075 msg.Position = Vector3.Zero; 1014 msg.Position = Vector3.Zero;
1076 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; 1015 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
1077 msg.binaryBucket = new byte[0]; 1016 msg.binaryBucket = new byte[0];
1078 OutgoingInstantMessage(msg, remoteClient.AgentId); 1017 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
1079 1018
1080 1019
1081 // SL sends out messages to everyone in the group 1020 // SL sends out messages to everyone in the group
@@ -1089,13 +1028,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1089 1028
1090 // Todo: Security check, probably also want to send some kind of notification 1029 // Todo: Security check, probably also want to send some kind of notification
1091 UUID InviteID = UUID.Random(); 1030 UUID InviteID = UUID.Random();
1092 GroupRequestID grid = GetClientGroupRequestID(remoteClient);
1093 1031
1094 m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); 1032 m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID);
1095 1033
1096 // Check to see if the invite went through, if it did not then it's possible 1034 // Check to see if the invite went through, if it did not then it's possible
1097 // the remoteClient did not validate or did not have permission to invite. 1035 // the remoteClient did not validate or did not have permission to invite.
1098 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); 1036 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID);
1099 1037
1100 if (inviteInfo != null) 1038 if (inviteInfo != null)
1101 { 1039 {
@@ -1107,7 +1045,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1107 1045
1108 msg.imSessionID = inviteUUID; 1046 msg.imSessionID = inviteUUID;
1109 1047
1110 // msg.fromAgentID = remoteClient.AgentId.Guid; 1048 // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1111 msg.fromAgentID = groupID.Guid; 1049 msg.fromAgentID = groupID.Guid;
1112 msg.toAgentID = invitedAgentID.Guid; 1050 msg.toAgentID = invitedAgentID.Guid;
1113 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1051 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1160,57 +1098,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1160 return child; 1098 return child;
1161 } 1099 }
1162 1100
1163 private GroupRequestID GetClientGroupRequestID(IClientAPI client)
1164 {
1165 if (client == null)
1166 {
1167 return new GroupRequestID();
1168 }
1169
1170 lock (m_clientRequestIDInfo)
1171 {
1172 if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
1173 {
1174 GroupRequestIDInfo info = new GroupRequestIDInfo();
1175 info.RequestID.AgentID = client.AgentId;
1176 info.RequestID.SessionID = client.SessionId;
1177
1178 //UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1179 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
1180 if (account == null)
1181 {
1182 // This should be impossible. If I've been passed a reference to a client
1183 // that client should be registered with the UserService. So something
1184 // is horribly wrong somewhere.
1185
1186 m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);
1187
1188 // Default to local user service and hope for the best?
1189 // REFACTORING PROBLEM
1190 //info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1191
1192 }
1193 else
1194 {
1195 string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1196 object homeUriObj;
1197 if (account.ServiceURLs.TryGetValue("HomeURI", out homeUriObj) && homeUriObj != null)
1198 domain = homeUriObj.ToString();
1199 // They're a local user, use this:
1200 info.RequestID.UserServiceURL = domain;
1201 }
1202
1203 m_clientRequestIDInfo.Add(client.AgentId, info);
1204 }
1205
1206 m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
1207
1208 return m_clientRequestIDInfo[client.AgentId].RequestID;
1209 }
1210// Unreachable code!
1211// return new GroupRequestID();
1212 }
1213
1214 /// <summary> 1101 /// <summary>
1215 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1102 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1216 /// </summary> 1103 /// </summary>
@@ -1229,7 +1116,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1229 1116
1230 foreach (GroupMembershipData membership in data) 1117 foreach (GroupMembershipData membership in data)
1231 { 1118 {
1232 if (remoteClient.AgentId != dataForAgentID) 1119 if (GetRequestingAgentID(remoteClient) != dataForAgentID)
1233 { 1120 {
1234 if (!membership.ListInProfile) 1121 if (!membership.ListInProfile)
1235 { 1122 {
@@ -1257,13 +1144,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1257 OSDMap llDataStruct = new OSDMap(3); 1144 OSDMap llDataStruct = new OSDMap(3);
1258 llDataStruct.Add("AgentData", AgentData); 1145 llDataStruct.Add("AgentData", AgentData);
1259 llDataStruct.Add("GroupData", GroupData); 1146 llDataStruct.Add("GroupData", GroupData);
1260 llDataStruct.Add("NewGroupData", NewGroupData); 1147 llDataStruct.Add("NewGroupData", NewGroupData);
1148
1149 if (m_debugEnabled)
1150 {
1151 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1152 }
1261 1153
1262 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 1154 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1263 1155
1264 if (queue != null) 1156 if (queue != null)
1265 { 1157 {
1266 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId); 1158 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
1267 } 1159 }
1268 1160
1269 } 1161 }
@@ -1336,7 +1228,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1336 /// <returns></returns> 1228 /// <returns></returns>
1337 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) 1229 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
1338 { 1230 {
1339 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); 1231 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID);
1340 GroupMembershipData[] membershipArray; 1232 GroupMembershipData[] membershipArray;
1341 1233
1342 if (requestingClient.AgentId != dataForAgentID) 1234 if (requestingClient.AgentId != dataForAgentID)
@@ -1358,7 +1250,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1358 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1250 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
1359 foreach (GroupMembershipData membership in membershipArray) 1251 foreach (GroupMembershipData membership in membershipArray)
1360 { 1252 {
1361 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); 1253 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers);
1362 } 1254 }
1363 } 1255 }
1364 1256
@@ -1416,7 +1308,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1416 // 1308 //
1417 } 1309 }
1418 1310
1419 #endregion 1311 #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 }
1420 } 1322 }
1421 1323
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 }
1422} 1331}