diff options
Adding the groups update (Mantis #4646)
Thanks, mcortez.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | 301 |
1 files changed, 115 insertions, 186 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 61c51e0..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,25 +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 | return m_groupData.GetGroupRecord(null, UUID.Zero, name); | 557 | return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name); |
601 | } | 558 | } |
602 | 559 | ||
603 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) | 560 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) |
604 | { | 561 | { |
605 | 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); |
606 | 563 | ||
607 | m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); | 564 | m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
608 | 565 | ||
609 | // Changing active group changes title, active powers, all kinds of things | 566 | // Changing active group changes title, active powers, all kinds of things |
610 | // 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 |
611 | // 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 |
612 | // updated with new title. | 569 | // updated with new title. |
613 | UpdateAllClientsWithGroupInfo(remoteClient.AgentId); | 570 | UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); |
614 | } | 571 | } |
615 | 572 | ||
616 | /// <summary> | 573 | /// <summary> |
@@ -620,10 +577,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
620 | { | 577 | { |
621 | 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); |
622 | 579 | ||
623 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
624 | 580 | ||
625 | List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); | 581 | List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
626 | GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); | 582 | GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
627 | 583 | ||
628 | List<GroupTitlesData> titles = new List<GroupTitlesData>(); | 584 | List<GroupTitlesData> titles = new List<GroupTitlesData>(); |
629 | foreach (GroupRolesData role in agentRoles) | 585 | foreach (GroupRolesData role in agentRoles) |
@@ -645,8 +601,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
645 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) | 601 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) |
646 | { | 602 | { |
647 | 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); |
648 | 604 | List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID); | |
649 | 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 | } | ||
650 | 613 | ||
651 | return data; | 614 | return data; |
652 | 615 | ||
@@ -656,7 +619,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
656 | { | 619 | { |
657 | 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); |
658 | 621 | ||
659 | List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); | 622 | List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID); |
660 | 623 | ||
661 | return data; | 624 | return data; |
662 | } | 625 | } |
@@ -665,8 +628,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
665 | { | 628 | { |
666 | 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); |
667 | 630 | ||
668 | List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); | 631 | List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID); |
669 | 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 | } | ||
670 | return data; | 640 | return data; |
671 | } | 641 | } |
672 | 642 | ||
@@ -676,17 +646,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
676 | 646 | ||
677 | GroupProfileData profile = new GroupProfileData(); | 647 | GroupProfileData profile = new GroupProfileData(); |
678 | 648 | ||
679 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
680 | 649 | ||
681 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); | 650 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); |
682 | if (groupInfo != null) | 651 | if (groupInfo != null) |
683 | { | 652 | { |
684 | profile.AllowPublish = groupInfo.AllowPublish; | 653 | profile.AllowPublish = groupInfo.AllowPublish; |
685 | profile.Charter = groupInfo.Charter; | 654 | profile.Charter = groupInfo.Charter; |
686 | profile.FounderID = groupInfo.FounderID; | 655 | profile.FounderID = groupInfo.FounderID; |
687 | profile.GroupID = groupID; | 656 | profile.GroupID = groupID; |
688 | profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; | 657 | profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count; |
689 | profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; | 658 | profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count; |
690 | profile.InsigniaID = groupInfo.GroupPicture; | 659 | profile.InsigniaID = groupInfo.GroupPicture; |
691 | profile.MaturePublish = groupInfo.MaturePublish; | 660 | profile.MaturePublish = groupInfo.MaturePublish; |
692 | profile.MembershipFee = groupInfo.MembershipFee; | 661 | profile.MembershipFee = groupInfo.MembershipFee; |
@@ -697,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
697 | profile.ShowInList = groupInfo.ShowInList; | 666 | profile.ShowInList = groupInfo.ShowInList; |
698 | } | 667 | } |
699 | 668 | ||
700 | GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); | 669 | GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
701 | if (memberInfo != null) | 670 | if (memberInfo != null) |
702 | { | 671 | { |
703 | profile.MemberTitle = memberInfo.GroupTitle; | 672 | profile.MemberTitle = memberInfo.GroupTitle; |
@@ -711,7 +680,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
711 | { | 680 | { |
712 | 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); |
713 | 682 | ||
714 | return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); | 683 | return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray(); |
715 | } | 684 | } |
716 | 685 | ||
717 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) | 686 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) |
@@ -721,33 +690,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
721 | "[GROUPS]: {0} called with groupID={1}, agentID={2}", | 690 | "[GROUPS]: {0} called with groupID={1}, agentID={2}", |
722 | System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); | 691 | System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); |
723 | 692 | ||
724 | return m_groupData.GetAgentGroupMembership(null, agentID, groupID); | 693 | return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID); |
725 | } | 694 | } |
726 | 695 | ||
727 | 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) |
728 | { | 697 | { |
729 | 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); |
730 | 699 | ||
731 | // TODO: Security Check? | 700 | // Note: Permissions checking for modification rights is handled by the Groups Server/Service |
732 | 701 | m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); | |
733 | m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); | ||
734 | } | 702 | } |
735 | 703 | ||
736 | public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) | 704 | public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) |
737 | { | 705 | { |
738 | // TODO: Security Check? | 706 | // Note: Permissions checking for modification rights is handled by the Groups Server/Service |
739 | 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); |
740 | 708 | ||
741 | m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); | 709 | m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile); |
742 | } | 710 | } |
743 | 711 | ||
744 | 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) |
745 | { | 713 | { |
746 | 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); |
747 | 715 | ||
748 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | 716 | if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null) |
749 | |||
750 | if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null) | ||
751 | { | 717 | { |
752 | 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."); |
753 | return UUID.Zero; | 719 | return UUID.Zero; |
@@ -761,14 +727,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
761 | 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."); |
762 | return UUID.Zero; | 728 | return UUID.Zero; |
763 | } | 729 | } |
764 | money.ApplyGroupCreationCharge(remoteClient.AgentId); | 730 | money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient)); |
765 | } | 731 | } |
766 | 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)); |
767 | 733 | ||
768 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); | 734 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); |
769 | 735 | ||
770 | // Update the founder with new group information. | 736 | // Update the founder with new group information. |
771 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 737 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
772 | 738 | ||
773 | return groupID; | 739 | return groupID; |
774 | } | 740 | } |
@@ -779,7 +745,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
779 | 745 | ||
780 | // 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? |
781 | 747 | ||
782 | return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); | 748 | return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray(); |
783 | } | 749 | } |
784 | 750 | ||
785 | /// <summary> | 751 | /// <summary> |
@@ -789,7 +755,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
789 | { | 755 | { |
790 | 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); |
791 | 757 | ||
792 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); | 758 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID); |
793 | if (membership != null) | 759 | if (membership != null) |
794 | { | 760 | { |
795 | return membership.GroupTitle; | 761 | return membership.GroupTitle; |
@@ -804,13 +770,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
804 | { | 770 | { |
805 | 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); |
806 | 772 | ||
807 | m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); | 773 | m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID); |
808 | 774 | ||
809 | // 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 |
810 | // 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 |
811 | // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID) | 777 | // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) |
812 | 778 | ||
813 | UpdateAllClientsWithGroupInfo(remoteClient.AgentId); | 779 | UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); |
814 | } | 780 | } |
815 | 781 | ||
816 | 782 | ||
@@ -820,16 +786,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
820 | 786 | ||
821 | // Security Checks are handled in the Groups Service. | 787 | // Security Checks are handled in the Groups Service. |
822 | 788 | ||
823 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
824 | |||
825 | switch ((OpenMetaverse.GroupRoleUpdate)updateType) | 789 | switch ((OpenMetaverse.GroupRoleUpdate)updateType) |
826 | { | 790 | { |
827 | case OpenMetaverse.GroupRoleUpdate.Create: | 791 | case OpenMetaverse.GroupRoleUpdate.Create: |
828 | m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); | 792 | m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers); |
829 | break; | 793 | break; |
830 | 794 | ||
831 | case OpenMetaverse.GroupRoleUpdate.Delete: | 795 | case OpenMetaverse.GroupRoleUpdate.Delete: |
832 | m_groupData.RemoveGroupRole(grID, groupID, roleID); | 796 | m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID); |
833 | break; | 797 | break; |
834 | 798 | ||
835 | case OpenMetaverse.GroupRoleUpdate.UpdateAll: | 799 | case OpenMetaverse.GroupRoleUpdate.UpdateAll: |
@@ -840,7 +804,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
840 | GroupPowers gp = (GroupPowers)powers; | 804 | GroupPowers gp = (GroupPowers)powers; |
841 | 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()); |
842 | } | 806 | } |
843 | m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); | 807 | m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers); |
844 | break; | 808 | break; |
845 | 809 | ||
846 | case OpenMetaverse.GroupRoleUpdate.NoUpdate: | 810 | case OpenMetaverse.GroupRoleUpdate.NoUpdate: |
@@ -851,7 +815,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
851 | } | 815 | } |
852 | 816 | ||
853 | // 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. |
854 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 818 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
855 | } | 819 | } |
856 | 820 | ||
857 | 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) |
@@ -859,18 +823,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
859 | 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); |
860 | // Todo: Security check | 824 | // Todo: Security check |
861 | 825 | ||
862 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
863 | |||
864 | switch (changes) | 826 | switch (changes) |
865 | { | 827 | { |
866 | case 0: | 828 | case 0: |
867 | // Add | 829 | // Add |
868 | m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); | 830 | m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); |
869 | 831 | ||
870 | break; | 832 | break; |
871 | case 1: | 833 | case 1: |
872 | // Remove | 834 | // Remove |
873 | m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); | 835 | m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); |
874 | 836 | ||
875 | break; | 837 | break; |
876 | default: | 838 | default: |
@@ -879,25 +841,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
879 | } | 841 | } |
880 | 842 | ||
881 | // 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. |
882 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 844 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
883 | } | 845 | } |
884 | 846 | ||
885 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) | 847 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) |
886 | { | 848 | { |
887 | 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); |
888 | 850 | ||
889 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | 851 | GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID); |
890 | |||
891 | GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID); | ||
892 | 852 | ||
893 | if (data != null) | 853 | if (data != null) |
894 | { | 854 | { |
895 | GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); | 855 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); |
896 | 856 | ||
897 | GridInstantMessage msg = new GridInstantMessage(); | 857 | GridInstantMessage msg = new GridInstantMessage(); |
898 | msg.imSessionID = UUID.Zero.Guid; | 858 | msg.imSessionID = UUID.Zero.Guid; |
899 | msg.fromAgentID = data.GroupID.Guid; | 859 | msg.fromAgentID = data.GroupID.Guid; |
900 | msg.toAgentID = remoteClient.AgentId.Guid; | 860 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; |
901 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 861 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
902 | msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; | 862 | msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; |
903 | msg.message = data.noticeData.Subject + "|" + data.Message; | 863 | msg.message = data.noticeData.Subject + "|" + data.Message; |
@@ -909,7 +869,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
909 | msg.RegionID = UUID.Zero.Guid; | 869 | msg.RegionID = UUID.Zero.Guid; |
910 | msg.binaryBucket = data.BinaryBucket; | 870 | msg.binaryBucket = data.BinaryBucket; |
911 | 871 | ||
912 | OutgoingInstantMessage(msg, remoteClient.AgentId); | 872 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
913 | } | 873 | } |
914 | 874 | ||
915 | } | 875 | } |
@@ -929,7 +889,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
929 | msg.Position = Vector3.Zero; | 889 | msg.Position = Vector3.Zero; |
930 | msg.RegionID = UUID.Zero.Guid; | 890 | msg.RegionID = UUID.Zero.Guid; |
931 | 891 | ||
932 | GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); | 892 | GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID); |
933 | if (info != null) | 893 | if (info != null) |
934 | { | 894 | { |
935 | msg.fromAgentID = info.GroupID.Guid; | 895 | msg.fromAgentID = info.GroupID.Guid; |
@@ -956,7 +916,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
956 | 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); |
957 | 917 | ||
958 | // Send agent information about his groups | 918 | // Send agent information about his groups |
959 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 919 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
960 | } | 920 | } |
961 | 921 | ||
962 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) | 922 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) |
@@ -964,19 +924,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
964 | 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); |
965 | 925 | ||
966 | // 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 |
967 | m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); | 927 | m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero); |
968 | 928 | ||
969 | remoteClient.SendJoinGroupReply(groupID, true); | 929 | remoteClient.SendJoinGroupReply(groupID, true); |
970 | 930 | ||
971 | // Should this send updates to everyone in the group? | 931 | // Should this send updates to everyone in the group? |
972 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 932 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
973 | } | 933 | } |
974 | 934 | ||
975 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) | 935 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) |
976 | { | 936 | { |
977 | 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); |
978 | 938 | ||
979 | m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); | 939 | m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
980 | 940 | ||
981 | remoteClient.SendLeaveGroupReply(groupID, true); | 941 | remoteClient.SendLeaveGroupReply(groupID, true); |
982 | 942 | ||
@@ -984,33 +944,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
984 | 944 | ||
985 | // 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 |
986 | // Should this also update everyone who is in the group? | 946 | // Should this also update everyone who is in the group? |
987 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 947 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
988 | } | 948 | } |
989 | 949 | ||
990 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) | 950 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) |
991 | { | 951 | { |
992 | 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); |
993 | 953 | ||
994 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
995 | 954 | ||
996 | // Todo: Security check? | 955 | // Todo: Security check? |
997 | m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); | 956 | m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID); |
998 | 957 | ||
999 | remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); | 958 | remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true); |
959 | |||
960 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); | ||
1000 | 961 | ||
1001 | GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); | ||
1002 | 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); |
1003 | if ((groupInfo == null) || (account == null)) | 963 | if ((groupInfo == null) || (account == null)) |
1004 | { | 964 | { |
1005 | return; | 965 | return; |
1006 | } | 966 | } |
1007 | |||
1008 | 967 | ||
1009 | // Send Message to Ejectee | 968 | // Send Message to Ejectee |
1010 | GridInstantMessage msg = new GridInstantMessage(); | 969 | GridInstantMessage msg = new GridInstantMessage(); |
1011 | 970 | ||
1012 | msg.imSessionID = UUID.Zero.Guid; | 971 | msg.imSessionID = UUID.Zero.Guid; |
1013 | msg.fromAgentID = remoteClient.AgentId.Guid; | 972 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1014 | // msg.fromAgentID = info.GroupID; | 973 | // msg.fromAgentID = info.GroupID; |
1015 | msg.toAgentID = ejecteeID.Guid; | 974 | msg.toAgentID = ejecteeID.Guid; |
1016 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 975 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
@@ -1036,8 +995,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1036 | 995 | ||
1037 | msg = new GridInstantMessage(); | 996 | msg = new GridInstantMessage(); |
1038 | msg.imSessionID = UUID.Zero.Guid; | 997 | msg.imSessionID = UUID.Zero.Guid; |
1039 | msg.fromAgentID = remoteClient.AgentId.Guid; | 998 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1040 | msg.toAgentID = remoteClient.AgentId.Guid; | 999 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; |
1041 | msg.timestamp = 0; | 1000 | msg.timestamp = 0; |
1042 | msg.fromAgentName = remoteClient.Name; | 1001 | msg.fromAgentName = remoteClient.Name; |
1043 | if (account != null) | 1002 | if (account != null) |
@@ -1055,7 +1014,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1055 | msg.Position = Vector3.Zero; | 1014 | msg.Position = Vector3.Zero; |
1056 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; | 1015 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; |
1057 | msg.binaryBucket = new byte[0]; | 1016 | msg.binaryBucket = new byte[0]; |
1058 | OutgoingInstantMessage(msg, remoteClient.AgentId); | 1017 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
1059 | 1018 | ||
1060 | 1019 | ||
1061 | // SL sends out messages to everyone in the group | 1020 | // SL sends out messages to everyone in the group |
@@ -1069,13 +1028,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1069 | 1028 | ||
1070 | // 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 |
1071 | UUID InviteID = UUID.Random(); | 1030 | UUID InviteID = UUID.Random(); |
1072 | GroupRequestID grid = GetClientGroupRequestID(remoteClient); | ||
1073 | 1031 | ||
1074 | m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); | 1032 | m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID); |
1075 | 1033 | ||
1076 | // 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 |
1077 | // 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. |
1078 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); | 1036 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID); |
1079 | 1037 | ||
1080 | if (inviteInfo != null) | 1038 | if (inviteInfo != null) |
1081 | { | 1039 | { |
@@ -1087,7 +1045,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1087 | 1045 | ||
1088 | msg.imSessionID = inviteUUID; | 1046 | msg.imSessionID = inviteUUID; |
1089 | 1047 | ||
1090 | // msg.fromAgentID = remoteClient.AgentId.Guid; | 1048 | // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1091 | msg.fromAgentID = groupID.Guid; | 1049 | msg.fromAgentID = groupID.Guid; |
1092 | msg.toAgentID = invitedAgentID.Guid; | 1050 | msg.toAgentID = invitedAgentID.Guid; |
1093 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 1051 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
@@ -1140,57 +1098,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1140 | return child; | 1098 | return child; |
1141 | } | 1099 | } |
1142 | 1100 | ||
1143 | private GroupRequestID GetClientGroupRequestID(IClientAPI client) | ||
1144 | { | ||
1145 | if (client == null) | ||
1146 | { | ||
1147 | return new GroupRequestID(); | ||
1148 | } | ||
1149 | |||
1150 | lock (m_clientRequestIDInfo) | ||
1151 | { | ||
1152 | if (!m_clientRequestIDInfo.ContainsKey(client.AgentId)) | ||
1153 | { | ||
1154 | GroupRequestIDInfo info = new GroupRequestIDInfo(); | ||
1155 | info.RequestID.AgentID = client.AgentId; | ||
1156 | info.RequestID.SessionID = client.SessionId; | ||
1157 | |||
1158 | //UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId); | ||
1159 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId); | ||
1160 | if (account == null) | ||
1161 | { | ||
1162 | // This should be impossible. If I've been passed a reference to a client | ||
1163 | // that client should be registered with the UserService. So something | ||
1164 | // is horribly wrong somewhere. | ||
1165 | |||
1166 | m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId); | ||
1167 | |||
1168 | // Default to local user service and hope for the best? | ||
1169 | // REFACTORING PROBLEM | ||
1170 | //info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; | ||
1171 | |||
1172 | } | ||
1173 | else | ||
1174 | { | ||
1175 | string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; | ||
1176 | object homeUriObj; | ||
1177 | if (account.ServiceURLs.TryGetValue("HomeURI", out homeUriObj) && homeUriObj != null) | ||
1178 | domain = homeUriObj.ToString(); | ||
1179 | // They're a local user, use this: | ||
1180 | info.RequestID.UserServiceURL = domain; | ||
1181 | } | ||
1182 | |||
1183 | m_clientRequestIDInfo.Add(client.AgentId, info); | ||
1184 | } | ||
1185 | |||
1186 | m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now; | ||
1187 | |||
1188 | return m_clientRequestIDInfo[client.AgentId].RequestID; | ||
1189 | } | ||
1190 | // Unreachable code! | ||
1191 | // return new GroupRequestID(); | ||
1192 | } | ||
1193 | |||
1194 | /// <summary> | 1101 | /// <summary> |
1195 | /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. | 1102 | /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. |
1196 | /// </summary> | 1103 | /// </summary> |
@@ -1209,7 +1116,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1209 | 1116 | ||
1210 | foreach (GroupMembershipData membership in data) | 1117 | foreach (GroupMembershipData membership in data) |
1211 | { | 1118 | { |
1212 | if (remoteClient.AgentId != dataForAgentID) | 1119 | if (GetRequestingAgentID(remoteClient) != dataForAgentID) |
1213 | { | 1120 | { |
1214 | if (!membership.ListInProfile) | 1121 | if (!membership.ListInProfile) |
1215 | { | 1122 | { |
@@ -1237,13 +1144,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1237 | OSDMap llDataStruct = new OSDMap(3); | 1144 | OSDMap llDataStruct = new OSDMap(3); |
1238 | llDataStruct.Add("AgentData", AgentData); | 1145 | llDataStruct.Add("AgentData", AgentData); |
1239 | llDataStruct.Add("GroupData", GroupData); | 1146 | llDataStruct.Add("GroupData", GroupData); |
1240 | 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 | } | ||
1241 | 1153 | ||
1242 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); | 1154 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); |
1243 | 1155 | ||
1244 | if (queue != null) | 1156 | if (queue != null) |
1245 | { | 1157 | { |
1246 | queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId); | 1158 | queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); |
1247 | } | 1159 | } |
1248 | 1160 | ||
1249 | } | 1161 | } |
@@ -1316,7 +1228,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1316 | /// <returns></returns> | 1228 | /// <returns></returns> |
1317 | private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) | 1229 | private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) |
1318 | { | 1230 | { |
1319 | List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); | 1231 | List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID); |
1320 | GroupMembershipData[] membershipArray; | 1232 | GroupMembershipData[] membershipArray; |
1321 | 1233 | ||
1322 | if (requestingClient.AgentId != dataForAgentID) | 1234 | if (requestingClient.AgentId != dataForAgentID) |
@@ -1338,7 +1250,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1338 | 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); |
1339 | foreach (GroupMembershipData membership in membershipArray) | 1251 | foreach (GroupMembershipData membership in membershipArray) |
1340 | { | 1252 | { |
1341 | 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); |
1342 | } | 1254 | } |
1343 | } | 1255 | } |
1344 | 1256 | ||
@@ -1396,7 +1308,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1396 | // | 1308 | // |
1397 | } | 1309 | } |
1398 | 1310 | ||
1399 | #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 | } | ||
1400 | } | 1322 | } |
1401 | 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 | } | ||
1402 | } | 1331 | } |