aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs321
1 files changed, 137 insertions, 184 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 8d32e66..3e05732 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -87,16 +87,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
87 87
88 private IGroupsServicesConnector m_groupData = null; 88 private IGroupsServicesConnector m_groupData = null;
89 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
100 // Configuration settings 90 // Configuration settings
101 private bool m_groupsEnabled = false; 91 private bool m_groupsEnabled = false;
102 private bool m_groupNoticesEnabled = true; 92 private bool m_groupNoticesEnabled = true;
@@ -133,30 +123,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
133 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); 123 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
134 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 124 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
135 125
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 } 126 }
161 } 127 }
162 128
@@ -234,8 +200,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
234 return; 200 return;
235 201
236 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 202 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
237
238 m_clientRequestIDFlushTimer.Stop();
239 } 203 }
240 204
241 public Type ReplaceableInterface 205 public Type ReplaceableInterface
@@ -272,14 +236,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
272 // Used for Notices and Group Invites/Accept/Reject 236 // Used for Notices and Group Invites/Accept/Reject
273 client.OnInstantMessage += OnInstantMessage; 237 client.OnInstantMessage += OnInstantMessage;
274 238
275 lock (m_clientRequestIDInfo) 239 // 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); 240 SendAgentGroupDataUpdate(client, client.AgentId);
284 } 241 }
285 242
@@ -287,7 +244,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
287 { 244 {
288 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 245 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
289 246
290 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); 247 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
291 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 248 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
292 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 249 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
293 } 250 }
@@ -331,10 +288,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
331 { 288 {
332 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) 289 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
333 { 290 {
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); 291 if (m_debugEnabled)
292 m_log.DebugFormat(
293 "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
294 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
335 295
336 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 296 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
337 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); 297 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray());
338 } 298 }
339 299
340 } 300 }
@@ -348,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
348 string activeGroupName = string.Empty; 308 string activeGroupName = string.Empty;
349 ulong activeGroupPowers = (ulong)GroupPowers.None; 309 ulong activeGroupPowers = (ulong)GroupPowers.None;
350 310
351 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); 311 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
352 if (membership != null) 312 if (membership != null)
353 { 313 {
354 activeGroupID = membership.GroupID; 314 activeGroupID = membership.GroupID;
@@ -361,13 +321,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
361 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 321 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
362 } 322 }
363 323
364 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient) 324 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
365 { 325 {
366 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 326 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
367 327
368 string GroupName; 328 string GroupName;
369 329
370 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); 330 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
371 if (group != null) 331 if (group != null)
372 { 332 {
373 GroupName = group.GroupName; 333 GroupName = group.GroupName;
@@ -382,13 +342,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
382 342
383 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 343 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
384 { 344 {
385 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 345 if (m_debugEnabled)
346 {
347 m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
348 m_log.DebugFormat("[GROUPS]: remoteClient ({0}) im ({1})", remoteClient, im);
349
350 }
351
386 352
387 // Group invitations 353 // Group invitations
388 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 354 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
389 { 355 {
390 UUID inviteID = new UUID(im.imSessionID); 356 UUID inviteID = new UUID(im.imSessionID);
391 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 357 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
392 358
393 if (inviteInfo == null) 359 if (inviteInfo == null)
394 { 360 {
@@ -407,7 +373,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
407 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 373 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
408 374
409 // and the sessionid is the role 375 // and the sessionid is the role
410 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 376 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
411 377
412 GridInstantMessage msg = new GridInstantMessage(); 378 GridInstantMessage msg = new GridInstantMessage();
413 msg.imSessionID = UUID.Zero.Guid; 379 msg.imSessionID = UUID.Zero.Guid;
@@ -431,14 +397,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
431 // TODO: If the inviter is still online, they need an agent dataupdate 397 // TODO: If the inviter is still online, they need an agent dataupdate
432 // and maybe group membership updates for the invitee 398 // and maybe group membership updates for the invitee
433 399
434 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 400 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
435 } 401 }
436 402
437 // Reject 403 // Reject
438 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 404 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
439 { 405 {
440 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 406 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
441 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 407 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
442 } 408 }
443 } 409 }
444 } 410 }
@@ -452,7 +418,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
452 } 418 }
453 419
454 UUID GroupID = new UUID(im.toAgentID); 420 UUID GroupID = new UUID(im.toAgentID);
455 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) 421 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null)
456 { 422 {
457 UUID NoticeID = UUID.Random(); 423 UUID NoticeID = UUID.Random();
458 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 424 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -496,14 +462,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
496 } 462 }
497 463
498 464
499 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 465 m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
500 if (OnNewGroupNotice != null) 466 if (OnNewGroupNotice != null)
501 { 467 {
502 OnNewGroupNotice(GroupID, NoticeID); 468 OnNewGroupNotice(GroupID, NoticeID);
503 } 469 }
504 470
505 // Send notice out to everyone that wants notices 471 // Send notice out to everyone that wants notices
506 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) 472 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID))
507 { 473 {
508 if (m_debugEnabled) 474 if (m_debugEnabled)
509 { 475 {
@@ -521,7 +487,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
521 if (member.AcceptNotices) 487 if (member.AcceptNotices)
522 { 488 {
523 // Build notice IIM 489 // Build notice IIM
524 GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); 490 GridInstantMessage msg = CreateGroupNoticeIM(GetRequestingAgentID(remoteClient), NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice);
525 491
526 msg.toAgentID = member.AgentID.Guid; 492 msg.toAgentID = member.AgentID.Guid;
527 OutgoingInstantMessage(msg, member.AgentID); 493 OutgoingInstantMessage(msg, member.AgentID);
@@ -549,7 +515,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
549 IClientAPI ejectee = GetActiveClient(ejecteeID); 515 IClientAPI ejectee = GetActiveClient(ejecteeID);
550 if (ejectee != null) 516 if (ejectee != null)
551 { 517 {
552 UUID groupID = new UUID(im.fromAgentID); 518 UUID groupID = new UUID(im.imSessionID);
553 ejectee.SendAgentDropGroup(groupID); 519 ejectee.SendAgentDropGroup(groupID);
554 } 520 }
555 } 521 }
@@ -588,20 +554,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
588 554
589 public GroupRecord GetGroupRecord(UUID GroupID) 555 public GroupRecord GetGroupRecord(UUID GroupID)
590 { 556 {
591 return m_groupData.GetGroupRecord(null, GroupID, null); 557 return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
592 } 558 }
593 559
560 public GroupRecord GetGroupRecord(string name)
561 {
562 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
563 }
564
594 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 565 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
595 { 566 {
596 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 567 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
597 568
598 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 569 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
599 570
600 // Changing active group changes title, active powers, all kinds of things 571 // 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 572 // 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 573 // updated with new group info. At a minimum, they should get ScenePresence
603 // updated with new title. 574 // updated with new title.
604 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 575 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
605 } 576 }
606 577
607 /// <summary> 578 /// <summary>
@@ -611,10 +582,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
611 { 582 {
612 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 583 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
613 584
614 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
615 585
616 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); 586 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
617 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 587 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
618 588
619 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 589 List<GroupTitlesData> titles = new List<GroupTitlesData>();
620 foreach (GroupRolesData role in agentRoles) 590 foreach (GroupRolesData role in agentRoles)
@@ -636,8 +606,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
636 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 606 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
637 { 607 {
638 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 608 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
609 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
639 610
640 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); 611 if (m_debugEnabled)
612 {
613 foreach (GroupMembersData member in data)
614 {
615 m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
616 }
617 }
641 618
642 return data; 619 return data;
643 620
@@ -647,21 +624,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
647 { 624 {
648 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 625 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
649 626
650 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); 627 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID);
651 628
652 return data; 629 return data;
653
654 } 630 }
655 631
656 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) 632 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID)
657 { 633 {
658 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 634 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
659 635
660 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); 636 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID);
661 637
638 if (m_debugEnabled)
639 {
640 foreach (GroupRoleMembersData member in data)
641 {
642 m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
643 }
644 }
662 return data; 645 return data;
663
664
665 } 646 }
666 647
667 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) 648 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID)
@@ -670,17 +651,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
670 651
671 GroupProfileData profile = new GroupProfileData(); 652 GroupProfileData profile = new GroupProfileData();
672 653
673 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
674 654
675 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); 655 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
676 if (groupInfo != null) 656 if (groupInfo != null)
677 { 657 {
678 profile.AllowPublish = groupInfo.AllowPublish; 658 profile.AllowPublish = groupInfo.AllowPublish;
679 profile.Charter = groupInfo.Charter; 659 profile.Charter = groupInfo.Charter;
680 profile.FounderID = groupInfo.FounderID; 660 profile.FounderID = groupInfo.FounderID;
681 profile.GroupID = groupID; 661 profile.GroupID = groupID;
682 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; 662 profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count;
683 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; 663 profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count;
684 profile.InsigniaID = groupInfo.GroupPicture; 664 profile.InsigniaID = groupInfo.GroupPicture;
685 profile.MaturePublish = groupInfo.MaturePublish; 665 profile.MaturePublish = groupInfo.MaturePublish;
686 profile.MembershipFee = groupInfo.MembershipFee; 666 profile.MembershipFee = groupInfo.MembershipFee;
@@ -691,7 +671,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
691 profile.ShowInList = groupInfo.ShowInList; 671 profile.ShowInList = groupInfo.ShowInList;
692 } 672 }
693 673
694 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 674 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
695 if (memberInfo != null) 675 if (memberInfo != null)
696 { 676 {
697 profile.MemberTitle = memberInfo.GroupTitle; 677 profile.MemberTitle = memberInfo.GroupTitle;
@@ -705,40 +685,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
705 { 685 {
706 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 686 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
707 687
708 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); 688 return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray();
709 } 689 }
710 690
711 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 691 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
712 { 692 {
713 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 693 if (m_debugEnabled)
694 m_log.DebugFormat(
695 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
696 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
714 697
715 return m_groupData.GetAgentGroupMembership(null, agentID, groupID); 698 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
716 } 699 }
717 700
718 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 701 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
719 { 702 {
720 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 703 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
721 704
722 // TODO: Security Check? 705 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
723 706 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 } 707 }
726 708
727 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 709 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
728 { 710 {
729 // TODO: Security Check? 711 // 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); 712 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
731 713
732 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); 714 m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile);
733 } 715 }
734 716
735 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 717 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
736 { 718 {
737 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 719 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
738 720
739 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 721 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null)
740
741 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
742 { 722 {
743 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 723 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
744 return UUID.Zero; 724 return UUID.Zero;
@@ -754,12 +734,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
754 } 734 }
755 money.ApplyGroupCreationCharge(remoteClient.AgentId); 735 money.ApplyGroupCreationCharge(remoteClient.AgentId);
756 } 736 }
757 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); 737 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
758 738
759 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 739 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
760 740
761 // Update the founder with new group information. 741 // Update the founder with new group information.
762 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 742 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
763 743
764 return groupID; 744 return groupID;
765 } 745 }
@@ -770,7 +750,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
770 750
771 // ToDo: check if agent is a member of group and is allowed to see notices? 751 // ToDo: check if agent is a member of group and is allowed to see notices?
772 752
773 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); 753 return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray();
774 } 754 }
775 755
776 /// <summary> 756 /// <summary>
@@ -780,7 +760,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
780 { 760 {
781 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 761 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
782 762
783 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); 763 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID);
784 if (membership != null) 764 if (membership != null)
785 { 765 {
786 return membership.GroupTitle; 766 return membership.GroupTitle;
@@ -795,13 +775,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
795 { 775 {
796 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 776 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
797 777
798 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); 778 m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID);
799 779
800 // TODO: Not sure what all is needed here, but if the active group role change is for the group 780 // 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 781 // 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) 782 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
803 783
804 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 784 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
805 } 785 }
806 786
807 787
@@ -811,16 +791,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
811 791
812 // Security Checks are handled in the Groups Service. 792 // Security Checks are handled in the Groups Service.
813 793
814 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
815
816 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 794 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
817 { 795 {
818 case OpenMetaverse.GroupRoleUpdate.Create: 796 case OpenMetaverse.GroupRoleUpdate.Create:
819 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); 797 m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers);
820 break; 798 break;
821 799
822 case OpenMetaverse.GroupRoleUpdate.Delete: 800 case OpenMetaverse.GroupRoleUpdate.Delete:
823 m_groupData.RemoveGroupRole(grID, groupID, roleID); 801 m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID);
824 break; 802 break;
825 803
826 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 804 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@@ -831,7 +809,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
831 GroupPowers gp = (GroupPowers)powers; 809 GroupPowers gp = (GroupPowers)powers;
832 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); 810 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
833 } 811 }
834 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); 812 m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers);
835 break; 813 break;
836 814
837 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 815 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -842,7 +820,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
842 } 820 }
843 821
844 // TODO: This update really should send out updates for everyone in the role that just got changed. 822 // TODO: This update really should send out updates for everyone in the role that just got changed.
845 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 823 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
846 } 824 }
847 825
848 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 826 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -850,18 +828,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
850 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 828 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
851 // Todo: Security check 829 // Todo: Security check
852 830
853 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
854
855 switch (changes) 831 switch (changes)
856 { 832 {
857 case 0: 833 case 0:
858 // Add 834 // Add
859 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); 835 m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
860 836
861 break; 837 break;
862 case 1: 838 case 1:
863 // Remove 839 // Remove
864 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); 840 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
865 841
866 break; 842 break;
867 default: 843 default:
@@ -870,25 +846,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
870 } 846 }
871 847
872 // TODO: This update really should send out updates for everyone in the role that just got changed. 848 // TODO: This update really should send out updates for everyone in the role that just got changed.
873 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 849 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
874 } 850 }
875 851
876 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 852 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
877 { 853 {
878 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 854 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
879 855
880 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 856 GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID);
881
882 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
883 857
884 if (data != null) 858 if (data != null)
885 { 859 {
886 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); 860 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null);
887 861
888 GridInstantMessage msg = new GridInstantMessage(); 862 GridInstantMessage msg = new GridInstantMessage();
889 msg.imSessionID = UUID.Zero.Guid; 863 msg.imSessionID = UUID.Zero.Guid;
890 msg.fromAgentID = data.GroupID.Guid; 864 msg.fromAgentID = data.GroupID.Guid;
891 msg.toAgentID = remoteClient.AgentId.Guid; 865 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
892 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 866 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
893 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; 867 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
894 msg.message = data.noticeData.Subject + "|" + data.Message; 868 msg.message = data.noticeData.Subject + "|" + data.Message;
@@ -900,7 +874,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
900 msg.RegionID = UUID.Zero.Guid; 874 msg.RegionID = UUID.Zero.Guid;
901 msg.binaryBucket = data.BinaryBucket; 875 msg.binaryBucket = data.BinaryBucket;
902 876
903 OutgoingInstantMessage(msg, remoteClient.AgentId); 877 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
904 } 878 }
905 879
906 } 880 }
@@ -920,7 +894,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
920 msg.Position = Vector3.Zero; 894 msg.Position = Vector3.Zero;
921 msg.RegionID = UUID.Zero.Guid; 895 msg.RegionID = UUID.Zero.Guid;
922 896
923 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); 897 GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID);
924 if (info != null) 898 if (info != null)
925 { 899 {
926 msg.fromAgentID = info.GroupID.Guid; 900 msg.fromAgentID = info.GroupID.Guid;
@@ -947,7 +921,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
947 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 921 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
948 922
949 // Send agent information about his groups 923 // Send agent information about his groups
950 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 924 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
951 } 925 }
952 926
953 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 927 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -955,19 +929,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
955 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 929 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
956 930
957 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 931 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
958 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); 932 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
959 933
960 remoteClient.SendJoinGroupReply(groupID, true); 934 remoteClient.SendJoinGroupReply(groupID, true);
961 935
962 // Should this send updates to everyone in the group? 936 // Should this send updates to everyone in the group?
963 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 937 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
964 } 938 }
965 939
966 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 940 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
967 { 941 {
968 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 942 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
969 943
970 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 944 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
971 945
972 remoteClient.SendLeaveGroupReply(groupID, true); 946 remoteClient.SendLeaveGroupReply(groupID, true);
973 947
@@ -975,21 +949,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
975 949
976 // SL sends out notifcations to the group messaging session that the person has left 950 // 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? 951 // Should this also update everyone who is in the group?
978 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 952 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
979 } 953 }
980 954
981 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 955 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
982 { 956 {
983 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 957 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
984 958
985 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
986 959
987 // Todo: Security check? 960 // Todo: Security check?
988 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); 961 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID);
989 962
990 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 963 remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true);
991 964
992 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); 965 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
993 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); 966 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
994 967
995 if ((groupInfo == null) || (userProfile == null)) 968 if ((groupInfo == null) || (userProfile == null))
@@ -1002,7 +975,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1002 GridInstantMessage msg = new GridInstantMessage(); 975 GridInstantMessage msg = new GridInstantMessage();
1003 976
1004 msg.imSessionID = UUID.Zero.Guid; 977 msg.imSessionID = UUID.Zero.Guid;
1005 msg.fromAgentID = remoteClient.AgentId.Guid; 978 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1006 // msg.fromAgentID = info.GroupID; 979 // msg.fromAgentID = info.GroupID;
1007 msg.toAgentID = ejecteeID.Guid; 980 msg.toAgentID = ejecteeID.Guid;
1008 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 981 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1028,8 +1001,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1028 1001
1029 msg = new GridInstantMessage(); 1002 msg = new GridInstantMessage();
1030 msg.imSessionID = UUID.Zero.Guid; 1003 msg.imSessionID = UUID.Zero.Guid;
1031 msg.fromAgentID = remoteClient.AgentId.Guid; 1004 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1032 msg.toAgentID = remoteClient.AgentId.Guid; 1005 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
1033 msg.timestamp = 0; 1006 msg.timestamp = 0;
1034 msg.fromAgentName = remoteClient.Name; 1007 msg.fromAgentName = remoteClient.Name;
1035 if (userProfile != null) 1008 if (userProfile != null)
@@ -1047,7 +1020,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1047 msg.Position = Vector3.Zero; 1020 msg.Position = Vector3.Zero;
1048 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; 1021 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
1049 msg.binaryBucket = new byte[0]; 1022 msg.binaryBucket = new byte[0];
1050 OutgoingInstantMessage(msg, remoteClient.AgentId); 1023 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
1051 1024
1052 1025
1053 // SL sends out messages to everyone in the group 1026 // SL sends out messages to everyone in the group
@@ -1057,17 +1030,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1057 1030
1058 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) 1031 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
1059 { 1032 {
1060 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1033 if (m_debugEnabled)
1034 {
1035 m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1036 m_log.DebugFormat("[GROUPS]: remoteClient({0}) groupID({0}) invitedAgentID({0}) roleID({0})", remoteClient, groupID, invitedAgentID, roleID);
1037 }
1038
1061 1039
1062 // Todo: Security check, probably also want to send some kind of notification 1040 // Todo: Security check, probably also want to send some kind of notification
1063 UUID InviteID = UUID.Random(); 1041 UUID InviteID = UUID.Random();
1064 GroupRequestID grid = GetClientGroupRequestID(remoteClient);
1065 1042
1066 m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); 1043 UUID requestingAgentID = GetRequestingAgentID(remoteClient);
1044 if (requestingAgentID == UUID.Zero)
1045 {
1046 m_log.Error("[GROUPS] Group Invite Requires a valid requesting agent to be specified");
1047 }
1048 m_groupData.AddAgentToGroupInvite(requestingAgentID, InviteID, groupID, roleID, invitedAgentID);
1067 1049
1068 // Check to see if the invite went through, if it did not then it's possible 1050 // 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. 1051 // the remoteClient did not validate or did not have permission to invite.
1070 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); 1052 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID);
1071 1053
1072 if (inviteInfo != null) 1054 if (inviteInfo != null)
1073 { 1055 {
@@ -1079,7 +1061,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1079 1061
1080 msg.imSessionID = inviteUUID; 1062 msg.imSessionID = inviteUUID;
1081 1063
1082 // msg.fromAgentID = remoteClient.AgentId.Guid; 1064 // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1083 msg.fromAgentID = groupID.Guid; 1065 msg.fromAgentID = groupID.Guid;
1084 msg.toAgentID = invitedAgentID.Guid; 1066 msg.toAgentID = invitedAgentID.Guid;
1085 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1067 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1132,57 +1114,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1132 return child; 1114 return child;
1133 } 1115 }
1134 1116
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> 1117 /// <summary>
1187 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1118 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1188 /// </summary> 1119 /// </summary>
@@ -1231,6 +1162,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1231 llDataStruct.Add("GroupData", GroupData); 1162 llDataStruct.Add("GroupData", GroupData);
1232 llDataStruct.Add("NewGroupData", NewGroupData); 1163 llDataStruct.Add("NewGroupData", NewGroupData);
1233 1164
1165 if (m_debugEnabled)
1166 {
1167 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1168 }
1169
1234 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 1170 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1235 1171
1236 if (queue != null) 1172 if (queue != null)
@@ -1308,7 +1244,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1308 /// <returns></returns> 1244 /// <returns></returns>
1309 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) 1245 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
1310 { 1246 {
1311 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); 1247 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID);
1312 GroupMembershipData[] membershipArray; 1248 GroupMembershipData[] membershipArray;
1313 1249
1314 if (requestingClient.AgentId != dataForAgentID) 1250 if (requestingClient.AgentId != dataForAgentID)
@@ -1330,7 +1266,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1330 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1266 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
1331 foreach (GroupMembershipData membership in membershipArray) 1267 foreach (GroupMembershipData membership in membershipArray)
1332 { 1268 {
1333 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); 1269 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers);
1334 } 1270 }
1335 } 1271 }
1336 1272
@@ -1389,6 +1325,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1389 } 1325 }
1390 1326
1391 #endregion 1327 #endregion
1328
1329 private UUID GetRequestingAgentID(IClientAPI client)
1330 {
1331 UUID requestingAgentID = UUID.Zero;
1332 if (client != null)
1333 {
1334 requestingAgentID = client.AgentId;
1335 }
1336 return requestingAgentID;
1337 }
1392 } 1338 }
1393 1339
1340 public class GroupNoticeInfo
1341 {
1342 public GroupNoticeData noticeData = new GroupNoticeData();
1343 public UUID GroupID = UUID.Zero;
1344 public string Message = string.Empty;
1345 public byte[] BinaryBucket = new byte[0];
1346 }
1394} 1347}