diff options
author | John Hurliman | 2010-09-17 14:35:35 -0700 |
---|---|---|
committer | John Hurliman | 2010-09-17 14:35:35 -0700 |
commit | c08b6c28734b0e026aa25533333a66f845c48bca (patch) | |
tree | cf1eb99d801d1f65988cf64674189008eed2dc7c /OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |
parent | Applying the llParseString2List() patch from #5036 that Melanie claims was al... (diff) | |
parent | * Add a few more tests to help our meager code coverage %. (diff) | |
download | opensim-SC_OLD-c08b6c28734b0e026aa25533333a66f845c48bca.zip opensim-SC_OLD-c08b6c28734b0e026aa25533333a66f845c48bca.tar.gz opensim-SC_OLD-c08b6c28734b0e026aa25533333a66f845c48bca.tar.bz2 opensim-SC_OLD-c08b6c28734b0e026aa25533333a66f845c48bca.tar.xz |
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 | 103 |
1 files changed, 71 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 4e4eee9..7a21d5e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -317,7 +317,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
317 | continue; | 317 | continue; |
318 | 318 | ||
319 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, fromAgentID); | 319 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, fromAgentID); |
320 | PresenceInfo presence = PresenceService.GetAgent(fromAgentID); | 320 | |
321 | PresenceInfo presence = null; | ||
322 | PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid }); | ||
323 | if (presences != null && presences.Length > 0) | ||
324 | presence = presences[0]; | ||
325 | if (presence != null) | ||
326 | im.offline = 0; | ||
321 | 327 | ||
322 | im.fromAgentID = fromAgentID.Guid; | 328 | im.fromAgentID = fromAgentID.Guid; |
323 | im.fromAgentName = account.FirstName + " " + account.LastName; | 329 | im.fromAgentName = account.FirstName + " " + account.LastName; |
@@ -430,13 +436,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
430 | return; | 436 | return; |
431 | 437 | ||
432 | // The friend is not here [as root]. Let's forward. | 438 | // The friend is not here [as root]. Let's forward. |
433 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 439 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
434 | if (friendSession != null && friendSession.RegionID != UUID.Zero) // let's guard against sessions-gone-bad with the RegionID check | 440 | if (friendSessions != null && friendSessions.Length > 0) |
435 | { | 441 | { |
436 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 442 | PresenceInfo friendSession = null; |
437 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | 443 | foreach (PresenceInfo pinfo in friendSessions) |
438 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | 444 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad |
445 | { | ||
446 | friendSession = pinfo; | ||
447 | break; | ||
448 | } | ||
449 | |||
450 | if (friendSession != null) | ||
451 | { | ||
452 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
453 | //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); | ||
454 | m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); | ||
455 | } | ||
439 | } | 456 | } |
457 | |||
458 | // Friend is not online. Ignore. | ||
440 | } | 459 | } |
441 | else | 460 | else |
442 | { | 461 | { |
@@ -477,11 +496,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
477 | return; | 496 | return; |
478 | 497 | ||
479 | // The prospective friend is not here [as root]. Let's forward. | 498 | // The prospective friend is not here [as root]. Let's forward. |
480 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 499 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
481 | if (friendSession != null) | 500 | if (friendSessions != null && friendSessions.Length > 0) |
482 | { | 501 | { |
483 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 502 | PresenceInfo friendSession = friendSessions[0]; |
484 | m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); | 503 | if (friendSession != null) |
504 | { | ||
505 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
506 | m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); | ||
507 | } | ||
485 | } | 508 | } |
486 | // If the prospective friend is not online, he'll get the message upon login. | 509 | // If the prospective friend is not online, he'll get the message upon login. |
487 | } | 510 | } |
@@ -508,12 +531,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
508 | } | 531 | } |
509 | 532 | ||
510 | // The friend is not here | 533 | // The friend is not here |
511 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 534 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
512 | if (friendSession != null) | 535 | if (friendSessions != null && friendSessions.Length > 0) |
513 | { | 536 | { |
514 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 537 | PresenceInfo friendSession = friendSessions[0]; |
515 | m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); | 538 | if (friendSession != null) |
516 | client.SendAgentOnline(new UUID[] { friendID }); | 539 | { |
540 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
541 | m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); | ||
542 | client.SendAgentOnline(new UUID[] { friendID }); | ||
543 | } | ||
517 | } | 544 | } |
518 | } | 545 | } |
519 | 546 | ||
@@ -532,14 +559,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
532 | if (LocalFriendshipDenied(agentID, client.Name, friendID)) | 559 | if (LocalFriendshipDenied(agentID, client.Name, friendID)) |
533 | return; | 560 | return; |
534 | 561 | ||
535 | PresenceInfo friendSession = PresenceService.GetAgent(friendID); | 562 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
536 | if (friendSession != null) | 563 | if (friendSessions != null && friendSessions.Length > 0) |
537 | { | 564 | { |
538 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 565 | PresenceInfo friendSession = friendSessions[0]; |
539 | if (region != null) | 566 | if (friendSession != null) |
540 | m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); | 567 | { |
541 | else | 568 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
542 | m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID); | 569 | if (region != null) |
570 | m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); | ||
571 | else | ||
572 | m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID); | ||
573 | } | ||
543 | } | 574 | } |
544 | } | 575 | } |
545 | 576 | ||
@@ -561,11 +592,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
561 | if (LocalFriendshipTerminated(exfriendID)) | 592 | if (LocalFriendshipTerminated(exfriendID)) |
562 | return; | 593 | return; |
563 | 594 | ||
564 | PresenceInfo friendSession = PresenceService.GetAgent(exfriendID); | 595 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); |
565 | if (friendSession != null) | 596 | if (friendSessions != null && friendSessions.Length > 0) |
566 | { | 597 | { |
567 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 598 | PresenceInfo friendSession = friendSessions[0]; |
568 | m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); | 599 | if (friendSession != null) |
600 | { | ||
601 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | ||
602 | m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); | ||
603 | } | ||
569 | } | 604 | } |
570 | } | 605 | } |
571 | 606 | ||
@@ -604,13 +639,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
604 | if (LocalGrantRights(requester, target, myFlags, rights)) | 639 | if (LocalGrantRights(requester, target, myFlags, rights)) |
605 | return; | 640 | return; |
606 | 641 | ||
607 | PresenceInfo friendSession = PresenceService.GetAgent(target); | 642 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); |
608 | if (friendSession != null) | 643 | if (friendSessions != null && friendSessions.Length > 0) |
609 | { | 644 | { |
610 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); | 645 | PresenceInfo friendSession = friendSessions[0]; |
611 | // TODO: You might want to send the delta to save the lookup | 646 | if (friendSession != null) |
612 | // on the other end!! | 647 | { |
613 | m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); | 648 | GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); |
649 | // TODO: You might want to send the delta to save the lookup | ||
650 | // on the other end!! | ||
651 | m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); | ||
652 | } | ||
614 | } | 653 | } |
615 | } | 654 | } |
616 | } | 655 | } |