diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Addons/Groups/GroupsModule.cs | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to 'OpenSim/Addons/Groups/GroupsModule.cs')
-rw-r--r-- | OpenSim/Addons/Groups/GroupsModule.cs | 413 |
1 files changed, 202 insertions, 211 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index d121d1a..a4030aa 100644 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Groups | |||
51 | private List<Scene> m_sceneList = new List<Scene>(); | 51 | private List<Scene> m_sceneList = new List<Scene>(); |
52 | 52 | ||
53 | private IMessageTransferModule m_msgTransferModule = null; | 53 | private IMessageTransferModule m_msgTransferModule = null; |
54 | 54 | ||
55 | private IGroupsServicesConnector m_groupData = null; | 55 | private IGroupsServicesConnector m_groupData = null; |
56 | private IUserManagement m_UserManagement; | 56 | private IUserManagement m_UserManagement; |
57 | 57 | ||
@@ -137,13 +137,6 @@ namespace OpenSim.Groups | |||
137 | 137 | ||
138 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 138 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
139 | 139 | ||
140 | scene.EventManager.OnNewClient += OnNewClient; | ||
141 | scene.EventManager.OnMakeRootAgent += OnMakeRoot; | ||
142 | scene.EventManager.OnMakeChildAgent += OnMakeChild; | ||
143 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
144 | // The InstantMessageModule itself doesn't do this, | ||
145 | // so lets see if things explode if we don't do it | ||
146 | // scene.EventManager.OnClientClosed += OnClientClosed; | ||
147 | 140 | ||
148 | if (m_groupData == null) | 141 | if (m_groupData == null) |
149 | { | 142 | { |
@@ -182,6 +175,11 @@ namespace OpenSim.Groups | |||
182 | m_sceneList.Add(scene); | 175 | m_sceneList.Add(scene); |
183 | } | 176 | } |
184 | 177 | ||
178 | scene.EventManager.OnNewClient += OnNewClient; | ||
179 | scene.EventManager.OnMakeRootAgent += OnMakeRoot; | ||
180 | scene.EventManager.OnMakeChildAgent += OnMakeChild; | ||
181 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
182 | scene.EventManager.OnClientClosed += OnClientClosed; | ||
185 | 183 | ||
186 | } | 184 | } |
187 | 185 | ||
@@ -196,6 +194,7 @@ namespace OpenSim.Groups | |||
196 | scene.EventManager.OnMakeRootAgent -= OnMakeRoot; | 194 | scene.EventManager.OnMakeRootAgent -= OnMakeRoot; |
197 | scene.EventManager.OnMakeChildAgent -= OnMakeChild; | 195 | scene.EventManager.OnMakeChildAgent -= OnMakeChild; |
198 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 196 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
197 | scene.EventManager.OnClientClosed -= OnClientClosed; | ||
199 | 198 | ||
200 | lock (m_sceneList) | 199 | lock (m_sceneList) |
201 | { | 200 | { |
@@ -211,7 +210,7 @@ namespace OpenSim.Groups | |||
211 | if (m_debugEnabled) m_log.Debug("[Groups]: Shutting down Groups module."); | 210 | if (m_debugEnabled) m_log.Debug("[Groups]: Shutting down Groups module."); |
212 | } | 211 | } |
213 | 212 | ||
214 | public Type ReplaceableInterface | 213 | public Type ReplaceableInterface |
215 | { | 214 | { |
216 | get { return null; } | 215 | get { return null; } |
217 | } | 216 | } |
@@ -237,6 +236,7 @@ namespace OpenSim.Groups | |||
237 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; | 236 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; |
238 | } | 237 | } |
239 | 238 | ||
239 | |||
240 | private void OnMakeRoot(ScenePresence sp) | 240 | private void OnMakeRoot(ScenePresence sp) |
241 | { | 241 | { |
242 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 242 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -245,8 +245,12 @@ namespace OpenSim.Groups | |||
245 | // Used for Notices and Group Invites/Accept/Reject | 245 | // Used for Notices and Group Invites/Accept/Reject |
246 | sp.ControllingClient.OnInstantMessage += OnInstantMessage; | 246 | sp.ControllingClient.OnInstantMessage += OnInstantMessage; |
247 | 247 | ||
248 | // Send client their groups information. | 248 | // Send out group data update for compatibility. |
249 | SendAgentGroupDataUpdate(sp.ControllingClient, sp.UUID); | 249 | // There might be some problem with the thread we're generating this on but not |
250 | // doing the update at this time causes problems (Mantis #7920 and #7915) | ||
251 | // TODO: move sending this update to a later time in the rootification of the client. | ||
252 | if(!sp.haveGroupInformation) | ||
253 | SendAgentGroupDataUpdate(sp.ControllingClient, false); | ||
250 | } | 254 | } |
251 | 255 | ||
252 | private void OnMakeChild(ScenePresence sp) | 256 | private void OnMakeChild(ScenePresence sp) |
@@ -262,23 +266,28 @@ namespace OpenSim.Groups | |||
262 | { | 266 | { |
263 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 267 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
264 | 268 | ||
265 | //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray(); | ||
266 | GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); | 269 | GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); |
267 | remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); | 270 | remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); |
268 | } | 271 | } |
269 | 272 | ||
270 | /* | 273 | private void OnClientClosed(UUID AgentId, Scene scene) |
271 | * This becomes very problematic in a shared module. In a shared module you may have more then one | ||
272 | * reference to IClientAPI's, one for 0 or 1 root connections, and 0 or more child connections. | ||
273 | * The OnClientClosed event does not provide anything to indicate which one of those should be closed | ||
274 | * nor does it provide what scene it was from so that the specific reference can be looked up. | ||
275 | * The InstantMessageModule.cs does not currently worry about unregistering the handles, | ||
276 | * and it should be an issue, since it's the client that references us not the other way around | ||
277 | * , so as long as we don't keep a reference to the client laying around, the client can still be GC'ed | ||
278 | private void OnClientClosed(UUID AgentId) | ||
279 | { | 274 | { |
280 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 275 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
276 | if (scene == null) | ||
277 | return; | ||
278 | |||
279 | ScenePresence sp = scene.GetScenePresence(AgentId); | ||
280 | IClientAPI client = sp.ControllingClient; | ||
281 | if (client != null) | ||
282 | { | ||
283 | client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest; | ||
284 | client.OnRequestAvatarProperties -= OnRequestAvatarProperties; | ||
285 | // make child possible not called? | ||
286 | client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest; | ||
287 | client.OnInstantMessage -= OnInstantMessage; | ||
288 | } | ||
281 | 289 | ||
290 | /* | ||
282 | lock (m_ActiveClients) | 291 | lock (m_ActiveClients) |
283 | { | 292 | { |
284 | if (m_ActiveClients.ContainsKey(AgentId)) | 293 | if (m_ActiveClients.ContainsKey(AgentId)) |
@@ -296,31 +305,22 @@ namespace OpenSim.Groups | |||
296 | if (m_debugEnabled) m_log.WarnFormat("[Groups]: Client closed that wasn't registered here."); | 305 | if (m_debugEnabled) m_log.WarnFormat("[Groups]: Client closed that wasn't registered here."); |
297 | } | 306 | } |
298 | 307 | ||
299 | |||
300 | } | ||
301 | } | 308 | } |
302 | */ | 309 | */ |
303 | 310 | ||
311 | } | ||
312 | |||
304 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) | 313 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) |
305 | { | 314 | { |
306 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 315 | // this a private message for own agent only |
307 | 316 | if (dataForAgentID != GetRequestingAgentID(remoteClient)) | |
308 | UUID activeGroupID = UUID.Zero; | 317 | return; |
309 | string activeGroupTitle = string.Empty; | ||
310 | string activeGroupName = string.Empty; | ||
311 | ulong activeGroupPowers = (ulong)GroupPowers.None; | ||
312 | |||
313 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentIDStr(remoteClient), dataForAgentID.ToString()); | ||
314 | if (membership != null) | ||
315 | { | ||
316 | activeGroupID = membership.GroupID; | ||
317 | activeGroupTitle = membership.GroupTitle; | ||
318 | activeGroupPowers = membership.GroupPowers; | ||
319 | } | ||
320 | 318 | ||
321 | SendAgentDataUpdate(remoteClient, dataForAgentID, activeGroupID, activeGroupName, activeGroupPowers, activeGroupTitle); | 319 | SendAgentGroupDataUpdate(remoteClient, false); |
322 | 320 | ||
323 | SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); | 321 | // also current viewers do ignore it and ask later on a much nicer thread |
322 | // its a info request not a change, so nothing is sent to others | ||
323 | // they do get the group title with the avatar object update on arrivel to a region | ||
324 | } | 324 | } |
325 | 325 | ||
326 | private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) | 326 | private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) |
@@ -394,12 +394,14 @@ namespace OpenSim.Groups | |||
394 | msg.binaryBucket = new byte[0]; | 394 | msg.binaryBucket = new byte[0]; |
395 | 395 | ||
396 | OutgoingInstantMessage(msg, invitee); | 396 | OutgoingInstantMessage(msg, invitee); |
397 | 397 | IClientAPI inviteeClient = GetActiveRootClient(invitee); | |
398 | UpdateAllClientsWithGroupInfo(invitee); | 398 | if(inviteeClient !=null) |
399 | { | ||
400 | SendAgentGroupDataUpdate(inviteeClient,true); | ||
401 | } | ||
399 | } | 402 | } |
400 | 403 | ||
401 | m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentIDStr(remoteClient), inviteID); | 404 | m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentIDStr(remoteClient), inviteID); |
402 | |||
403 | } | 405 | } |
404 | 406 | ||
405 | // Reject | 407 | // Reject |
@@ -444,17 +446,16 @@ namespace OpenSim.Groups | |||
444 | 446 | ||
445 | UUID itemID = binBucketMap["item_id"].AsUUID(); | 447 | UUID itemID = binBucketMap["item_id"].AsUUID(); |
446 | UUID ownerID = binBucketMap["owner_id"].AsUUID(); | 448 | UUID ownerID = binBucketMap["owner_id"].AsUUID(); |
447 | item = new InventoryItemBase(itemID, ownerID); | 449 | item = m_sceneList[0].InventoryService.GetItem(ownerID, itemID); |
448 | item = m_sceneList[0].InventoryService.GetItem(item); | ||
449 | } | 450 | } |
450 | else | 451 | else |
451 | m_log.DebugFormat("[Groups]: Received OSD with unexpected type: {0}", binBucketOSD.GetType()); | 452 | m_log.DebugFormat("[Groups]: Received OSD with unexpected type: {0}", binBucketOSD.GetType()); |
452 | } | 453 | } |
453 | 454 | ||
454 | if (m_groupData.AddGroupNotice(GetRequestingAgentIDStr(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, | 455 | if (m_groupData.AddGroupNotice(GetRequestingAgentIDStr(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, |
455 | hasAttachment, | 456 | hasAttachment, |
456 | (byte)(item == null ? 0 : item.AssetType), | 457 | (byte)(item == null ? 0 : item.AssetType), |
457 | item == null ? null : item.Name, | 458 | item == null ? null : item.Name, |
458 | item == null ? UUID.Zero : item.ID, | 459 | item == null ? UUID.Zero : item.ID, |
459 | item == null ? UUID.Zero.ToString() : item.Owner.ToString())) | 460 | item == null ? UUID.Zero.ToString() : item.Owner.ToString())) |
460 | { | 461 | { |
@@ -463,7 +464,6 @@ namespace OpenSim.Groups | |||
463 | OnNewGroupNotice(GroupID, NoticeID); | 464 | OnNewGroupNotice(GroupID, NoticeID); |
464 | } | 465 | } |
465 | 466 | ||
466 | |||
467 | // Send notice out to everyone that wants notices | 467 | // Send notice out to everyone that wants notices |
468 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID)) | 468 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID)) |
469 | { | 469 | { |
@@ -497,7 +497,7 @@ namespace OpenSim.Groups | |||
497 | 497 | ||
498 | m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); | 498 | m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); |
499 | string message; | 499 | string message; |
500 | InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, | 500 | InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, |
501 | giver, notice.noticeData.AttachmentItemID, out message); | 501 | giver, notice.noticeData.AttachmentItemID, out message); |
502 | 502 | ||
503 | if (itemCopy == null) | 503 | if (itemCopy == null) |
@@ -508,12 +508,11 @@ namespace OpenSim.Groups | |||
508 | 508 | ||
509 | remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); | 509 | remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); |
510 | } | 510 | } |
511 | |||
512 | } | 511 | } |
513 | 512 | ||
514 | // Interop, received special 210 code for ejecting a group member | 513 | // Interop, received special 210 code for ejecting a group member |
515 | // this only works within the comms servers domain, and won't work hypergrid | 514 | // this only works within the comms servers domain, and won't work hypergrid |
516 | // TODO:FIXME: Use a presense server of some kind to find out where the | 515 | // TODO:FIXME: Use a presense server of some kind to find out where the |
517 | // client actually is, and try contacting that region directly to notify them, | 516 | // client actually is, and try contacting that region directly to notify them, |
518 | // or provide the notification via xmlrpc update queue | 517 | // or provide the notification via xmlrpc update queue |
519 | if ((im.dialog == 210)) | 518 | if ((im.dialog == 210)) |
@@ -524,14 +523,16 @@ namespace OpenSim.Groups | |||
524 | 523 | ||
525 | UUID ejecteeID = new UUID(im.toAgentID); | 524 | UUID ejecteeID = new UUID(im.toAgentID); |
526 | 525 | ||
526 | im.imSessionID = UUID.Zero.Guid; | ||
527 | im.dialog = (byte)InstantMessageDialog.MessageFromAgent; | 527 | im.dialog = (byte)InstantMessageDialog.MessageFromAgent; |
528 | OutgoingInstantMessage(im, ejecteeID); | 528 | OutgoingInstantMessage(im, ejecteeID); |
529 | 529 | ||
530 | IClientAPI ejectee = GetActiveClient(ejecteeID); | 530 | IClientAPI ejectee = GetActiveRootClient(ejecteeID); |
531 | if (ejectee != null) | 531 | if (ejectee != null) |
532 | { | 532 | { |
533 | UUID groupID = new UUID(im.imSessionID); | 533 | UUID groupID = new UUID(im.imSessionID); |
534 | ejectee.SendAgentDropGroup(groupID); | 534 | ejectee.SendAgentDropGroup(groupID); |
535 | SendAgentGroupDataUpdate(ejectee,true); | ||
535 | } | 536 | } |
536 | } | 537 | } |
537 | } | 538 | } |
@@ -551,7 +552,7 @@ namespace OpenSim.Groups | |||
551 | case (byte)InstantMessageDialog.GroupInvitation: | 552 | case (byte)InstantMessageDialog.GroupInvitation: |
552 | case (byte)InstantMessageDialog.GroupNotice: | 553 | case (byte)InstantMessageDialog.GroupNotice: |
553 | UUID toAgentID = new UUID(msg.toAgentID); | 554 | UUID toAgentID = new UUID(msg.toAgentID); |
554 | IClientAPI localClient = GetActiveClient(toAgentID); | 555 | IClientAPI localClient = GetActiveRootClient(toAgentID); |
555 | if (localClient != null) | 556 | if (localClient != null) |
556 | { | 557 | { |
557 | localClient.SendInstantMessage(msg); | 558 | localClient.SendInstantMessage(msg); |
@@ -576,7 +577,7 @@ namespace OpenSim.Groups | |||
576 | { | 577 | { |
577 | return m_groupData.GetGroupRecord(UUID.Zero.ToString(), UUID.Zero, name); | 578 | return m_groupData.GetGroupRecord(UUID.Zero.ToString(), UUID.Zero, name); |
578 | } | 579 | } |
579 | 580 | ||
580 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) | 581 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) |
581 | { | 582 | { |
582 | 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); |
@@ -584,10 +585,10 @@ namespace OpenSim.Groups | |||
584 | m_groupData.SetAgentActiveGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID); | 585 | m_groupData.SetAgentActiveGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID); |
585 | 586 | ||
586 | // Changing active group changes title, active powers, all kinds of things | 587 | // Changing active group changes title, active powers, all kinds of things |
587 | // anyone who is in any region that can see this client, should probably be | 588 | // anyone who is in any region that can see this client, should probably be |
588 | // updated with new group info. At a minimum, they should get ScenePresence | 589 | // updated with new group info. At a minimum, they should get ScenePresence |
589 | // updated with new title. | 590 | // updated with new title. |
590 | UpdateAllClientsWithGroupInfo(remoteClient.AgentId); | 591 | SendAgentGroupDataUpdate(remoteClient, true); |
591 | } | 592 | } |
592 | 593 | ||
593 | /// <summary> | 594 | /// <summary> |
@@ -619,10 +620,10 @@ namespace OpenSim.Groups | |||
619 | 620 | ||
620 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) | 621 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) |
621 | { | 622 | { |
622 | if (m_debugEnabled) | 623 | if (m_debugEnabled) |
623 | m_log.DebugFormat( | 624 | m_log.DebugFormat( |
624 | "[Groups]: GroupMembersRequest called for {0} from client {1}", groupID, remoteClient.Name); | 625 | "[Groups]: GroupMembersRequest called for {0} from client {1}", groupID, remoteClient.Name); |
625 | 626 | ||
626 | List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), groupID); | 627 | List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), groupID); |
627 | 628 | ||
628 | if (m_debugEnabled) | 629 | if (m_debugEnabled) |
@@ -634,7 +635,6 @@ namespace OpenSim.Groups | |||
634 | } | 635 | } |
635 | 636 | ||
636 | return data; | 637 | return data; |
637 | |||
638 | } | 638 | } |
639 | 639 | ||
640 | public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID) | 640 | public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID) |
@@ -706,7 +706,7 @@ namespace OpenSim.Groups | |||
706 | 706 | ||
707 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) | 707 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) |
708 | { | 708 | { |
709 | if (m_debugEnabled) | 709 | if (m_debugEnabled) |
710 | m_log.DebugFormat( | 710 | m_log.DebugFormat( |
711 | "[Groups]: {0} called with groupID={1}, agentID={2}", | 711 | "[Groups]: {0} called with groupID={1}, agentID={2}", |
712 | System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); | 712 | System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); |
@@ -714,6 +714,12 @@ namespace OpenSim.Groups | |||
714 | return m_groupData.GetAgentGroupMembership(UUID.Zero.ToString(), agentID.ToString(), groupID); | 714 | return m_groupData.GetAgentGroupMembership(UUID.Zero.ToString(), agentID.ToString(), groupID); |
715 | } | 715 | } |
716 | 716 | ||
717 | public GroupMembershipData GetActiveMembershipData(UUID agentID) | ||
718 | { | ||
719 | string agentIDstr = agentID.ToString(); | ||
720 | return m_groupData.GetAgentActiveMembership(agentIDstr, agentIDstr); | ||
721 | } | ||
722 | |||
717 | public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) | 723 | public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) |
718 | { | 724 | { |
719 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 725 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -750,7 +756,7 @@ namespace OpenSim.Groups | |||
750 | 756 | ||
751 | if (avatar != null) | 757 | if (avatar != null) |
752 | { | 758 | { |
753 | if (avatar.UserLevel < m_levelGroupCreate) | 759 | if (avatar.GodController.UserLevel < m_levelGroupCreate) |
754 | { | 760 | { |
755 | remoteClient.SendCreateGroupReply(UUID.Zero, false, String.Format("Insufficient permissions to create a group. Requires level {0}", m_levelGroupCreate)); | 761 | remoteClient.SendCreateGroupReply(UUID.Zero, false, String.Format("Insufficient permissions to create a group. Requires level {0}", m_levelGroupCreate)); |
756 | return UUID.Zero; | 762 | return UUID.Zero; |
@@ -758,7 +764,7 @@ namespace OpenSim.Groups | |||
758 | } | 764 | } |
759 | 765 | ||
760 | // check funds | 766 | // check funds |
761 | // is there is a money module present ? | 767 | // is there a money module present ? |
762 | IMoneyModule money = scene.RequestModuleInterface<IMoneyModule>(); | 768 | IMoneyModule money = scene.RequestModuleInterface<IMoneyModule>(); |
763 | if (money != null) | 769 | if (money != null) |
764 | { | 770 | { |
@@ -770,18 +776,18 @@ namespace OpenSim.Groups | |||
770 | } | 776 | } |
771 | 777 | ||
772 | string reason = string.Empty; | 778 | string reason = string.Empty; |
773 | UUID groupID = m_groupData.CreateGroup(remoteClient.AgentId, name, charter, showInList, insigniaID, membershipFee, openEnrollment, | 779 | UUID groupID = m_groupData.CreateGroup(remoteClient.AgentId, name, charter, showInList, insigniaID, membershipFee, openEnrollment, |
774 | allowPublish, maturePublish, remoteClient.AgentId, out reason); | 780 | allowPublish, maturePublish, remoteClient.AgentId, out reason); |
775 | 781 | ||
776 | if (groupID != UUID.Zero) | 782 | if (groupID != UUID.Zero) |
777 | { | 783 | { |
778 | if (money != null) | 784 | if (money != null && money.GroupCreationCharge > 0) |
779 | money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate); | 785 | money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate, name); |
780 | 786 | ||
781 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); | 787 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully"); |
782 | 788 | ||
783 | // Update the founder with new group information. | 789 | // Update the founder with new group information. |
784 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); | 790 | SendAgentGroupDataUpdate(remoteClient, true); |
785 | } | 791 | } |
786 | else | 792 | else |
787 | remoteClient.SendCreateGroupReply(groupID, false, reason); | 793 | remoteClient.SendCreateGroupReply(groupID, false, reason); |
@@ -817,7 +823,7 @@ namespace OpenSim.Groups | |||
817 | if (membership != null) | 823 | if (membership != null) |
818 | { | 824 | { |
819 | return membership.GroupTitle; | 825 | return membership.GroupTitle; |
820 | } | 826 | } |
821 | return string.Empty; | 827 | return string.Empty; |
822 | } | 828 | } |
823 | 829 | ||
@@ -833,8 +839,8 @@ namespace OpenSim.Groups | |||
833 | // TODO: Not sure what all is needed here, but if the active group role change is for the group | 839 | // TODO: Not sure what all is needed here, but if the active group role change is for the group |
834 | // the client currently has set active, then we need to do a scene presence update too | 840 | // the client currently has set active, then we need to do a scene presence update too |
835 | // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) | 841 | // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) |
836 | 842 | ||
837 | UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); | 843 | SendDataUpdate(remoteClient, true); |
838 | } | 844 | } |
839 | 845 | ||
840 | 846 | ||
@@ -875,7 +881,7 @@ namespace OpenSim.Groups | |||
875 | } | 881 | } |
876 | 882 | ||
877 | // TODO: This update really should send out updates for everyone in the role that just got changed. | 883 | // TODO: This update really should send out updates for everyone in the role that just got changed. |
878 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); | 884 | SendDataUpdate(remoteClient, true); |
879 | } | 885 | } |
880 | 886 | ||
881 | public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) | 887 | public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) |
@@ -893,7 +899,7 @@ namespace OpenSim.Groups | |||
893 | case 1: | 899 | case 1: |
894 | // Remove | 900 | // Remove |
895 | m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentIDStr(remoteClient), memberID.ToString(), groupID, roleID); | 901 | m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentIDStr(remoteClient), memberID.ToString(), groupID, roleID); |
896 | 902 | ||
897 | break; | 903 | break; |
898 | default: | 904 | default: |
899 | m_log.ErrorFormat("[Groups]: {0} does not understand changes == {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, changes); | 905 | m_log.ErrorFormat("[Groups]: {0} does not understand changes == {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, changes); |
@@ -901,7 +907,7 @@ namespace OpenSim.Groups | |||
901 | } | 907 | } |
902 | 908 | ||
903 | // TODO: This update really should send out updates for everyone in the role that just got changed. | 909 | // TODO: This update really should send out updates for everyone in the role that just got changed. |
904 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); | 910 | SendDataUpdate(remoteClient, true); |
905 | } | 911 | } |
906 | 912 | ||
907 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) | 913 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) |
@@ -969,27 +975,37 @@ namespace OpenSim.Groups | |||
969 | return msg; | 975 | return msg; |
970 | } | 976 | } |
971 | 977 | ||
972 | public void SendAgentGroupDataUpdate(IClientAPI remoteClient) | 978 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) |
973 | { | 979 | { |
974 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 980 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
975 | 981 | ||
976 | // Send agent information about his groups | 982 | GroupRecord groupRecord = GetGroupRecord(groupID); |
977 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); | 983 | IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>(); |
978 | } | ||
979 | 984 | ||
980 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) | 985 | // Should check to see if there's an outstanding invitation |
981 | { | 986 | |
982 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 987 | if (money != null && groupRecord.MembershipFee > 0) |
988 | { | ||
989 | // Does the agent have the funds to cover the group join fee? | ||
990 | if (!money.AmountCovered(remoteClient.AgentId, groupRecord.MembershipFee)) | ||
991 | { | ||
992 | remoteClient.SendAlertMessage("Insufficient funds to join the group."); | ||
993 | remoteClient.SendJoinGroupReply(groupID, false); | ||
994 | return; | ||
995 | } | ||
996 | } | ||
983 | 997 | ||
984 | string reason = string.Empty; | 998 | string reason = string.Empty; |
985 | // Should check to see if OpenEnrollment, or if there's an outstanding invitation | 999 | |
986 | if (m_groupData.AddAgentToGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID, UUID.Zero, string.Empty, out reason)) | 1000 | if (m_groupData.AddAgentToGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID, UUID.Zero, string.Empty, out reason)) |
987 | { | 1001 | { |
1002 | if (money != null && groupRecord.MembershipFee > 0) | ||
1003 | money.ApplyCharge(remoteClient.AgentId, groupRecord.MembershipFee, MoneyTransactionType.GroupJoin, groupRecord.GroupName); | ||
988 | 1004 | ||
989 | remoteClient.SendJoinGroupReply(groupID, true); | 1005 | remoteClient.SendJoinGroupReply(groupID, true); |
990 | 1006 | ||
991 | // Should this send updates to everyone in the group? | 1007 | // Should this send updates to everyone in the group? |
992 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); | 1008 | SendAgentGroupDataUpdate(remoteClient, true); |
993 | 1009 | ||
994 | if (reason != string.Empty) | 1010 | if (reason != string.Empty) |
995 | // A warning | 1011 | // A warning |
@@ -999,6 +1015,15 @@ namespace OpenSim.Groups | |||
999 | remoteClient.SendJoinGroupReply(groupID, false); | 1015 | remoteClient.SendJoinGroupReply(groupID, false); |
1000 | } | 1016 | } |
1001 | 1017 | ||
1018 | public void JoinGroup(string agentID, UUID groupID) | ||
1019 | { | ||
1020 | string reason = string.Empty; | ||
1021 | m_groupData.AddAgentToGroup(agentID, agentID, groupID, UUID.Zero, string.Empty, out reason); | ||
1022 | if (reason != string.Empty) | ||
1023 | // A warning | ||
1024 | m_log.Warn("[Groups]: Join group warning - " + reason); | ||
1025 | } | ||
1026 | |||
1002 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) | 1027 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) |
1003 | { | 1028 | { |
1004 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1029 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -1011,7 +1036,7 @@ namespace OpenSim.Groups | |||
1011 | 1036 | ||
1012 | // SL sends out notifcations to the group messaging session that the person has left | 1037 | // SL sends out notifcations to the group messaging session that the person has left |
1013 | // Should this also update everyone who is in the group? | 1038 | // Should this also update everyone who is in the group? |
1014 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); | 1039 | SendAgentGroupDataUpdate(remoteClient, true); |
1015 | } | 1040 | } |
1016 | 1041 | ||
1017 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) | 1042 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) |
@@ -1070,10 +1095,31 @@ namespace OpenSim.Groups | |||
1070 | return; | 1095 | return; |
1071 | } | 1096 | } |
1072 | 1097 | ||
1098 | IClientAPI ejecteeClient = GetActiveRootClient(ejecteeID); | ||
1099 | |||
1073 | // Send Message to Ejectee | 1100 | // Send Message to Ejectee |
1074 | GridInstantMessage msg = new GridInstantMessage(); | 1101 | GridInstantMessage msg = new GridInstantMessage(); |
1075 | 1102 | ||
1076 | msg.imSessionID = UUID.Zero.Guid; | 1103 | // if local send a normal message |
1104 | if(ejecteeClient != null) | ||
1105 | { | ||
1106 | msg.imSessionID = UUID.Zero.Guid; | ||
1107 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; | ||
1108 | // also execute and send update | ||
1109 | ejecteeClient.SendAgentDropGroup(groupID); | ||
1110 | SendAgentGroupDataUpdate(ejecteeClient,true); | ||
1111 | } | ||
1112 | else // send | ||
1113 | { | ||
1114 | // Interop, received special 210 code for ejecting a group member | ||
1115 | // this only works within the comms servers domain, and won't work hypergrid | ||
1116 | // TODO:FIXME: Use a presence server of some kind to find out where the | ||
1117 | // client actually is, and try contacting that region directly to notify them, | ||
1118 | // or provide the notification via xmlrpc update queue | ||
1119 | |||
1120 | msg.imSessionID = groupInfo.GroupID.Guid; | ||
1121 | msg.dialog = (byte)210; //interop | ||
1122 | } | ||
1077 | msg.fromAgentID = agentID.Guid; | 1123 | msg.fromAgentID = agentID.Guid; |
1078 | // msg.fromAgentID = info.GroupID; | 1124 | // msg.fromAgentID = info.GroupID; |
1079 | msg.toAgentID = ejecteeID.Guid; | 1125 | msg.toAgentID = ejecteeID.Guid; |
@@ -1081,7 +1127,7 @@ namespace OpenSim.Groups | |||
1081 | msg.timestamp = 0; | 1127 | msg.timestamp = 0; |
1082 | msg.fromAgentName = agentName; | 1128 | msg.fromAgentName = agentName; |
1083 | msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); | 1129 | msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); |
1084 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; | 1130 | |
1085 | msg.fromGroup = false; | 1131 | msg.fromGroup = false; |
1086 | msg.offline = (byte)0; | 1132 | msg.offline = (byte)0; |
1087 | msg.ParentEstateID = 0; | 1133 | msg.ParentEstateID = 0; |
@@ -1091,11 +1137,7 @@ namespace OpenSim.Groups | |||
1091 | OutgoingInstantMessage(msg, ejecteeID); | 1137 | OutgoingInstantMessage(msg, ejecteeID); |
1092 | 1138 | ||
1093 | // Message to ejector | 1139 | // Message to ejector |
1094 | // Interop, received special 210 code for ejecting a group member | 1140 | |
1095 | // this only works within the comms servers domain, and won't work hypergrid | ||
1096 | // TODO:FIXME: Use a presense server of some kind to find out where the | ||
1097 | // client actually is, and try contacting that region directly to notify them, | ||
1098 | // or provide the notification via xmlrpc update queue | ||
1099 | 1141 | ||
1100 | msg = new GridInstantMessage(); | 1142 | msg = new GridInstantMessage(); |
1101 | msg.imSessionID = UUID.Zero.Guid; | 1143 | msg.imSessionID = UUID.Zero.Guid; |
@@ -1111,7 +1153,7 @@ namespace OpenSim.Groups | |||
1111 | { | 1153 | { |
1112 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member"); | 1154 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member"); |
1113 | } | 1155 | } |
1114 | msg.dialog = (byte)210; //interop | 1156 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; |
1115 | msg.fromGroup = false; | 1157 | msg.fromGroup = false; |
1116 | msg.offline = (byte)0; | 1158 | msg.offline = (byte)0; |
1117 | msg.ParentEstateID = 0; | 1159 | msg.ParentEstateID = 0; |
@@ -1119,11 +1161,6 @@ namespace OpenSim.Groups | |||
1119 | msg.RegionID = regionInfo.RegionID.Guid; | 1161 | msg.RegionID = regionInfo.RegionID.Guid; |
1120 | msg.binaryBucket = new byte[0]; | 1162 | msg.binaryBucket = new byte[0]; |
1121 | OutgoingInstantMessage(msg, agentID); | 1163 | OutgoingInstantMessage(msg, agentID); |
1122 | |||
1123 | |||
1124 | // SL sends out messages to everyone in the group | ||
1125 | // Who all should receive updates and what should they be updated with? | ||
1126 | UpdateAllClientsWithGroupInfo(ejecteeID); | ||
1127 | } | 1164 | } |
1128 | 1165 | ||
1129 | public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) | 1166 | public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) |
@@ -1186,6 +1223,18 @@ namespace OpenSim.Groups | |||
1186 | #endregion | 1223 | #endregion |
1187 | 1224 | ||
1188 | #region Client/Update Tools | 1225 | #region Client/Update Tools |
1226 | private IClientAPI GetActiveRootClient(UUID agentID) | ||
1227 | { | ||
1228 | foreach (Scene scene in m_sceneList) | ||
1229 | { | ||
1230 | ScenePresence sp = scene.GetScenePresence(agentID); | ||
1231 | if (sp != null && !sp.IsChildAgent && !sp.IsDeleted) | ||
1232 | { | ||
1233 | return sp.ControllingClient; | ||
1234 | } | ||
1235 | } | ||
1236 | return null; | ||
1237 | } | ||
1189 | 1238 | ||
1190 | /// <summary> | 1239 | /// <summary> |
1191 | /// Try to find an active IClientAPI reference for agentID giving preference to root connections | 1240 | /// Try to find an active IClientAPI reference for agentID giving preference to root connections |
@@ -1198,7 +1247,7 @@ namespace OpenSim.Groups | |||
1198 | foreach (Scene scene in m_sceneList) | 1247 | foreach (Scene scene in m_sceneList) |
1199 | { | 1248 | { |
1200 | ScenePresence sp = scene.GetScenePresence(agentID); | 1249 | ScenePresence sp = scene.GetScenePresence(agentID); |
1201 | if (sp != null) | 1250 | if (sp != null&& !sp.IsDeleted) |
1202 | { | 1251 | { |
1203 | if (!sp.IsChildAgent) | 1252 | if (!sp.IsChildAgent) |
1204 | { | 1253 | { |
@@ -1215,71 +1264,6 @@ namespace OpenSim.Groups | |||
1215 | return child; | 1264 | return child; |
1216 | } | 1265 | } |
1217 | 1266 | ||
1218 | /// <summary> | ||
1219 | /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. | ||
1220 | /// </summary> | ||
1221 | private void SendGroupMembershipInfoViaCaps(IClientAPI remoteClient, UUID dataForAgentID, GroupMembershipData[] data) | ||
1222 | { | ||
1223 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
1224 | |||
1225 | // NPCs currently don't have a CAPs structure or event queues. There is a strong argument for conveying this information | ||
1226 | // to them anyway since it makes writing server-side bots a lot easier, but for now we don't do anything. | ||
1227 | if (remoteClient.SceneAgent.PresenceType == PresenceType.Npc) | ||
1228 | return; | ||
1229 | |||
1230 | OSDArray AgentData = new OSDArray(1); | ||
1231 | OSDMap AgentDataMap = new OSDMap(1); | ||
1232 | AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID)); | ||
1233 | AgentData.Add(AgentDataMap); | ||
1234 | |||
1235 | OSDArray GroupData = new OSDArray(data.Length); | ||
1236 | OSDArray NewGroupData = new OSDArray(data.Length); | ||
1237 | |||
1238 | foreach (GroupMembershipData membership in data) | ||
1239 | { | ||
1240 | if (GetRequestingAgentID(remoteClient) != dataForAgentID) | ||
1241 | { | ||
1242 | if (!membership.ListInProfile) | ||
1243 | { | ||
1244 | // If we're sending group info to remoteclient about another agent, | ||
1245 | // filter out groups the other agent doesn't want to share. | ||
1246 | continue; | ||
1247 | } | ||
1248 | } | ||
1249 | |||
1250 | OSDMap GroupDataMap = new OSDMap(6); | ||
1251 | OSDMap NewGroupDataMap = new OSDMap(1); | ||
1252 | |||
1253 | GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID)); | ||
1254 | GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers)); | ||
1255 | GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices)); | ||
1256 | GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture)); | ||
1257 | GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution)); | ||
1258 | GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName)); | ||
1259 | NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile)); | ||
1260 | |||
1261 | GroupData.Add(GroupDataMap); | ||
1262 | NewGroupData.Add(NewGroupDataMap); | ||
1263 | } | ||
1264 | |||
1265 | OSDMap llDataStruct = new OSDMap(3); | ||
1266 | llDataStruct.Add("AgentData", AgentData); | ||
1267 | llDataStruct.Add("GroupData", GroupData); | ||
1268 | llDataStruct.Add("NewGroupData", NewGroupData); | ||
1269 | |||
1270 | if (m_debugEnabled) | ||
1271 | { | ||
1272 | m_log.InfoFormat("[Groups]: {0}", OSDParser.SerializeJsonString(llDataStruct)); | ||
1273 | } | ||
1274 | |||
1275 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); | ||
1276 | |||
1277 | if (queue != null) | ||
1278 | { | ||
1279 | queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); | ||
1280 | } | ||
1281 | } | ||
1282 | |||
1283 | private void SendScenePresenceUpdate(UUID AgentID, string Title) | 1267 | private void SendScenePresenceUpdate(UUID AgentID, string Title) |
1284 | { | 1268 | { |
1285 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: Updating scene title for {0} with title: {1}", AgentID, Title); | 1269 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: Updating scene title for {0} with title: {1}", AgentID, Title); |
@@ -1296,53 +1280,39 @@ namespace OpenSim.Groups | |||
1296 | presence.Grouptitle = Title; | 1280 | presence.Grouptitle = Title; |
1297 | 1281 | ||
1298 | if (! presence.IsChildAgent) | 1282 | if (! presence.IsChildAgent) |
1299 | presence.SendAvatarDataToAllClients(); | 1283 | presence.SendAvatarDataToAllAgents(); |
1300 | } | 1284 | } |
1301 | } | 1285 | } |
1302 | } | 1286 | } |
1303 | } | 1287 | } |
1304 | 1288 | ||
1305 | /// <summary> | 1289 | public void SendAgentGroupDataUpdate(IClientAPI remoteClient) |
1306 | /// Send updates to all clients who might be interested in groups data for dataForClientID | ||
1307 | /// </summary> | ||
1308 | private void UpdateAllClientsWithGroupInfo(UUID dataForClientID) | ||
1309 | { | 1290 | { |
1310 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1291 | SendAgentGroupDataUpdate(remoteClient, true); |
1311 | |||
1312 | // TODO: Probably isn't nessesary to update every client in every scene. | ||
1313 | // Need to examine client updates and do only what's nessesary. | ||
1314 | lock (m_sceneList) | ||
1315 | { | ||
1316 | foreach (Scene scene in m_sceneList) | ||
1317 | { | ||
1318 | scene.ForEachClient(delegate(IClientAPI client) { SendAgentGroupDataUpdate(client, dataForClientID); }); | ||
1319 | } | ||
1320 | } | ||
1321 | } | 1292 | } |
1322 | 1293 | ||
1323 | /// <summary> | 1294 | /// <summary> |
1324 | /// Update remoteClient with group information about dataForAgentID | 1295 | /// Tell remoteClient about its agent groups, and optionally send title to others |
1325 | /// </summary> | 1296 | /// </summary> |
1326 | private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForAgentID) | 1297 | private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers) |
1327 | { | 1298 | { |
1328 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name); | 1299 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name); |
1329 | 1300 | ||
1301 | // NPCs currently don't have a CAPs structure or event queues. There is a strong argument for conveying this information | ||
1302 | // to them anyway since it makes writing server-side bots a lot easier, but for now we don't do anything. | ||
1303 | if (remoteClient.SceneAgent.PresenceType == PresenceType.Npc) | ||
1304 | return; | ||
1305 | |||
1330 | // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff | 1306 | // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff |
1331 | 1307 | ||
1332 | OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero); | 1308 | UUID agentID = GetRequestingAgentID(remoteClient); |
1333 | 1309 | ||
1334 | // Need to send a group membership update to the client | 1310 | SendDataUpdate(remoteClient, tellOthers); |
1335 | // UDP version doesn't seem to behave nicely. But we're going to send it out here | ||
1336 | // with an empty group membership to hopefully remove groups being displayed due | ||
1337 | // to the core Groups Stub | ||
1338 | //remoteClient.SendGroupMembership(new GroupMembershipData[0]); | ||
1339 | 1311 | ||
1340 | GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID); | 1312 | GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID); |
1341 | SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); | ||
1342 | 1313 | ||
1343 | //remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray); | 1314 | remoteClient.UpdateGroupMembership(membershipArray); |
1344 | if (remoteClient.AgentId == dataForAgentID) | 1315 | remoteClient.SendAgentGroupDataUpdate(agentID, membershipArray); |
1345 | remoteClient.RefreshGroupMembership(); | ||
1346 | } | 1316 | } |
1347 | 1317 | ||
1348 | /// <summary> | 1318 | /// <summary> |
@@ -1381,7 +1351,7 @@ namespace OpenSim.Groups | |||
1381 | membershipArray = membershipData.ToArray(); | 1351 | membershipArray = membershipData.ToArray(); |
1382 | } | 1352 | } |
1383 | } | 1353 | } |
1384 | 1354 | ||
1385 | if (m_debugEnabled) | 1355 | if (m_debugEnabled) |
1386 | { | 1356 | { |
1387 | m_log.InfoFormat("[Groups]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); | 1357 | m_log.InfoFormat("[Groups]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); |
@@ -1394,27 +1364,49 @@ namespace OpenSim.Groups | |||
1394 | return membershipArray; | 1364 | return membershipArray; |
1395 | } | 1365 | } |
1396 | 1366 | ||
1397 | 1367 | //tell remoteClient about its agent group info, and optionally send title to others | |
1398 | private void SendAgentDataUpdate(IClientAPI remoteClient, UUID dataForAgentID, UUID activeGroupID, string activeGroupName, ulong activeGroupPowers, string activeGroupTitle) | 1368 | private void SendDataUpdate(IClientAPI remoteClient, bool tellOthers) |
1399 | { | 1369 | { |
1400 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1370 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
1401 | 1371 | ||
1402 | // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff | 1372 | UUID activeGroupID = UUID.Zero; |
1403 | string firstname = "Unknown", lastname = "Unknown"; | 1373 | string activeGroupTitle = string.Empty; |
1404 | string name = m_UserManagement.GetUserName(dataForAgentID); | 1374 | string activeGroupName = string.Empty; |
1405 | if (!string.IsNullOrEmpty(name)) | 1375 | ulong activeGroupPowers = (ulong)GroupPowers.None; |
1376 | |||
1377 | UUID agentID = GetRequestingAgentID(remoteClient); | ||
1378 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(agentID.ToString(), agentID.ToString()); | ||
1379 | if (membership != null) | ||
1406 | { | 1380 | { |
1407 | string[] parts = name.Split(new char[] { ' ' }); | 1381 | activeGroupID = membership.GroupID; |
1408 | if (parts.Length >= 2) | 1382 | activeGroupTitle = membership.GroupTitle; |
1409 | { | 1383 | activeGroupPowers = membership.GroupPowers; |
1410 | firstname = parts[0]; | 1384 | activeGroupName = membership.GroupName; |
1411 | lastname = parts[1]; | 1385 | } |
1412 | } | 1386 | |
1387 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, agentID); | ||
1388 | string firstname, lastname; | ||
1389 | if (account != null) | ||
1390 | { | ||
1391 | firstname = account.FirstName; | ||
1392 | lastname = account.LastName; | ||
1393 | } | ||
1394 | else | ||
1395 | { | ||
1396 | firstname = "Unknown"; | ||
1397 | lastname = "Unknown"; | ||
1413 | } | 1398 | } |
1414 | 1399 | ||
1415 | remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, | 1400 | remoteClient.SendAgentDataUpdate(agentID, activeGroupID, firstname, |
1416 | lastname, activeGroupPowers, activeGroupName, | 1401 | lastname, activeGroupPowers, activeGroupName, |
1417 | activeGroupTitle); | 1402 | activeGroupTitle); |
1403 | |||
1404 | if (tellOthers) | ||
1405 | SendScenePresenceUpdate(agentID, activeGroupTitle); | ||
1406 | |||
1407 | ScenePresence sp = (ScenePresence)remoteClient.SceneAgent; | ||
1408 | if (sp != null) | ||
1409 | sp.Grouptitle = activeGroupTitle; | ||
1418 | } | 1410 | } |
1419 | 1411 | ||
1420 | #endregion | 1412 | #endregion |
@@ -1425,7 +1417,7 @@ namespace OpenSim.Groups | |||
1425 | { | 1417 | { |
1426 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1418 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
1427 | 1419 | ||
1428 | IClientAPI localClient = GetActiveClient(msgTo); | 1420 | IClientAPI localClient = GetActiveRootClient(msgTo); |
1429 | if (localClient != null) | 1421 | if (localClient != null) |
1430 | { | 1422 | { |
1431 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: MsgTo ({0}) is local, delivering directly", localClient.Name); | 1423 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: MsgTo ({0}) is local, delivering directly", localClient.Name); |
@@ -1463,5 +1455,4 @@ namespace OpenSim.Groups | |||
1463 | } | 1455 | } |
1464 | 1456 | ||
1465 | } | 1457 | } |
1466 | |||
1467 | } | 1458 | } |