diff options
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index c266fe5..be767c4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -212,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
212 | scene.EventManager.OnClientLogin += OnClientLogin; | 212 | scene.EventManager.OnClientLogin += OnClientLogin; |
213 | } | 213 | } |
214 | 214 | ||
215 | public void RegionLoaded(Scene scene) | 215 | public virtual void RegionLoaded(Scene scene) |
216 | { | 216 | { |
217 | } | 217 | } |
218 | 218 | ||
@@ -550,7 +550,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
550 | UUID principalID = new UUID(im.fromAgentID); | 550 | UUID principalID = new UUID(im.fromAgentID); |
551 | UUID friendID = new UUID(im.toAgentID); | 551 | UUID friendID = new UUID(im.toAgentID); |
552 | 552 | ||
553 | m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2}", principalID, im.fromAgentName, friendID); | 553 | m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2} ({3})", principalID, client.FirstName + client.LastName, friendID, im.fromAgentName); |
554 | |||
555 | // Check that the friendship doesn't exist yet | ||
556 | FriendInfo[] finfos = GetFriends(principalID); | ||
557 | if (finfos != null) | ||
558 | { | ||
559 | FriendInfo f = GetFriend(finfos, friendID); | ||
560 | if (f != null) | ||
561 | { | ||
562 | client.SendAgentAlertMessage("This person is already your friend. Please delete it first if you want to reestablish the friendship.", false); | ||
563 | return; | ||
564 | } | ||
565 | } | ||
554 | 566 | ||
555 | // This user wants to be friends with the other user. | 567 | // This user wants to be friends with the other user. |
556 | // Let's add the relation backwards, in case the other is not online | 568 | // Let's add the relation backwards, in case the other is not online |
@@ -561,7 +573,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
561 | } | 573 | } |
562 | } | 574 | } |
563 | 575 | ||
564 | private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) | 576 | protected virtual bool ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) |
565 | { | 577 | { |
566 | // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID) | 578 | // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID) |
567 | // We stick this agent's ID as imSession, so that it's directly available on the receiving end | 579 | // We stick this agent's ID as imSession, so that it's directly available on the receiving end |
@@ -570,7 +582,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
570 | 582 | ||
571 | // Try the local sim | 583 | // Try the local sim |
572 | if (LocalFriendshipOffered(friendID, im)) | 584 | if (LocalFriendshipOffered(friendID, im)) |
573 | return; | 585 | return true; |
574 | 586 | ||
575 | // The prospective friend is not here [as root]. Let's forward. | 587 | // The prospective friend is not here [as root]. Let's forward. |
576 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); | 588 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
@@ -581,9 +593,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
581 | { | 593 | { |
582 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 594 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
583 | m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); | 595 | m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); |
596 | return true; | ||
584 | } | 597 | } |
585 | } | 598 | } |
586 | // If the prospective friend is not online, he'll get the message upon login. | 599 | // If the prospective friend is not online, he'll get the message upon login. |
600 | return false; | ||
587 | } | 601 | } |
588 | 602 | ||
589 | protected virtual string GetFriendshipRequesterName(UUID agentID) | 603 | protected virtual string GetFriendshipRequesterName(UUID agentID) |
@@ -592,7 +606,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
592 | return (account == null) ? "Unknown" : account.FirstName + " " + account.LastName; | 606 | return (account == null) ? "Unknown" : account.FirstName + " " + account.LastName; |
593 | } | 607 | } |
594 | 608 | ||
595 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | 609 | protected virtual void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) |
596 | { | 610 | { |
597 | m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID); | 611 | m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID); |
598 | 612 | ||
@@ -603,7 +617,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
603 | { | 617 | { |
604 | StoreFriendships(client.AgentId, friendID); | 618 | StoreFriendships(client.AgentId, friendID); |
605 | 619 | ||
606 | // Update the local cache | 620 | // Update the local cache. |
607 | RecacheFriends(client); | 621 | RecacheFriends(client); |
608 | 622 | ||
609 | // | 623 | // |
@@ -756,7 +770,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
756 | 770 | ||
757 | #region Local | 771 | #region Local |
758 | 772 | ||
759 | public bool LocalFriendshipOffered(UUID toID, GridInstantMessage im) | 773 | public virtual bool LocalFriendshipOffered(UUID toID, GridInstantMessage im) |
760 | { | 774 | { |
761 | IClientAPI friendClient = LocateClientObject(toID); | 775 | IClientAPI friendClient = LocateClientObject(toID); |
762 | if (friendClient != null) | 776 | if (friendClient != null) |
@@ -912,7 +926,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
912 | return FriendsService.GetFriends(client.AgentId); | 926 | return FriendsService.GetFriends(client.AgentId); |
913 | } | 927 | } |
914 | 928 | ||
915 | private void RecacheFriends(IClientAPI client) | 929 | protected void RecacheFriends(IClientAPI client) |
916 | { | 930 | { |
917 | // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event | 931 | // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event |
918 | // is on the critical path for transferring an avatar from one region to another. | 932 | // is on the critical path for transferring an avatar from one region to another. |