aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs46
2 files changed, 48 insertions, 2 deletions
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
162 } 162 }
163 } 163 }
164 164
165 protected void InitModule(IConfigSource config) 165 protected virtual void InitModule(IConfigSource config)
166 { 166 {
167 IConfig friendsConfig = config.Configs["Friends"]; 167 IConfig friendsConfig = config.Configs["Friends"];
168 if (friendsConfig != null) 168 if (friendsConfig != null)
@@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
546 } 546 }
547 } 547 }
548 548
549 private void OnInstantMessage(IClientAPI client, GridInstantMessage im) 549 protected virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im)
550 { 550 {
551 if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) 551 if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered)
552 { 552 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index 9a6d277..3728b85 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
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private int m_levelHGFriends = 0;
54
53 IUserManagement m_uMan; 55 IUserManagement m_uMan;
54 public IUserManagement UserManagementModule 56 public IUserManagement UserManagementModule
55 { 57 {
@@ -87,6 +89,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
87 m_StatusNotifier = new HGStatusNotifier(this); 89 m_StatusNotifier = new HGStatusNotifier(this);
88 } 90 }
89 91
92 protected override void InitModule(IConfigSource config)
93 {
94 base.InitModule(config);
95
96 // Additionally to the base method
97 IConfig friendsConfig = config.Configs["HGFriendsModule"];
98 if (friendsConfig != null)
99 {
100 m_levelHGFriends = friendsConfig.GetInt("LevelHGFriends", 0);
101
102 // TODO: read in all config variables pertaining to
103 // HG friendship permissions
104 }
105 }
106
90 #endregion 107 #endregion
91 108
92 #region IFriendsSimConnector 109 #region IFriendsSimConnector
@@ -105,6 +122,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
105 122
106 #endregion 123 #endregion
107 124
125 protected override void OnInstantMessage(IClientAPI client, GridInstantMessage im)
126 {
127 if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered)
128 {
129 // we got a friendship offer
130 UUID principalID = new UUID(im.fromAgentID);
131 UUID friendID = new UUID(im.toAgentID);
132
133 // Check if friendID is foreigner and if principalID has the permission
134 // to request friendships with foreigners. If not, return immediately.
135 if (!UserManagementModule.IsLocalGridUser(friendID))
136 {
137 ScenePresence avatar = null;
138 ((Scene)client.Scene).TryGetScenePresence(principalID, out avatar);
139
140 if (avatar == null)
141 return;
142
143 if (avatar.UserLevel < m_levelHGFriends)
144 {
145 client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false);
146 return;
147 }
148 }
149 }
150
151 base.OnInstantMessage(client, im);
152 }
153
108 protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders) 154 protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders)
109 { 155 {
110 // Update the local cache. Yes, we need to do it right here 156 // Update the local cache. Yes, we need to do it right here