From f2ede8c7e09487436261b249ec093bfd01c3f971 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 11 Apr 2012 08:11:05 -0700 Subject: HGFriendsModule: add the scaffolding for supporting permissions pertaining to HG friendships. Snoopy take it from here. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 4 +-- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 30 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f64c161..fc6325d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -162,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } - protected void InitModule(IConfigSource config) + protected virtual void InitModule(IConfigSource config) { IConfig friendsConfig = config.Configs["Friends"]; if (friendsConfig != null) @@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } - private void OnInstantMessage(IClientAPI client, GridInstantMessage im) + protected virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im) { if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) { diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 9a6d277..ddb6a71 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -87,6 +87,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_StatusNotifier = new HGStatusNotifier(this); } + protected override void InitModule(IConfigSource config) + { + base.InitModule(config); + + // Additionally to the base method + IConfig friendsConfig = config.Configs["HGFriendsModule"]; + if (friendsConfig != null) + { + // TODO: read in all config variables pertaining to + // HG friendship permissions + } + } + #endregion #region IFriendsSimConnector @@ -105,6 +118,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends #endregion + protected override void OnInstantMessage(IClientAPI client, GridInstantMessage im) + { + if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) + { + // we got a friendship offer + UUID principalID = new UUID(im.fromAgentID); + UUID friendID = new UUID(im.toAgentID); + + // TODO: CHECK IF friendID is foreigner and if principalID has the permission + // to request these kinds of friendships. If not, return immediately. + // Maybe you want to let the client know too with + // client.SendAlertMessage + } + + base.OnInstantMessage(client, im); + } + protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List callingCardFolders) { // Update the local cache. Yes, we need to do it right here -- cgit v1.1 From 1f4d3d35822c5ad3dbdd5f363014f1bf9afebdc6 Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Wed, 11 Apr 2012 18:52:07 +0200 Subject: HGFriendsModule: Added optional user level based restriction to send friendship invitations to foreign users. --- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index ddb6a71..f8fbbbb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -50,6 +50,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private int m_levelHGFriends = 0; + IUserManagement m_uMan; public IUserManagement UserManagementModule { @@ -95,6 +97,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends IConfig friendsConfig = config.Configs["HGFriendsModule"]; if (friendsConfig != null) { + m_levelHGFriends = friendsConfig.GetInt("LevelHGFriends", 0); + // TODO: read in all config variables pertaining to // HG friendship permissions } @@ -126,10 +130,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UUID principalID = new UUID(im.fromAgentID); UUID friendID = new UUID(im.toAgentID); - // TODO: CHECK IF friendID is foreigner and if principalID has the permission - // to request these kinds of friendships. If not, return immediately. - // Maybe you want to let the client know too with - // client.SendAlertMessage + // Check if friendID is foreigner and if principalID has the permission + // to request friendships with foreigners. If not, return immediately. + if (!UserManagementModule.IsLocalGridUser(friendID)) + { + ScenePresence avatar = null; + client.Scene.TryGetScenePresence(principalID, out avatar); + + if (avatar == null) + return; + + if (avatar.UserLevel < m_levelHGFriends) + { + client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false); + return; + } + } } base.OnInstantMessage(client, im); -- cgit v1.1 From 8be14095fed0d1d9f448d51fede20d13231c02db Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Wed, 11 Apr 2012 18:56:28 +0200 Subject: HGFriendsModule: Type casts to fix compile error --- OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index f8fbbbb..3728b85 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -135,7 +135,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (!UserManagementModule.IsLocalGridUser(friendID)) { ScenePresence avatar = null; - client.Scene.TryGetScenePresence(principalID, out avatar); + ((Scene)client.Scene).TryGetScenePresence(principalID, out avatar); if (avatar == null) return; -- cgit v1.1