aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
diff options
context:
space:
mode:
authorCharles Krinke2009-04-29 22:31:00 +0000
committerCharles Krinke2009-04-29 22:31:00 +0000
commit8944ab910cc8f62dc6ce567046a92e50b1e2813f (patch)
treeb8042c6ff8bd2598280368cf87d535f8a22af362 /OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
parentCatch another j2k decode exception that can be caused by a bad asset (diff)
downloadopensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.zip
opensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.tar.gz
opensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.tar.bz2
opensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.tar.xz
Thank you kindly, MCortez for a patch that:
The attached patch provides the necessary infrastructure to support security and authentication features of the xmlrpc server. * Read/Write keys for accessing a Group's xmlrpc service. * Requiring user session verification for write operations.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs213
1 files changed, 151 insertions, 62 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
index 3337ccd..5ba7eff 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
@@ -28,8 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31 31using System.Timers;
32using System.Collections;
33 32
34using log4net; 33using log4net;
35using Nini.Config; 34using Nini.Config;
@@ -61,6 +60,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
61 /// XmlRpcMessagingEnabled = true 60 /// XmlRpcMessagingEnabled = true
62 /// XmlRpcNoticesEnabled = true 61 /// XmlRpcNoticesEnabled = true
63 /// XmlRpcDebugEnabled = true 62 /// XmlRpcDebugEnabled = true
63 /// XmlRpcServiceReadKey = 1234
64 /// XmlRpcServiceWriteKey = 1234
64 /// 65 ///
65 /// ; Disables HTTP Keep-Alive for Groups Module HTTP Requests, work around for 66 /// ; Disables HTTP Keep-Alive for Groups Module HTTP Requests, work around for
66 /// ; a problem discovered on some Windows based region servers. Only disable 67 /// ; a problem discovered on some Windows based region servers. Only disable
@@ -79,6 +80,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
79 80
80 private IGroupDataProvider m_groupData = null; 81 private IGroupDataProvider m_groupData = null;
81 82
83 class GroupRequestIDInfo
84 {
85 public GroupRequestID RequestID = new GroupRequestID();
86 public DateTime LastUsedTMStamp = DateTime.MinValue;
87 }
88 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
89 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
90 private Timer m_clientRequestIDFlushTimer = new Timer();
91
92
82 // Configuration settings 93 // Configuration settings
83 private const string m_defaultXmlRpcServiceURL = "http://osflotsam.org/xmlrpc.php"; 94 private const string m_defaultXmlRpcServiceURL = "http://osflotsam.org/xmlrpc.php";
84 private bool m_groupsEnabled = false; 95 private bool m_groupsEnabled = false;
@@ -119,12 +130,34 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
119 string ServiceURL = groupsConfig.GetString("XmlRpcServiceURL", m_defaultXmlRpcServiceURL); 130 string ServiceURL = groupsConfig.GetString("XmlRpcServiceURL", m_defaultXmlRpcServiceURL);
120 bool DisableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false); 131 bool DisableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false);
121 132
122 m_groupData = new XmlRpcGroupDataProvider(ServiceURL, DisableKeepAlive); 133 string ServiceReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
134 string ServiceWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
135
136 m_groupData = new XmlRpcGroupDataProvider(ServiceURL, DisableKeepAlive, ServiceReadKey, ServiceWriteKey);
123 m_log.InfoFormat("[GROUPS]: XmlRpc Service URL set to: {0}", ServiceURL); 137 m_log.InfoFormat("[GROUPS]: XmlRpc Service URL set to: {0}", ServiceURL);
124 138
125 m_groupNoticesEnabled = groupsConfig.GetBoolean("XmlRpcNoticesEnabled", true); 139 m_groupNoticesEnabled = groupsConfig.GetBoolean("XmlRpcNoticesEnabled", true);
126 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true); 140 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true);
127 141
142 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
143 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
144 m_clientRequestIDFlushTimer.Start();
145 }
146 }
147
148 void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
149 {
150 lock (m_clientRequestIDInfo)
151 {
152 TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
153 UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
154 foreach (UUID key in CurrentKeys)
155 {
156 if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
157 {
158 m_clientRequestIDInfo.Remove(key);
159 }
160 }
128 } 161 }
129 } 162 }
130 163
@@ -188,6 +221,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
188 return; 221 return;
189 222
190 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down XmlRpcGroups module."); 223 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down XmlRpcGroups module.");
224
225 m_clientRequestIDFlushTimer.Stop();
191 } 226 }
192 227
193 public string Name 228 public string Name
@@ -218,13 +253,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
218 253
219 // Used for Notices and Group Invites/Accept/Reject 254 // Used for Notices and Group Invites/Accept/Reject
220 client.OnInstantMessage += OnInstantMessage; 255 client.OnInstantMessage += OnInstantMessage;
221 256
257 lock (m_clientRequestIDInfo)
258 {
259 if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
260 {
261 // flush any old RequestID information
262 m_clientRequestIDInfo.Remove(client.AgentId);
263 }
264 }
222 SendAgentGroupDataUpdate(client, client.AgentId); 265 SendAgentGroupDataUpdate(client, client.AgentId);
223 } 266 }
224 267
225 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) 268 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
226 { 269 {
227 GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(avatarID).ToArray(); 270 GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray();
228 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 271 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
229 } 272 }
230 273
@@ -270,7 +313,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
270 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); 313 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);
271 314
272 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 315 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
273 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(queryText).ToArray()); 316 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray());
274 } 317 }
275 318
276 } 319 }
@@ -284,7 +327,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
284 string activeGroupName = string.Empty; 327 string activeGroupName = string.Empty;
285 ulong activeGroupPowers = (ulong)GroupPowers.None; 328 ulong activeGroupPowers = (ulong)GroupPowers.None;
286 329
287 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(dataForAgentID); 330 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID);
288 if (membership != null) 331 if (membership != null)
289 { 332 {
290 activeGroupID = membership.GroupID; 333 activeGroupID = membership.GroupID;
@@ -297,13 +340,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
297 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 340 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
298 } 341 }
299 342
300 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remote_client) 343 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient)
301 { 344 {
302 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 345 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
303 346
304 string GroupName; 347 string GroupName;
305 348
306 GroupRecord group = m_groupData.GetGroupRecord(GroupID, null); 349 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null);
307 if (group != null) 350 if (group != null)
308 { 351 {
309 GroupName = group.GroupName; 352 GroupName = group.GroupName;
@@ -313,7 +356,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
313 GroupName = "Unknown"; 356 GroupName = "Unknown";
314 } 357 }
315 358
316 remote_client.SendGroupNameReply(GroupID, GroupName); 359 remoteClient.SendGroupNameReply(GroupID, GroupName);
317 } 360 }
318 361
319 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 362 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
@@ -324,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
324 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 367 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
325 { 368 {
326 UUID inviteID = new UUID(im.imSessionID); 369 UUID inviteID = new UUID(im.imSessionID);
327 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(inviteID); 370 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
328 371
329 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Invite is for Agent {0} to Group {1}.", inviteInfo.AgentID, inviteInfo.GroupID); 372 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Invite is for Agent {0} to Group {1}.", inviteInfo.AgentID, inviteInfo.GroupID);
330 373
@@ -337,7 +380,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
337 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 380 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
338 381
339 // and the sessionid is the role 382 // and the sessionid is the role
340 m_groupData.AddAgentToGroup(inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 383 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
341 384
342 GridInstantMessage msg = new GridInstantMessage(); 385 GridInstantMessage msg = new GridInstantMessage();
343 msg.imSessionID = UUID.Zero.Guid; 386 msg.imSessionID = UUID.Zero.Guid;
@@ -361,14 +404,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
361 // TODO: If the inviter is still online, they need an agent dataupdate 404 // TODO: If the inviter is still online, they need an agent dataupdate
362 // and maybe group membership updates for the invitee 405 // and maybe group membership updates for the invitee
363 406
364 m_groupData.RemoveAgentToGroupInvite(inviteID); 407 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
365 } 408 }
366 409
367 // Reject 410 // Reject
368 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 411 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
369 { 412 {
370 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 413 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
371 m_groupData.RemoveAgentToGroupInvite(inviteID); 414 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
372 } 415 }
373 } 416 }
374 } 417 }
@@ -382,7 +425,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
382 } 425 }
383 426
384 UUID GroupID = new UUID(im.toAgentID); 427 UUID GroupID = new UUID(im.toAgentID);
385 if (m_groupData.GetGroupRecord(GroupID, null) != null) 428 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null)
386 { 429 {
387 UUID NoticeID = UUID.Random(); 430 UUID NoticeID = UUID.Random();
388 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 431 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -422,14 +465,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
422 bucket[18] = 0; //dunno 465 bucket[18] = 0; //dunno
423 } 466 }
424 467
425 m_groupData.AddGroupNotice(GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 468 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
426 if (OnNewGroupNotice != null) 469 if (OnNewGroupNotice != null)
427 { 470 {
428 OnNewGroupNotice(GroupID, NoticeID); 471 OnNewGroupNotice(GroupID, NoticeID);
429 } 472 }
430 473
431 // Send notice out to everyone that wants notices 474 // Send notice out to everyone that wants notices
432 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GroupID)) 475 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID))
433 { 476 {
434 if (member.AcceptNotices) 477 if (member.AcceptNotices)
435 { 478 {
@@ -501,14 +544,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
501 544
502 public GroupRecord GetGroupRecord(UUID GroupID) 545 public GroupRecord GetGroupRecord(UUID GroupID)
503 { 546 {
504 return m_groupData.GetGroupRecord(GroupID, null); 547 return m_groupData.GetGroupRecord(null, GroupID, null);
505 } 548 }
506 549
507 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 550 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
508 { 551 {
509 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 552 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
510 553
511 m_groupData.SetAgentActiveGroup(remoteClient.AgentId, groupID); 554 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
512 555
513 // Changing active group changes title, active powers, all kinds of things 556 // Changing active group changes title, active powers, all kinds of things
514 // anyone who is in any region that can see this client, should probably be 557 // anyone who is in any region that can see this client, should probably be
@@ -524,8 +567,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
524 { 567 {
525 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 568 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
526 569
527 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(remoteClient.AgentId, groupID); 570 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
528 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(remoteClient.AgentId, groupID); 571
572 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID);
573 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
529 574
530 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 575 List<GroupTitlesData> titles = new List<GroupTitlesData>();
531 foreach (GroupRolesData role in agentRoles) 576 foreach (GroupRolesData role in agentRoles)
@@ -548,7 +593,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
548 { 593 {
549 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 594 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
550 595
551 List<GroupMembersData> data = m_groupData.GetGroupMembers(groupID); 596 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID);
552 if (m_debugEnabled) 597 if (m_debugEnabled)
553 { 598 {
554 foreach (GroupMembersData member in data) 599 foreach (GroupMembersData member in data)
@@ -565,7 +610,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
565 { 610 {
566 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 611 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
567 612
568 List<GroupRolesData> data = m_groupData.GetGroupRoles(groupID); 613 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID);
569 614
570 if (m_debugEnabled) 615 if (m_debugEnabled)
571 { 616 {
@@ -583,7 +628,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
583 { 628 {
584 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);
585 630
586 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(groupID); 631 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID);
587 632
588 if (m_debugEnabled) 633 if (m_debugEnabled)
589 { 634 {
@@ -604,15 +649,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
604 649
605 GroupProfileData profile = new GroupProfileData(); 650 GroupProfileData profile = new GroupProfileData();
606 651
607 GroupRecord groupInfo = m_groupData.GetGroupRecord(groupID, null); 652 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
653
654 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null);
608 if (groupInfo != null) 655 if (groupInfo != null)
609 { 656 {
610 profile.AllowPublish = groupInfo.AllowPublish; 657 profile.AllowPublish = groupInfo.AllowPublish;
611 profile.Charter = groupInfo.Charter; 658 profile.Charter = groupInfo.Charter;
612 profile.FounderID = groupInfo.FounderID; 659 profile.FounderID = groupInfo.FounderID;
613 profile.GroupID = groupID; 660 profile.GroupID = groupID;
614 profile.GroupMembershipCount = m_groupData.GetGroupMembers(groupID).Count; 661 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count;
615 profile.GroupRolesCount = m_groupData.GetGroupRoles(groupID).Count; 662 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count;
616 profile.InsigniaID = groupInfo.GroupPicture; 663 profile.InsigniaID = groupInfo.GroupPicture;
617 profile.MaturePublish = groupInfo.MaturePublish; 664 profile.MaturePublish = groupInfo.MaturePublish;
618 profile.MembershipFee = groupInfo.MembershipFee; 665 profile.MembershipFee = groupInfo.MembershipFee;
@@ -623,7 +670,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
623 profile.ShowInList = groupInfo.ShowInList; 670 profile.ShowInList = groupInfo.ShowInList;
624 } 671 }
625 672
626 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(remoteClient.AgentId, groupID); 673 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
627 if (memberInfo != null) 674 if (memberInfo != null)
628 { 675 {
629 profile.MemberTitle = memberInfo.GroupTitle; 676 profile.MemberTitle = memberInfo.GroupTitle;
@@ -637,14 +684,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
637 { 684 {
638 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 685 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
639 686
640 return m_groupData.GetAgentGroupMemberships(agentID).ToArray(); 687 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray();
641 } 688 }
642 689
643 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 690 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
644 { 691 {
645 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 692 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
646 693
647 return m_groupData.GetAgentGroupMembership(agentID, groupID); 694 return m_groupData.GetAgentGroupMembership(null, agentID, groupID);
648 } 695 }
649 696
650 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 697 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
@@ -653,7 +700,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
653 700
654 // TODO: Security Check? 701 // TODO: Security Check?
655 702
656 m_groupData.UpdateGroup(groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); 703 m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
657 } 704 }
658 705
659 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 706 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
@@ -661,20 +708,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
661 // TODO: Security Check? 708 // TODO: Security Check?
662 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 709 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
663 710
664 m_groupData.SetAgentGroupInfo(remoteClient.AgentId, groupID, acceptNotices, listInProfile); 711 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile);
665 } 712 }
666 713
667 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 714 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
668 { 715 {
669 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 716 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
670 717
671 if (m_groupData.GetGroupRecord(UUID.Zero, name) != null) 718 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
719
720 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
672 { 721 {
673 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 722 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
674 return UUID.Zero; 723 return UUID.Zero;
675 } 724 }
676 725
677 UUID groupID = m_groupData.CreateGroup(name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); 726 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId);
678 727
679 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 728 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
680 729
@@ -689,8 +738,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
689 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 738 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
690 739
691 // ToDo: check if agent is a member of group and is allowed to see notices? 740 // ToDo: check if agent is a member of group and is allowed to see notices?
692 741
693 return m_groupData.GetGroupNotices(groupID).ToArray(); 742 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray();
694 } 743 }
695 744
696 /// <summary> 745 /// <summary>
@@ -700,7 +749,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
700 { 749 {
701 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 750 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
702 751
703 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(avatarID); 752 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID);
704 if (membership != null) 753 if (membership != null)
705 { 754 {
706 return membership.GroupTitle; 755 return membership.GroupTitle;
@@ -715,7 +764,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
715 { 764 {
716 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 765 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
717 766
718 m_groupData.SetAgentActiveGroupRole(remoteClient.AgentId, groupID, titleRoleID); 767 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID);
719 768
720 // TODO: Not sure what all is needed here, but if the active group role change is for the group 769 // TODO: Not sure what all is needed here, but if the active group role change is for the group
721 // the client currently has set active, then we need to do a scene presence update too 770 // the client currently has set active, then we need to do a scene presence update too
@@ -731,20 +780,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
731 780
732 // TODO: Security Checks? 781 // TODO: Security Checks?
733 782
783 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
784
734 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 785 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
735 { 786 {
736 case OpenMetaverse.GroupRoleUpdate.Create: 787 case OpenMetaverse.GroupRoleUpdate.Create:
737 m_groupData.AddGroupRole(groupID, UUID.Random(), name, description, title, powers); 788 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers);
738 break; 789 break;
739 790
740 case OpenMetaverse.GroupRoleUpdate.Delete: 791 case OpenMetaverse.GroupRoleUpdate.Delete:
741 m_groupData.RemoveGroupRole(groupID, roleID); 792 m_groupData.RemoveGroupRole(grID, groupID, roleID);
742 break; 793 break;
743 794
744 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 795 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
745 case OpenMetaverse.GroupRoleUpdate.UpdateData: 796 case OpenMetaverse.GroupRoleUpdate.UpdateData:
746 case OpenMetaverse.GroupRoleUpdate.UpdatePowers: 797 case OpenMetaverse.GroupRoleUpdate.UpdatePowers:
747 m_groupData.UpdateGroupRole(groupID, roleID, name, description, title, powers); 798 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers);
748 break; 799 break;
749 800
750 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 801 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -763,16 +814,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
763 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 814 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
764 // Todo: Security check 815 // Todo: Security check
765 816
817 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
818
766 switch (changes) 819 switch (changes)
767 { 820 {
768 case 0: 821 case 0:
769 // Add 822 // Add
770 m_groupData.AddAgentToGroupRole(memberID, groupID, roleID); 823 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID);
771 824
772 break; 825 break;
773 case 1: 826 case 1:
774 // Remove 827 // Remove
775 m_groupData.RemoveAgentFromGroupRole(memberID, groupID, roleID); 828 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID);
776 829
777 break; 830 break;
778 default: 831 default:
@@ -788,12 +841,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
788 { 841 {
789 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 842 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
790 843
791 844 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
792 GroupNoticeInfo data = m_groupData.GetGroupNotice(groupNoticeID); 845
846 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
793 847
794 if (data != null) 848 if (data != null)
795 { 849 {
796 GroupRecord groupInfo = m_groupData.GetGroupRecord(data.GroupID, null); 850 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null);
797 851
798 GridInstantMessage msg = new GridInstantMessage(); 852 GridInstantMessage msg = new GridInstantMessage();
799 msg.imSessionID = UUID.Zero.Guid; 853 msg.imSessionID = UUID.Zero.Guid;
@@ -825,12 +879,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
825 msg.dialog = dialog; 879 msg.dialog = dialog;
826 // msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNotice; 880 // msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNotice;
827 msg.fromGroup = true; 881 msg.fromGroup = true;
828 msg.offline = (byte)0; 882 msg.offline = (byte)1; // Allow this message to be stored for offline use
829 msg.ParentEstateID = 0; 883 msg.ParentEstateID = 0;
830 msg.Position = Vector3.Zero; 884 msg.Position = Vector3.Zero;
831 msg.RegionID = UUID.Zero.Guid; 885 msg.RegionID = UUID.Zero.Guid;
832 886
833 GroupNoticeInfo info = m_groupData.GetGroupNotice(groupNoticeID); 887 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID);
834 if (info != null) 888 if (info != null)
835 { 889 {
836 msg.fromAgentID = info.GroupID.Guid; 890 msg.fromAgentID = info.GroupID.Guid;
@@ -865,7 +919,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
865 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 919 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
866 920
867 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 921 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
868 m_groupData.AddAgentToGroup(remoteClient.AgentId, groupID, UUID.Zero); 922 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero);
869 923
870 remoteClient.SendJoinGroupReply(groupID, true); 924 remoteClient.SendJoinGroupReply(groupID, true);
871 925
@@ -877,7 +931,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
877 { 931 {
878 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 932 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
879 933
880 m_groupData.RemoveAgentFromGroup(remoteClient.AgentId, groupID); 934 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
881 935
882 remoteClient.SendLeaveGroupReply(groupID, true); 936 remoteClient.SendLeaveGroupReply(groupID, true);
883 937
@@ -892,12 +946,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
892 { 946 {
893 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 947 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
894 948
949 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
950
895 // Todo: Security check? 951 // Todo: Security check?
896 m_groupData.RemoveAgentFromGroup(ejecteeID, groupID); 952 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID);
897 953
898 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 954 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true);
899 955
900 GroupRecord groupInfo = m_groupData.GetGroupRecord(groupID, null); 956 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
901 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); 957 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
902 958
903 if ((groupInfo == null) || (userProfile == null)) 959 if ((groupInfo == null) || (userProfile == null))
@@ -969,7 +1025,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
969 1025
970 // Todo: Security check, probably also want to send some kind of notification 1026 // Todo: Security check, probably also want to send some kind of notification
971 UUID InviteID = UUID.Random(); 1027 UUID InviteID = UUID.Random();
972 m_groupData.AddAgentToGroupInvite(InviteID, groupID, roleID, invitedAgentID); 1028 m_groupData.AddAgentToGroupInvite(GetClientGroupRequestID(remoteClient), InviteID, groupID, roleID, invitedAgentID);
973 1029
974 if (m_msgTransferModule != null) 1030 if (m_msgTransferModule != null)
975 { 1031 {
@@ -1031,6 +1087,37 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1031 return child; 1087 return child;
1032 } 1088 }
1033 1089
1090 private GroupRequestID GetClientGroupRequestID(IClientAPI client)
1091 {
1092 lock (m_clientRequestIDInfo)
1093 {
1094 if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
1095 {
1096 GroupRequestIDInfo info = new GroupRequestIDInfo();
1097 info.RequestID.AgentID = client.AgentId;
1098 info.RequestID.SessionID = client.SessionId;
1099
1100 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1101 if (userProfile is ForeignUserProfileData)
1102 {
1103 // They aren't from around here
1104 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1105 info.RequestID.UserServiceURL = fupd.UserServerURI;
1106 }
1107 else
1108 {
1109 // They're a local user, use this:
1110 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1111 }
1112
1113 m_clientRequestIDInfo.Add(client.AgentId, info);
1114 }
1115
1116 m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
1117 }
1118 return m_clientRequestIDInfo[client.AgentId].RequestID;
1119 }
1120
1034 /// <summary> 1121 /// <summary>
1035 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1122 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1036 /// </summary> 1123 /// </summary>
@@ -1120,23 +1207,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1120 /// <summary> 1207 /// <summary>
1121 /// Update remoteClient with group information about dataForAgentID 1208 /// Update remoteClient with group information about dataForAgentID
1122 /// </summary> 1209 /// </summary>
1123 private void SendAgentGroupDataUpdate(IClientAPI client, UUID dataForAgentID) 1210 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForAgentID)
1124 { 1211 {
1125 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, client.Name); 1212 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name);
1126 1213
1127 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1214 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1128 1215
1129 OnAgentDataUpdateRequest(client, dataForAgentID, UUID.Zero); 1216 OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero);
1130 1217
1131 1218
1132 // Need to send a group membership update to the client 1219 // Need to send a group membership update to the client
1133 // UDP version doesn't seem to behave nicely 1220 // UDP version doesn't seem to behave nicely. But we're going to send it out here
1134 // client.SendGroupMembership(GetMembershipData(client.AgentId)); 1221 // with an empty group membership to hopefully remove groups being displayed due
1222 // to the core Groups Stub
1223 remoteClient.SendGroupMembership( new GroupMembershipData[0] );
1135 1224
1136 GroupMembershipData[] membershipData = m_groupData.GetAgentGroupMemberships(dataForAgentID).ToArray(); 1225 GroupMembershipData[] membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), dataForAgentID).ToArray();
1137 1226
1138 SendGroupMembershipInfoViaCaps(client, dataForAgentID, membershipData); 1227 SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipData);
1139 client.SendAvatarGroupsReply(dataForAgentID, membershipData); 1228 remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipData);
1140 1229
1141 } 1230 }
1142 1231