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