aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2010-02-26 17:33:08 -0800
committerDiva Canto2010-02-26 17:33:08 -0800
commitdc88dc2c3dde7c90e2e2fc094d91bb0915ff1c2f (patch)
tree818d6646bdf789c356cf1335a74322b78b485c57 /OpenSim/Region
parentAdd the client message handlers. The calling card handlers that are part of (diff)
downloadopensim-SC-dc88dc2c3dde7c90e2e2fc094d91bb0915ff1c2f.zip
opensim-SC-dc88dc2c3dde7c90e2e2fc094d91bb0915ff1c2f.tar.gz
opensim-SC-dc88dc2c3dde7c90e2e2fc094d91bb0915ff1c2f.tar.bz2
opensim-SC-dc88dc2c3dde7c90e2e2fc094d91bb0915ff1c2f.tar.xz
More flesh to FriendsModule. Still incomplete.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index f2ab174..7094213 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -45,6 +45,7 @@ using OpenSim.Framework.Servers.HttpServer;
45using log4net; 45using log4net;
46using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 46using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
47using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; 47using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
48using GridRegion = OpenSim.Services.Interfaces.GridRegion;
48 49
49namespace OpenSim.Region.CoreModules.Avatar.Friends 50namespace OpenSim.Region.CoreModules.Avatar.Friends
50{ 51{
@@ -94,6 +95,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
94 } 95 }
95 } 96 }
96 97
98 protected IFriendsService FriendsService
99 {
100 get
101 {
102 if (m_FriendsService == null)
103 {
104 if (m_Scenes.Count > 0)
105 m_FriendsService = m_Scenes[0].RequestModuleInterface<IFriendsService>();
106 }
107
108 return m_FriendsService;
109 }
110 }
111
112 protected IGridService GridService
113 {
114 get
115 {
116 return m_Scenes[0].GridService;
117 }
118 }
119
97 public FriendsModule() 120 public FriendsModule()
98 : base("POST", "/friends") 121 : base("POST", "/friends")
99 { 122 {
@@ -431,22 +454,66 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
431 454
432 private void OnInstantMessage(IClientAPI client, GridInstantMessage im) 455 private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
433 { 456 {
457 if (im.dialog == (byte)OpenMetaverse.InstantMessageDialog.FriendshipOffered)
458 {
459 // we got a friendship offer
460 UUID principalID = new UUID(im.fromAgentID);
461 UUID friendID = new UUID(im.toAgentID);
462
463 // this user wants to be friends with the other user
464 FriendsService.StoreFriend(principalID, friendID.ToString(), 1);
465
466 // Now let's ask the other user to be friends with this user
467 ForwardFriendshipOffer(principalID, friendID, im);
468 }
469 }
470
471 private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im)
472 {
473 IClientAPI friendClient = LocateClientObject(friendID);
474 if (friendClient != null)
475 {
476 // the prospective friend in this sim as root agent
477 friendClient.SendInstantMessage(im);
478 // we're done
479 return;
480 }
481
482 // The prospective friend is not here [as root]. Let's forward.
483 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
484 PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
485 if (friendSession != null)
486 {
487 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
488 // ...
489 // m_FriendsSimConnector.FriendshipOffered(region, agentID, friemdID, im.message);
490 }
434 } 491 }
435 492
436 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) 493 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
437 { 494 {
495 FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
496
497 // TODO: Notify the new friend
438 } 498 }
439 499
440 private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) 500 private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
441 { 501 {
502 // TODO: Notify the friend-wanna-be
442 } 503 }
443 504
444 private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) 505 private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID)
445 { 506 {
507 FriendsService.Delete(agentID, exfriendID.ToString());
508
509 // TODO: Notify the exfriend
446 } 510 }
447 511
448 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) 512 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
449 { 513 {
514 FriendsService.StoreFriend(requester, target.ToString(), rights);
515
516 // TODO: Notify the friend
450 } 517 }
451 } 518 }
452} 519}