aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
diff options
context:
space:
mode:
authorMelanie2010-05-05 16:03:20 +0100
committerMelanie2010-05-05 16:03:20 +0100
commit6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29 (patch)
treed7997b254fe40ff6a4e79e5b45c457e088fe5361 /OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
parentPatch from mcortez: Update groups, add ALPHA Siman grid connector for groups (diff)
downloadopensim-SC-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.zip
opensim-SC-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.tar.gz
opensim-SC-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.tar.bz2
opensim-SC-6fdd5bfe2d0ac1313d94466b5c8a87ef07768f29.tar.xz
Revert "Patch from mcortez: Update groups, add ALPHA Siman grid connector for groups"
The patch was for 0.7 This reverts commit 608bb0dfefbbc97aded6d1357dd9d350053411fb.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs341
1 files changed, 202 insertions, 139 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 6b942cb..8d32e66 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -43,8 +43,6 @@ using OpenSim.Region.CoreModules.Framework.EventQueue;
43using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
45 45
46using OpenSim.Services.Interfaces;
47
48using Caps = OpenSim.Framework.Capabilities.Caps; 46using Caps = OpenSim.Framework.Capabilities.Caps;
49using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; 47using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags;
50 48
@@ -89,6 +87,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
89 87
90 private IGroupsServicesConnector m_groupData = null; 88 private IGroupsServicesConnector m_groupData = null;
91 89
90 class GroupRequestIDInfo
91 {
92 public GroupRequestID RequestID = new GroupRequestID();
93 public DateTime LastUsedTMStamp = DateTime.MinValue;
94 }
95 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
96 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
97 private Timer m_clientRequestIDFlushTimer;
98
99
92 // Configuration settings 100 // Configuration settings
93 private bool m_groupsEnabled = false; 101 private bool m_groupsEnabled = false;
94 private bool m_groupNoticesEnabled = true; 102 private bool m_groupNoticesEnabled = true;
@@ -125,6 +133,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
125 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); 133 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
126 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 134 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
127 135
136 m_clientRequestIDFlushTimer = new Timer();
137 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
138 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
139 m_clientRequestIDFlushTimer.AutoReset = true;
140 m_clientRequestIDFlushTimer.Start();
141 }
142 }
143
144 void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
145 {
146 lock (m_clientRequestIDInfo)
147 {
148 TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
149 UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
150 foreach (UUID key in CurrentKeys)
151 {
152 if (m_clientRequestIDInfo.ContainsKey(key))
153 {
154 if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
155 {
156 m_clientRequestIDInfo.Remove(key);
157 }
158 }
159 }
128 } 160 }
129 } 161 }
130 162
@@ -202,6 +234,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
202 return; 234 return;
203 235
204 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 236 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
237
238 m_clientRequestIDFlushTimer.Stop();
205 } 239 }
206 240
207 public Type ReplaceableInterface 241 public Type ReplaceableInterface
@@ -238,7 +272,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
238 // Used for Notices and Group Invites/Accept/Reject 272 // Used for Notices and Group Invites/Accept/Reject
239 client.OnInstantMessage += OnInstantMessage; 273 client.OnInstantMessage += OnInstantMessage;
240 274
241 // Send client thier groups information. 275 lock (m_clientRequestIDInfo)
276 {
277 if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
278 {
279 // flush any old RequestID information
280 m_clientRequestIDInfo.Remove(client.AgentId);
281 }
282 }
242 SendAgentGroupDataUpdate(client, client.AgentId); 283 SendAgentGroupDataUpdate(client, client.AgentId);
243 } 284 }
244 285
@@ -246,7 +287,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
246 { 287 {
247 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 288 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
248 289
249 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray(); 290 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray();
250 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 291 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
251 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 292 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
252 } 293 }
@@ -285,17 +326,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
285 } 326 }
286 */ 327 */
287 328
329
288 void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) 330 void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
289 { 331 {
290 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) 332 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
291 { 333 {
292 if (m_debugEnabled) 334 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
293 m_log.DebugFormat(
294 "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
295 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
296 335
297 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 336 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
298 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray()); 337 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray());
299 } 338 }
300 339
301 } 340 }
@@ -309,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
309 string activeGroupName = string.Empty; 348 string activeGroupName = string.Empty;
310 ulong activeGroupPowers = (ulong)GroupPowers.None; 349 ulong activeGroupPowers = (ulong)GroupPowers.None;
311 350
312 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID); 351 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID);
313 if (membership != null) 352 if (membership != null)
314 { 353 {
315 activeGroupID = membership.GroupID; 354 activeGroupID = membership.GroupID;
@@ -322,13 +361,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
322 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 361 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
323 } 362 }
324 363
325 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) 364 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient)
326 { 365 {
327 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 366 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
328 367
329 string GroupName; 368 string GroupName;
330 369
331 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null); 370 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null);
332 if (group != null) 371 if (group != null)
333 { 372 {
334 GroupName = group.GroupName; 373 GroupName = group.GroupName;
@@ -349,7 +388,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
349 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 388 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
350 { 389 {
351 UUID inviteID = new UUID(im.imSessionID); 390 UUID inviteID = new UUID(im.imSessionID);
352 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); 391 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
353 392
354 if (inviteInfo == null) 393 if (inviteInfo == null)
355 { 394 {
@@ -368,7 +407,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
368 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 407 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
369 408
370 // and the sessionid is the role 409 // and the sessionid is the role
371 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 410 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
372 411
373 GridInstantMessage msg = new GridInstantMessage(); 412 GridInstantMessage msg = new GridInstantMessage();
374 msg.imSessionID = UUID.Zero.Guid; 413 msg.imSessionID = UUID.Zero.Guid;
@@ -392,14 +431,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
392 // TODO: If the inviter is still online, they need an agent dataupdate 431 // TODO: If the inviter is still online, they need an agent dataupdate
393 // and maybe group membership updates for the invitee 432 // and maybe group membership updates for the invitee
394 433
395 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); 434 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
396 } 435 }
397 436
398 // Reject 437 // Reject
399 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 438 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
400 { 439 {
401 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 440 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
402 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); 441 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
403 } 442 }
404 } 443 }
405 } 444 }
@@ -413,7 +452,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
413 } 452 }
414 453
415 UUID GroupID = new UUID(im.toAgentID); 454 UUID GroupID = new UUID(im.toAgentID);
416 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null) 455 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null)
417 { 456 {
418 UUID NoticeID = UUID.Random(); 457 UUID NoticeID = UUID.Random();
419 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 458 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -457,21 +496,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
457 } 496 }
458 497
459 498
460 m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 499 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
461 if (OnNewGroupNotice != null) 500 if (OnNewGroupNotice != null)
462 { 501 {
463 OnNewGroupNotice(GroupID, NoticeID); 502 OnNewGroupNotice(GroupID, NoticeID);
464 } 503 }
465 504
466 // Send notice out to everyone that wants notices 505 // Send notice out to everyone that wants notices
467 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID)) 506 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID))
468 { 507 {
469 if (m_debugEnabled) 508 if (m_debugEnabled)
470 { 509 {
471 UserAccount targetUser = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, member.AgentID); 510 UserProfileData targetUserProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(member.AgentID);
472 if (targetUser != null) 511 if (targetUserProfile != null)
473 { 512 {
474 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices); 513 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUserProfile.Name, member.AcceptNotices);
475 } 514 }
476 else 515 else
477 { 516 {
@@ -549,25 +588,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
549 588
550 public GroupRecord GetGroupRecord(UUID GroupID) 589 public GroupRecord GetGroupRecord(UUID GroupID)
551 { 590 {
552 return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); 591 return m_groupData.GetGroupRecord(null, GroupID, null);
553 } 592 }
554 593
555 public GroupRecord GetGroupRecord(string name)
556 {
557 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
558 }
559
560 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 594 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
561 { 595 {
562 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 596 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
563 597
564 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 598 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
565 599
566 // Changing active group changes title, active powers, all kinds of things 600 // Changing active group changes title, active powers, all kinds of things
567 // anyone who is in any region that can see this client, should probably be 601 // anyone who is in any region that can see this client, should probably be
568 // updated with new group info. At a minimum, they should get ScenePresence 602 // updated with new group info. At a minimum, they should get ScenePresence
569 // updated with new title. 603 // updated with new title.
570 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); 604 UpdateAllClientsWithGroupInfo(remoteClient.AgentId);
571 } 605 }
572 606
573 /// <summary> 607 /// <summary>
@@ -577,9 +611,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
577 { 611 {
578 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 612 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
579 613
614 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
580 615
581 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 616 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID);
582 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 617 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
583 618
584 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 619 List<GroupTitlesData> titles = new List<GroupTitlesData>();
585 foreach (GroupRolesData role in agentRoles) 620 foreach (GroupRolesData role in agentRoles)
@@ -601,15 +636,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
601 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 636 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
602 { 637 {
603 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 638 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
604 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID); 639
605 640 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID);
606 if (m_debugEnabled)
607 {
608 foreach (GroupMembersData member in data)
609 {
610 m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
611 }
612 }
613 641
614 return data; 642 return data;
615 643
@@ -619,25 +647,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
619 { 647 {
620 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 648 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
621 649
622 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID); 650 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID);
623 651
624 return data; 652 return data;
653
625 } 654 }
626 655
627 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) 656 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID)
628 { 657 {
629 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 658 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
630 659
631 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID); 660 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID);
632 661
633 if (m_debugEnabled)
634 {
635 foreach (GroupRoleMembersData member in data)
636 {
637 m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
638 }
639 }
640 return data; 662 return data;
663
664
641 } 665 }
642 666
643 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) 667 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID)
@@ -646,16 +670,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
646 670
647 GroupProfileData profile = new GroupProfileData(); 671 GroupProfileData profile = new GroupProfileData();
648 672
673 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
649 674
650 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); 675 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null);
651 if (groupInfo != null) 676 if (groupInfo != null)
652 { 677 {
653 profile.AllowPublish = groupInfo.AllowPublish; 678 profile.AllowPublish = groupInfo.AllowPublish;
654 profile.Charter = groupInfo.Charter; 679 profile.Charter = groupInfo.Charter;
655 profile.FounderID = groupInfo.FounderID; 680 profile.FounderID = groupInfo.FounderID;
656 profile.GroupID = groupID; 681 profile.GroupID = groupID;
657 profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count; 682 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count;
658 profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count; 683 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count;
659 profile.InsigniaID = groupInfo.GroupPicture; 684 profile.InsigniaID = groupInfo.GroupPicture;
660 profile.MaturePublish = groupInfo.MaturePublish; 685 profile.MaturePublish = groupInfo.MaturePublish;
661 profile.MembershipFee = groupInfo.MembershipFee; 686 profile.MembershipFee = groupInfo.MembershipFee;
@@ -666,7 +691,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
666 profile.ShowInList = groupInfo.ShowInList; 691 profile.ShowInList = groupInfo.ShowInList;
667 } 692 }
668 693
669 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 694 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
670 if (memberInfo != null) 695 if (memberInfo != null)
671 { 696 {
672 profile.MemberTitle = memberInfo.GroupTitle; 697 profile.MemberTitle = memberInfo.GroupTitle;
@@ -680,46 +705,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
680 { 705 {
681 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 706 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
682 707
683 return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray(); 708 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray();
684 } 709 }
685 710
686 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 711 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
687 { 712 {
688 if (m_debugEnabled) 713 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
689 m_log.DebugFormat(
690 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
691 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
692 714
693 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID); 715 return m_groupData.GetAgentGroupMembership(null, agentID, groupID);
694 } 716 }
695 717
696 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 718 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
697 { 719 {
698 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 720 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
699 721
700 // Note: Permissions checking for modification rights is handled by the Groups Server/Service 722 // TODO: Security Check?
701 m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); 723
724 m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
702 } 725 }
703 726
704 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 727 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
705 { 728 {
706 // Note: Permissions checking for modification rights is handled by the Groups Server/Service 729 // TODO: Security Check?
707 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 730 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
708 731
709 m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile); 732 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile);
710 } 733 }
711 734
712 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 735 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
713 { 736 {
714 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 737 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
715 738
716 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null) 739 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
740
741 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
717 { 742 {
718 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 743 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
719 return UUID.Zero; 744 return UUID.Zero;
720 } 745 }
721 // is there is a money module present ? 746 // is there is a money module present ?
722 IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>(); 747 IMoneyModule money=remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
723 if (money != null) 748 if (money != null)
724 { 749 {
725 // do the transaction, that is if the agent has got sufficient funds 750 // do the transaction, that is if the agent has got sufficient funds
@@ -727,14 +752,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
727 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); 752 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
728 return UUID.Zero; 753 return UUID.Zero;
729 } 754 }
730 money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient)); 755 money.ApplyGroupCreationCharge(remoteClient.AgentId);
731 } 756 }
732 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient)); 757 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId);
733 758
734 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 759 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
735 760
736 // Update the founder with new group information. 761 // Update the founder with new group information.
737 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 762 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
738 763
739 return groupID; 764 return groupID;
740 } 765 }
@@ -745,7 +770,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
745 770
746 // ToDo: check if agent is a member of group and is allowed to see notices? 771 // ToDo: check if agent is a member of group and is allowed to see notices?
747 772
748 return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray(); 773 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray();
749 } 774 }
750 775
751 /// <summary> 776 /// <summary>
@@ -755,7 +780,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
755 { 780 {
756 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 781 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
757 782
758 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID); 783 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID);
759 if (membership != null) 784 if (membership != null)
760 { 785 {
761 return membership.GroupTitle; 786 return membership.GroupTitle;
@@ -770,13 +795,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
770 { 795 {
771 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 796 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
772 797
773 m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID); 798 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID);
774 799
775 // TODO: Not sure what all is needed here, but if the active group role change is for the group 800 // TODO: Not sure what all is needed here, but if the active group role change is for the group
776 // the client currently has set active, then we need to do a scene presence update too 801 // the client currently has set active, then we need to do a scene presence update too
777 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) 802 // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID)
778 803
779 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); 804 UpdateAllClientsWithGroupInfo(remoteClient.AgentId);
780 } 805 }
781 806
782 807
@@ -786,14 +811,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
786 811
787 // Security Checks are handled in the Groups Service. 812 // Security Checks are handled in the Groups Service.
788 813
814 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
815
789 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 816 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
790 { 817 {
791 case OpenMetaverse.GroupRoleUpdate.Create: 818 case OpenMetaverse.GroupRoleUpdate.Create:
792 m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers); 819 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers);
793 break; 820 break;
794 821
795 case OpenMetaverse.GroupRoleUpdate.Delete: 822 case OpenMetaverse.GroupRoleUpdate.Delete:
796 m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID); 823 m_groupData.RemoveGroupRole(grID, groupID, roleID);
797 break; 824 break;
798 825
799 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 826 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@@ -804,7 +831,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
804 GroupPowers gp = (GroupPowers)powers; 831 GroupPowers gp = (GroupPowers)powers;
805 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); 832 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
806 } 833 }
807 m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers); 834 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers);
808 break; 835 break;
809 836
810 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 837 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -815,7 +842,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
815 } 842 }
816 843
817 // TODO: This update really should send out updates for everyone in the role that just got changed. 844 // TODO: This update really should send out updates for everyone in the role that just got changed.
818 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 845 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
819 } 846 }
820 847
821 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 848 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -823,16 +850,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
823 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 850 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
824 // Todo: Security check 851 // Todo: Security check
825 852
853 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
854
826 switch (changes) 855 switch (changes)
827 { 856 {
828 case 0: 857 case 0:
829 // Add 858 // Add
830 m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); 859 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID);
831 860
832 break; 861 break;
833 case 1: 862 case 1:
834 // Remove 863 // Remove
835 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); 864 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID);
836 865
837 break; 866 break;
838 default: 867 default:
@@ -841,23 +870,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
841 } 870 }
842 871
843 // TODO: This update really should send out updates for everyone in the role that just got changed. 872 // TODO: This update really should send out updates for everyone in the role that just got changed.
844 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 873 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
845 } 874 }
846 875
847 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 876 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
848 { 877 {
849 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 878 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
850 879
851 GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID); 880 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
881
882 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
852 883
853 if (data != null) 884 if (data != null)
854 { 885 {
855 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); 886 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null);
856 887
857 GridInstantMessage msg = new GridInstantMessage(); 888 GridInstantMessage msg = new GridInstantMessage();
858 msg.imSessionID = UUID.Zero.Guid; 889 msg.imSessionID = UUID.Zero.Guid;
859 msg.fromAgentID = data.GroupID.Guid; 890 msg.fromAgentID = data.GroupID.Guid;
860 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; 891 msg.toAgentID = remoteClient.AgentId.Guid;
861 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 892 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
862 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; 893 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
863 msg.message = data.noticeData.Subject + "|" + data.Message; 894 msg.message = data.noticeData.Subject + "|" + data.Message;
@@ -869,7 +900,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
869 msg.RegionID = UUID.Zero.Guid; 900 msg.RegionID = UUID.Zero.Guid;
870 msg.binaryBucket = data.BinaryBucket; 901 msg.binaryBucket = data.BinaryBucket;
871 902
872 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); 903 OutgoingInstantMessage(msg, remoteClient.AgentId);
873 } 904 }
874 905
875 } 906 }
@@ -889,7 +920,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
889 msg.Position = Vector3.Zero; 920 msg.Position = Vector3.Zero;
890 msg.RegionID = UUID.Zero.Guid; 921 msg.RegionID = UUID.Zero.Guid;
891 922
892 GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID); 923 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID);
893 if (info != null) 924 if (info != null)
894 { 925 {
895 msg.fromAgentID = info.GroupID.Guid; 926 msg.fromAgentID = info.GroupID.Guid;
@@ -916,7 +947,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
916 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 947 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
917 948
918 // Send agent information about his groups 949 // Send agent information about his groups
919 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 950 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
920 } 951 }
921 952
922 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 953 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -924,19 +955,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
924 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 955 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
925 956
926 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 957 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
927 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero); 958 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero);
928 959
929 remoteClient.SendJoinGroupReply(groupID, true); 960 remoteClient.SendJoinGroupReply(groupID, true);
930 961
931 // Should this send updates to everyone in the group? 962 // Should this send updates to everyone in the group?
932 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 963 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
933 } 964 }
934 965
935 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 966 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
936 { 967 {
937 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 968 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
938 969
939 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 970 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
940 971
941 remoteClient.SendLeaveGroupReply(groupID, true); 972 remoteClient.SendLeaveGroupReply(groupID, true);
942 973
@@ -944,32 +975,34 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
944 975
945 // SL sends out notifcations to the group messaging session that the person has left 976 // SL sends out notifcations to the group messaging session that the person has left
946 // Should this also update everyone who is in the group? 977 // Should this also update everyone who is in the group?
947 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 978 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId);
948 } 979 }
949 980
950 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 981 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
951 { 982 {
952 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 983 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
953 984
985 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
954 986
955 // Todo: Security check? 987 // Todo: Security check?
956 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID); 988 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID);
957 989
958 remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true); 990 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true);
959 991
960 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); 992 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
993 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
961 994
962 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); 995 if ((groupInfo == null) || (userProfile == null))
963 if ((groupInfo == null) || (account == null))
964 { 996 {
965 return; 997 return;
966 } 998 }
999
967 1000
968 // Send Message to Ejectee 1001 // Send Message to Ejectee
969 GridInstantMessage msg = new GridInstantMessage(); 1002 GridInstantMessage msg = new GridInstantMessage();
970 1003
971 msg.imSessionID = UUID.Zero.Guid; 1004 msg.imSessionID = UUID.Zero.Guid;
972 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; 1005 msg.fromAgentID = remoteClient.AgentId.Guid;
973 // msg.fromAgentID = info.GroupID; 1006 // msg.fromAgentID = info.GroupID;
974 msg.toAgentID = ejecteeID.Guid; 1007 msg.toAgentID = ejecteeID.Guid;
975 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1008 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -995,13 +1028,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
995 1028
996 msg = new GridInstantMessage(); 1029 msg = new GridInstantMessage();
997 msg.imSessionID = UUID.Zero.Guid; 1030 msg.imSessionID = UUID.Zero.Guid;
998 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; 1031 msg.fromAgentID = remoteClient.AgentId.Guid;
999 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; 1032 msg.toAgentID = remoteClient.AgentId.Guid;
1000 msg.timestamp = 0; 1033 msg.timestamp = 0;
1001 msg.fromAgentName = remoteClient.Name; 1034 msg.fromAgentName = remoteClient.Name;
1002 if (account != null) 1035 if (userProfile != null)
1003 { 1036 {
1004 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName); 1037 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, userProfile.Name);
1005 } 1038 }
1006 else 1039 else
1007 { 1040 {
@@ -1014,7 +1047,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1014 msg.Position = Vector3.Zero; 1047 msg.Position = Vector3.Zero;
1015 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; 1048 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
1016 msg.binaryBucket = new byte[0]; 1049 msg.binaryBucket = new byte[0];
1017 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); 1050 OutgoingInstantMessage(msg, remoteClient.AgentId);
1018 1051
1019 1052
1020 // SL sends out messages to everyone in the group 1053 // SL sends out messages to everyone in the group
@@ -1028,12 +1061,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1028 1061
1029 // Todo: Security check, probably also want to send some kind of notification 1062 // Todo: Security check, probably also want to send some kind of notification
1030 UUID InviteID = UUID.Random(); 1063 UUID InviteID = UUID.Random();
1064 GroupRequestID grid = GetClientGroupRequestID(remoteClient);
1031 1065
1032 m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID); 1066 m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID);
1033 1067
1034 // Check to see if the invite went through, if it did not then it's possible 1068 // Check to see if the invite went through, if it did not then it's possible
1035 // the remoteClient did not validate or did not have permission to invite. 1069 // the remoteClient did not validate or did not have permission to invite.
1036 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID); 1070 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID);
1037 1071
1038 if (inviteInfo != null) 1072 if (inviteInfo != null)
1039 { 1073 {
@@ -1045,7 +1079,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1045 1079
1046 msg.imSessionID = inviteUUID; 1080 msg.imSessionID = inviteUUID;
1047 1081
1048 // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; 1082 // msg.fromAgentID = remoteClient.AgentId.Guid;
1049 msg.fromAgentID = groupID.Guid; 1083 msg.fromAgentID = groupID.Guid;
1050 msg.toAgentID = invitedAgentID.Guid; 1084 msg.toAgentID = invitedAgentID.Guid;
1051 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1085 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1098,6 +1132,57 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1098 return child; 1132 return child;
1099 } 1133 }
1100 1134
1135 private GroupRequestID GetClientGroupRequestID(IClientAPI client)
1136 {
1137 if (client == null)
1138 {
1139 return new GroupRequestID();
1140 }
1141
1142 lock (m_clientRequestIDInfo)
1143 {
1144 if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
1145 {
1146 GroupRequestIDInfo info = new GroupRequestIDInfo();
1147 info.RequestID.AgentID = client.AgentId;
1148 info.RequestID.SessionID = client.SessionId;
1149
1150 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1151 if (userProfile == null)
1152 {
1153 // This should be impossible. If I've been passed a reference to a client
1154 // that client should be registered with the UserService. So something
1155 // is horribly wrong somewhere.
1156
1157 m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);
1158
1159 // Default to local user service and hope for the best?
1160 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1161
1162 }
1163 else if (userProfile is ForeignUserProfileData)
1164 {
1165 // They aren't from around here
1166 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1167 info.RequestID.UserServiceURL = fupd.UserServerURI;
1168 }
1169 else
1170 {
1171 // They're a local user, use this:
1172 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1173 }
1174
1175 m_clientRequestIDInfo.Add(client.AgentId, info);
1176 }
1177
1178 m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
1179
1180 return m_clientRequestIDInfo[client.AgentId].RequestID;
1181 }
1182// Unreachable code!
1183// return new GroupRequestID();
1184 }
1185
1101 /// <summary> 1186 /// <summary>
1102 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1187 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1103 /// </summary> 1188 /// </summary>
@@ -1116,7 +1201,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1116 1201
1117 foreach (GroupMembershipData membership in data) 1202 foreach (GroupMembershipData membership in data)
1118 { 1203 {
1119 if (GetRequestingAgentID(remoteClient) != dataForAgentID) 1204 if (remoteClient.AgentId != dataForAgentID)
1120 { 1205 {
1121 if (!membership.ListInProfile) 1206 if (!membership.ListInProfile)
1122 { 1207 {
@@ -1144,18 +1229,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1144 OSDMap llDataStruct = new OSDMap(3); 1229 OSDMap llDataStruct = new OSDMap(3);
1145 llDataStruct.Add("AgentData", AgentData); 1230 llDataStruct.Add("AgentData", AgentData);
1146 llDataStruct.Add("GroupData", GroupData); 1231 llDataStruct.Add("GroupData", GroupData);
1147 llDataStruct.Add("NewGroupData", NewGroupData); 1232 llDataStruct.Add("NewGroupData", NewGroupData);
1148
1149 if (m_debugEnabled)
1150 {
1151 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1152 }
1153 1233
1154 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 1234 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1155 1235
1156 if (queue != null) 1236 if (queue != null)
1157 { 1237 {
1158 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); 1238 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId);
1159 } 1239 }
1160 1240
1161 } 1241 }
@@ -1228,7 +1308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1228 /// <returns></returns> 1308 /// <returns></returns>
1229 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) 1309 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
1230 { 1310 {
1231 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID); 1311 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID);
1232 GroupMembershipData[] membershipArray; 1312 GroupMembershipData[] membershipArray;
1233 1313
1234 if (requestingClient.AgentId != dataForAgentID) 1314 if (requestingClient.AgentId != dataForAgentID)
@@ -1250,7 +1330,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1250 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1330 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
1251 foreach (GroupMembershipData membership in membershipArray) 1331 foreach (GroupMembershipData membership in membershipArray)
1252 { 1332 {
1253 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers); 1333 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle);
1254 } 1334 }
1255 } 1335 }
1256 1336
@@ -1262,12 +1342,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1262 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1342 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1263 1343
1264 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1344 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1265 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); 1345 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(dataForAgentID);
1266 string firstname, lastname; 1346 string firstname, lastname;
1267 if (account != null) 1347 if (userProfile != null)
1268 { 1348 {
1269 firstname = account.FirstName; 1349 firstname = userProfile.FirstName;
1270 lastname = account.LastName; 1350 lastname = userProfile.SurName;
1271 } 1351 }
1272 else 1352 else
1273 { 1353 {
@@ -1308,24 +1388,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1308 // 1388 //
1309 } 1389 }
1310 1390
1311 #endregion 1391 #endregion
1312
1313 private UUID GetRequestingAgentID(IClientAPI client)
1314 {
1315 UUID requestingAgentID = UUID.Zero;
1316 if (client != null)
1317 {
1318 requestingAgentID = client.AgentId;
1319 }
1320 return requestingAgentID;
1321 }
1322 } 1392 }
1323 1393
1324 public class GroupNoticeInfo
1325 {
1326 public GroupNoticeData noticeData = new GroupNoticeData();
1327 public UUID GroupID = UUID.Zero;
1328 public string Message = string.Empty;
1329 public byte[] BinaryBucket = new byte[0];
1330 }
1331} 1394}