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.cs302
1 files changed, 115 insertions, 187 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 61c51e0..e5dab93 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
@@ -209,14 +175,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
209 } 175 }
210 176
211 scene.EventManager.OnNewClient += OnNewClient; 177 scene.EventManager.OnNewClient += OnNewClient;
212 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
213
214 // The InstantMessageModule itself doesn't do this, 179 // The InstantMessageModule itself doesn't do this,
215 // so lets see if things explode if we don't do it 180 // so lets see if things explode if we don't do it
216 // scene.EventManager.OnClientClosed += OnClientClosed; 181 // scene.EventManager.OnClientClosed += OnClientClosed;
217 182
218 } 183 }
219 184
220 public void RemoveRegion(Scene scene) 185 public void RemoveRegion(Scene scene)
221 { 186 {
222 if (!m_groupsEnabled) 187 if (!m_groupsEnabled)
@@ -236,8 +201,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
236 return; 201 return;
237 202
238 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 203 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
239
240 m_clientRequestIDFlushTimer.Stop();
241 } 204 }
242 205
243 public Type ReplaceableInterface 206 public Type ReplaceableInterface
@@ -274,14 +237,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
274 // Used for Notices and Group Invites/Accept/Reject 237 // Used for Notices and Group Invites/Accept/Reject
275 client.OnInstantMessage += OnInstantMessage; 238 client.OnInstantMessage += OnInstantMessage;
276 239
277 lock (m_clientRequestIDInfo) 240 // 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); 241 SendAgentGroupDataUpdate(client, client.AgentId);
286 } 242 }
287 243
@@ -289,7 +245,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
289 { 245 {
290 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 246 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
291 247
292 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); 248 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
293 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 249 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
294 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 250 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
295 } 251 }
@@ -338,9 +294,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
338 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); 294 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
339 295
340 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 296 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
341 remoteClient.SendDirGroupsReply( 297 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray());
342 queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); 298 }
343 } 299
344 } 300 }
345 301
346 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) 302 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
@@ -352,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
352 string activeGroupName = string.Empty; 308 string activeGroupName = string.Empty;
353 ulong activeGroupPowers = (ulong)GroupPowers.None; 309 ulong activeGroupPowers = (ulong)GroupPowers.None;
354 310
355 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); 311 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
356 if (membership != null) 312 if (membership != null)
357 { 313 {
358 activeGroupID = membership.GroupID; 314 activeGroupID = membership.GroupID;
@@ -371,7 +327,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
371 327
372 string GroupName; 328 string GroupName;
373 329
374 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); 330 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
375 if (group != null) 331 if (group != null)
376 { 332 {
377 GroupName = group.GroupName; 333 GroupName = group.GroupName;
@@ -392,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
392 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 348 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
393 { 349 {
394 UUID inviteID = new UUID(im.imSessionID); 350 UUID inviteID = new UUID(im.imSessionID);
395 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 351 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
396 352
397 if (inviteInfo == null) 353 if (inviteInfo == null)
398 { 354 {
@@ -411,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
411 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 367 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
412 368
413 // and the sessionid is the role 369 // and the sessionid is the role
414 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 370 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
415 371
416 GridInstantMessage msg = new GridInstantMessage(); 372 GridInstantMessage msg = new GridInstantMessage();
417 msg.imSessionID = UUID.Zero.Guid; 373 msg.imSessionID = UUID.Zero.Guid;
@@ -435,14 +391,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
435 // TODO: If the inviter is still online, they need an agent dataupdate 391 // TODO: If the inviter is still online, they need an agent dataupdate
436 // and maybe group membership updates for the invitee 392 // and maybe group membership updates for the invitee
437 393
438 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 394 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
439 } 395 }
440 396
441 // Reject 397 // Reject
442 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 398 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
443 { 399 {
444 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 400 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
445 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 401 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
446 } 402 }
447 } 403 }
448 } 404 }
@@ -456,7 +412,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
456 } 412 }
457 413
458 UUID GroupID = new UUID(im.toAgentID); 414 UUID GroupID = new UUID(im.toAgentID);
459 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) 415 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null)
460 { 416 {
461 UUID NoticeID = UUID.Random(); 417 UUID NoticeID = UUID.Random();
462 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 418 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -500,14 +456,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
500 } 456 }
501 457
502 458
503 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 459 m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
504 if (OnNewGroupNotice != null) 460 if (OnNewGroupNotice != null)
505 { 461 {
506 OnNewGroupNotice(GroupID, NoticeID); 462 OnNewGroupNotice(GroupID, NoticeID);
507 } 463 }
508 464
509 // Send notice out to everyone that wants notices 465 // Send notice out to everyone that wants notices
510 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) 466 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID))
511 { 467 {
512 if (m_debugEnabled) 468 if (m_debugEnabled)
513 { 469 {
@@ -553,7 +509,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
553 IClientAPI ejectee = GetActiveClient(ejecteeID); 509 IClientAPI ejectee = GetActiveClient(ejecteeID);
554 if (ejectee != null) 510 if (ejectee != null)
555 { 511 {
556 UUID groupID = new UUID(im.fromAgentID); 512 UUID groupID = new UUID(im.imSessionID);
557 ejectee.SendAgentDropGroup(groupID); 513 ejectee.SendAgentDropGroup(groupID);
558 } 514 }
559 } 515 }
@@ -592,25 +548,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
592 548
593 public GroupRecord GetGroupRecord(UUID GroupID) 549 public GroupRecord GetGroupRecord(UUID GroupID)
594 { 550 {
595 return m_groupData.GetGroupRecord(null, GroupID, null); 551 return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
596 } 552 }
597 553
598 public GroupRecord GetGroupRecord(string name) 554 public GroupRecord GetGroupRecord(string name)
599 { 555 {
600 return m_groupData.GetGroupRecord(null, UUID.Zero, name); 556 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
601 } 557 }
602 558
603 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 559 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
604 { 560 {
605 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 561 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
606 562
607 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 563 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
608 564
609 // Changing active group changes title, active powers, all kinds of things 565 // 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 566 // 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 567 // updated with new group info. At a minimum, they should get ScenePresence
612 // updated with new title. 568 // updated with new title.
613 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 569 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
614 } 570 }
615 571
616 /// <summary> 572 /// <summary>
@@ -620,10 +576,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
620 { 576 {
621 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 577 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
622 578
623 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
624 579
625 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); 580 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
626 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 581 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
627 582
628 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 583 List<GroupTitlesData> titles = new List<GroupTitlesData>();
629 foreach (GroupRolesData role in agentRoles) 584 foreach (GroupRolesData role in agentRoles)
@@ -645,8 +600,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
645 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 600 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
646 { 601 {
647 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 602 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
603 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
648 604
649 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); 605 if (m_debugEnabled)
606 {
607 foreach (GroupMembersData member in data)
608 {
609 m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
610 }
611 }
650 612
651 return data; 613 return data;
652 614
@@ -656,7 +618,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
656 { 618 {
657 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 619 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
658 620
659 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); 621 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID);
660 622
661 return data; 623 return data;
662 } 624 }
@@ -665,8 +627,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
665 { 627 {
666 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 628 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
667 629
668 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); 630 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID);
669 631
632 if (m_debugEnabled)
633 {
634 foreach (GroupRoleMembersData member in data)
635 {
636 m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
637 }
638 }
670 return data; 639 return data;
671 } 640 }
672 641
@@ -676,17 +645,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
676 645
677 GroupProfileData profile = new GroupProfileData(); 646 GroupProfileData profile = new GroupProfileData();
678 647
679 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
680 648
681 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); 649 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
682 if (groupInfo != null) 650 if (groupInfo != null)
683 { 651 {
684 profile.AllowPublish = groupInfo.AllowPublish; 652 profile.AllowPublish = groupInfo.AllowPublish;
685 profile.Charter = groupInfo.Charter; 653 profile.Charter = groupInfo.Charter;
686 profile.FounderID = groupInfo.FounderID; 654 profile.FounderID = groupInfo.FounderID;
687 profile.GroupID = groupID; 655 profile.GroupID = groupID;
688 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; 656 profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count;
689 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; 657 profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count;
690 profile.InsigniaID = groupInfo.GroupPicture; 658 profile.InsigniaID = groupInfo.GroupPicture;
691 profile.MaturePublish = groupInfo.MaturePublish; 659 profile.MaturePublish = groupInfo.MaturePublish;
692 profile.MembershipFee = groupInfo.MembershipFee; 660 profile.MembershipFee = groupInfo.MembershipFee;
@@ -697,7 +665,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
697 profile.ShowInList = groupInfo.ShowInList; 665 profile.ShowInList = groupInfo.ShowInList;
698 } 666 }
699 667
700 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 668 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
701 if (memberInfo != null) 669 if (memberInfo != null)
702 { 670 {
703 profile.MemberTitle = memberInfo.GroupTitle; 671 profile.MemberTitle = memberInfo.GroupTitle;
@@ -711,7 +679,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
711 { 679 {
712 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 680 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
713 681
714 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); 682 return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray();
715 } 683 }
716 684
717 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 685 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
@@ -721,33 +689,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
721 "[GROUPS]: {0} called with groupID={1}, agentID={2}", 689 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
722 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); 690 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
723 691
724 return m_groupData.GetAgentGroupMembership(null, agentID, groupID); 692 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
725 } 693 }
726 694
727 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 695 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
728 { 696 {
729 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 697 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
730 698
731 // TODO: Security Check? 699 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
732 700 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 } 701 }
735 702
736 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 703 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
737 { 704 {
738 // TODO: Security Check? 705 // 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); 706 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
740 707
741 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); 708 m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile);
742 } 709 }
743 710
744 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 711 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
745 { 712 {
746 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 713 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
747 714
748 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 715 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null)
749
750 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
751 { 716 {
752 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 717 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
753 return UUID.Zero; 718 return UUID.Zero;
@@ -761,14 +726,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
761 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); 726 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
762 return UUID.Zero; 727 return UUID.Zero;
763 } 728 }
764 money.ApplyGroupCreationCharge(remoteClient.AgentId); 729 money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient));
765 } 730 }
766 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); 731 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
767 732
768 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 733 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
769 734
770 // Update the founder with new group information. 735 // Update the founder with new group information.
771 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 736 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
772 737
773 return groupID; 738 return groupID;
774 } 739 }
@@ -779,7 +744,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
779 744
780 // ToDo: check if agent is a member of group and is allowed to see notices? 745 // ToDo: check if agent is a member of group and is allowed to see notices?
781 746
782 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); 747 return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray();
783 } 748 }
784 749
785 /// <summary> 750 /// <summary>
@@ -789,7 +754,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
789 { 754 {
790 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 755 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
791 756
792 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); 757 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID);
793 if (membership != null) 758 if (membership != null)
794 { 759 {
795 return membership.GroupTitle; 760 return membership.GroupTitle;
@@ -804,13 +769,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
804 { 769 {
805 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 770 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
806 771
807 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); 772 m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID);
808 773
809 // TODO: Not sure what all is needed here, but if the active group role change is for the group 774 // 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 775 // 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) 776 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
812 777
813 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 778 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
814 } 779 }
815 780
816 781
@@ -820,16 +785,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
820 785
821 // Security Checks are handled in the Groups Service. 786 // Security Checks are handled in the Groups Service.
822 787
823 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
824
825 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 788 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
826 { 789 {
827 case OpenMetaverse.GroupRoleUpdate.Create: 790 case OpenMetaverse.GroupRoleUpdate.Create:
828 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); 791 m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers);
829 break; 792 break;
830 793
831 case OpenMetaverse.GroupRoleUpdate.Delete: 794 case OpenMetaverse.GroupRoleUpdate.Delete:
832 m_groupData.RemoveGroupRole(grID, groupID, roleID); 795 m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID);
833 break; 796 break;
834 797
835 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 798 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@@ -840,7 +803,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
840 GroupPowers gp = (GroupPowers)powers; 803 GroupPowers gp = (GroupPowers)powers;
841 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); 804 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
842 } 805 }
843 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); 806 m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers);
844 break; 807 break;
845 808
846 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 809 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -851,7 +814,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
851 } 814 }
852 815
853 // TODO: This update really should send out updates for everyone in the role that just got changed. 816 // TODO: This update really should send out updates for everyone in the role that just got changed.
854 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 817 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
855 } 818 }
856 819
857 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 820 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -859,18 +822,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
859 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 822 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
860 // Todo: Security check 823 // Todo: Security check
861 824
862 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
863
864 switch (changes) 825 switch (changes)
865 { 826 {
866 case 0: 827 case 0:
867 // Add 828 // Add
868 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); 829 m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
869 830
870 break; 831 break;
871 case 1: 832 case 1:
872 // Remove 833 // Remove
873 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); 834 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
874 835
875 break; 836 break;
876 default: 837 default:
@@ -879,25 +840,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
879 } 840 }
880 841
881 // TODO: This update really should send out updates for everyone in the role that just got changed. 842 // TODO: This update really should send out updates for everyone in the role that just got changed.
882 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 843 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
883 } 844 }
884 845
885 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 846 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
886 { 847 {
887 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 848 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
888 849
889 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 850 GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID);
890
891 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
892 851
893 if (data != null) 852 if (data != null)
894 { 853 {
895 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); 854 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null);
896 855
897 GridInstantMessage msg = new GridInstantMessage(); 856 GridInstantMessage msg = new GridInstantMessage();
898 msg.imSessionID = UUID.Zero.Guid; 857 msg.imSessionID = UUID.Zero.Guid;
899 msg.fromAgentID = data.GroupID.Guid; 858 msg.fromAgentID = data.GroupID.Guid;
900 msg.toAgentID = remoteClient.AgentId.Guid; 859 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
901 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 860 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
902 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; 861 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
903 msg.message = data.noticeData.Subject + "|" + data.Message; 862 msg.message = data.noticeData.Subject + "|" + data.Message;
@@ -909,7 +868,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
909 msg.RegionID = UUID.Zero.Guid; 868 msg.RegionID = UUID.Zero.Guid;
910 msg.binaryBucket = data.BinaryBucket; 869 msg.binaryBucket = data.BinaryBucket;
911 870
912 OutgoingInstantMessage(msg, remoteClient.AgentId); 871 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
913 } 872 }
914 873
915 } 874 }
@@ -929,7 +888,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
929 msg.Position = Vector3.Zero; 888 msg.Position = Vector3.Zero;
930 msg.RegionID = UUID.Zero.Guid; 889 msg.RegionID = UUID.Zero.Guid;
931 890
932 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); 891 GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID);
933 if (info != null) 892 if (info != null)
934 { 893 {
935 msg.fromAgentID = info.GroupID.Guid; 894 msg.fromAgentID = info.GroupID.Guid;
@@ -956,7 +915,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
956 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 915 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
957 916
958 // Send agent information about his groups 917 // Send agent information about his groups
959 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 918 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
960 } 919 }
961 920
962 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 921 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -964,19 +923,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
964 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 923 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
965 924
966 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 925 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
967 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); 926 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
968 927
969 remoteClient.SendJoinGroupReply(groupID, true); 928 remoteClient.SendJoinGroupReply(groupID, true);
970 929
971 // Should this send updates to everyone in the group? 930 // Should this send updates to everyone in the group?
972 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 931 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
973 } 932 }
974 933
975 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 934 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
976 { 935 {
977 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 936 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
978 937
979 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 938 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
980 939
981 remoteClient.SendLeaveGroupReply(groupID, true); 940 remoteClient.SendLeaveGroupReply(groupID, true);
982 941
@@ -984,33 +943,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
984 943
985 // SL sends out notifcations to the group messaging session that the person has left 944 // 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? 945 // Should this also update everyone who is in the group?
987 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 946 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
988 } 947 }
989 948
990 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 949 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
991 { 950 {
992 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 951 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
993 952
994 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
995 953
996 // Todo: Security check? 954 // Todo: Security check?
997 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); 955 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID);
956
957 remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true);
998 958
999 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 959 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
1000 960
1001 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
1002 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); 961 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID);
1003 if ((groupInfo == null) || (account == null)) 962 if ((groupInfo == null) || (account == null))
1004 { 963 {
1005 return; 964 return;
1006 } 965 }
1007
1008 966
1009 // Send Message to Ejectee 967 // Send Message to Ejectee
1010 GridInstantMessage msg = new GridInstantMessage(); 968 GridInstantMessage msg = new GridInstantMessage();
1011 969
1012 msg.imSessionID = UUID.Zero.Guid; 970 msg.imSessionID = UUID.Zero.Guid;
1013 msg.fromAgentID = remoteClient.AgentId.Guid; 971 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1014 // msg.fromAgentID = info.GroupID; 972 // msg.fromAgentID = info.GroupID;
1015 msg.toAgentID = ejecteeID.Guid; 973 msg.toAgentID = ejecteeID.Guid;
1016 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 974 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1036,8 +994,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1036 994
1037 msg = new GridInstantMessage(); 995 msg = new GridInstantMessage();
1038 msg.imSessionID = UUID.Zero.Guid; 996 msg.imSessionID = UUID.Zero.Guid;
1039 msg.fromAgentID = remoteClient.AgentId.Guid; 997 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1040 msg.toAgentID = remoteClient.AgentId.Guid; 998 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
1041 msg.timestamp = 0; 999 msg.timestamp = 0;
1042 msg.fromAgentName = remoteClient.Name; 1000 msg.fromAgentName = remoteClient.Name;
1043 if (account != null) 1001 if (account != null)
@@ -1055,7 +1013,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1055 msg.Position = Vector3.Zero; 1013 msg.Position = Vector3.Zero;
1056 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; 1014 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
1057 msg.binaryBucket = new byte[0]; 1015 msg.binaryBucket = new byte[0];
1058 OutgoingInstantMessage(msg, remoteClient.AgentId); 1016 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
1059 1017
1060 1018
1061 // SL sends out messages to everyone in the group 1019 // SL sends out messages to everyone in the group
@@ -1069,13 +1027,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1069 1027
1070 // Todo: Security check, probably also want to send some kind of notification 1028 // Todo: Security check, probably also want to send some kind of notification
1071 UUID InviteID = UUID.Random(); 1029 UUID InviteID = UUID.Random();
1072 GroupRequestID grid = GetClientGroupRequestID(remoteClient);
1073 1030
1074 m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); 1031 m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID);
1075 1032
1076 // Check to see if the invite went through, if it did not then it's possible 1033 // 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. 1034 // the remoteClient did not validate or did not have permission to invite.
1078 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); 1035 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID);
1079 1036
1080 if (inviteInfo != null) 1037 if (inviteInfo != null)
1081 { 1038 {
@@ -1087,7 +1044,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1087 1044
1088 msg.imSessionID = inviteUUID; 1045 msg.imSessionID = inviteUUID;
1089 1046
1090 // msg.fromAgentID = remoteClient.AgentId.Guid; 1047 // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1091 msg.fromAgentID = groupID.Guid; 1048 msg.fromAgentID = groupID.Guid;
1092 msg.toAgentID = invitedAgentID.Guid; 1049 msg.toAgentID = invitedAgentID.Guid;
1093 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1050 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1140,57 +1097,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1140 return child; 1097 return child;
1141 } 1098 }
1142 1099
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> 1100 /// <summary>
1195 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1101 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1196 /// </summary> 1102 /// </summary>
@@ -1209,7 +1115,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1209 1115
1210 foreach (GroupMembershipData membership in data) 1116 foreach (GroupMembershipData membership in data)
1211 { 1117 {
1212 if (remoteClient.AgentId != dataForAgentID) 1118 if (GetRequestingAgentID(remoteClient) != dataForAgentID)
1213 { 1119 {
1214 if (!membership.ListInProfile) 1120 if (!membership.ListInProfile)
1215 { 1121 {
@@ -1239,11 +1145,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1239 llDataStruct.Add("GroupData", GroupData); 1145 llDataStruct.Add("GroupData", GroupData);
1240 llDataStruct.Add("NewGroupData", NewGroupData); 1146 llDataStruct.Add("NewGroupData", NewGroupData);
1241 1147
1148 if (m_debugEnabled)
1149 {
1150 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1151 }
1152
1242 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 1153 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1243 1154
1244 if (queue != null) 1155 if (queue != null)
1245 { 1156 {
1246 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId); 1157 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
1247 } 1158 }
1248 1159
1249 } 1160 }
@@ -1316,7 +1227,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1316 /// <returns></returns> 1227 /// <returns></returns>
1317 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) 1228 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
1318 { 1229 {
1319 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); 1230 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID);
1320 GroupMembershipData[] membershipArray; 1231 GroupMembershipData[] membershipArray;
1321 1232
1322 if (requestingClient.AgentId != dataForAgentID) 1233 if (requestingClient.AgentId != dataForAgentID)
@@ -1338,7 +1249,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1338 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1249 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
1339 foreach (GroupMembershipData membership in membershipArray) 1250 foreach (GroupMembershipData membership in membershipArray)
1340 { 1251 {
1341 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); 1252 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers);
1342 } 1253 }
1343 } 1254 }
1344 1255
@@ -1397,6 +1308,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1397 } 1308 }
1398 1309
1399 #endregion 1310 #endregion
1311
1312 private UUID GetRequestingAgentID(IClientAPI client)
1313 {
1314 UUID requestingAgentID = UUID.Zero;
1315 if (client != null)
1316 {
1317 requestingAgentID = client.AgentId;
1318 }
1319 return requestingAgentID;
1320 }
1400 } 1321 }
1401 1322
1323 public class GroupNoticeInfo
1324 {
1325 public GroupNoticeData noticeData = new GroupNoticeData();
1326 public UUID GroupID = UUID.Zero;
1327 public string Message = string.Empty;
1328 public byte[] BinaryBucket = new byte[0];
1329 }
1402} 1330}