aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs78
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs54
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs29
3 files changed, 149 insertions, 12 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 0590716..8e32fcc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -214,6 +214,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
214 214
215 public virtual void RegionLoaded(Scene scene) 215 public virtual void RegionLoaded(Scene scene)
216 { 216 {
217 scene.AddCommand(
218 "Friends", this, "friends show cache",
219 "friends show cache [<first-name> <last-name>]",
220 "Show the friends cache for the given user",
221 HandleFriendsShowCacheCommand);
217 } 222 }
218 223
219 public void RemoveRegion(Scene scene) 224 public void RemoveRegion(Scene scene)
@@ -903,7 +908,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
903 /// Get friends from local cache only 908 /// Get friends from local cache only
904 /// </summary> 909 /// </summary>
905 /// <param name="agentID"></param> 910 /// <param name="agentID"></param>
906 /// <returns></returns> 911 /// <returns>
912 /// An empty array if the user has no friends or friends have not been cached.
913 /// </returns>
907 protected FriendInfo[] GetFriends(UUID agentID) 914 protected FriendInfo[] GetFriends(UUID agentID)
908 { 915 {
909 UserFriendData friendsData; 916 UserFriendData friendsData;
@@ -952,6 +959,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
952 } 959 }
953 } 960 }
954 961
962 /// <summary>
963 /// Are friends cached on this simulator for a particular user?
964 /// </summary>
965 /// <param name="userID"></param>
966 /// <returns></returns>
967 protected bool AreFriendsCached(UUID userID)
968 {
969 lock (m_Friends)
970 return m_Friends.ContainsKey(userID);
971 }
972
955 protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights) 973 protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights)
956 { 974 {
957 FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights); 975 FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights);
@@ -977,5 +995,61 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
977 } 995 }
978 996
979 #endregion 997 #endregion
998
999 protected void HandleFriendsShowCacheCommand(string module, string[] cmd)
1000 {
1001 if (cmd.Length != 5)
1002 {
1003 MainConsole.Instance.OutputFormat("Usage: friends show cache [<first-name> <last-name>]");
1004 return;
1005 }
1006
1007 string firstName = cmd[3];
1008 string lastName = cmd[4];
1009
1010 IUserManagement umModule = m_Scenes[0].RequestModuleInterface<IUserManagement>();
1011 UUID userId = umModule.GetUserIdByName(firstName, lastName);
1012
1013// UserAccount ua
1014// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
1015
1016 if (userId == UUID.Zero)
1017 {
1018 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
1019 return;
1020 }
1021
1022 if (!AreFriendsCached(userId))
1023 {
1024 MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
1025 return;
1026 }
1027
1028 MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName);
1029
1030 MainConsole.Instance.OutputFormat("UUID\n");
1031
1032 FriendInfo[] friends = GetFriends(userId);
1033
1034 foreach (FriendInfo friend in friends)
1035 {
1036// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
1037
1038// string friendFirstName, friendLastName;
1039//
1040// UserAccount friendUa
1041// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
1042
1043 UUID friendId;
1044 string friendName;
1045
1046 if (UUID.TryParse(friend.Friend, out friendId))
1047 friendName = umModule.GetUserName(friendId);
1048 else
1049 friendName = friend.Friend;
1050
1051 MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
1052 }
1053 }
980 } 1054 }
981} 1055} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 4a563f9..aaba7fd 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31 31
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Client;
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid; 36using OpenSim.Services.Connectors.Hypergrid;
@@ -177,9 +178,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
177 logout = success; // flag for later logout from this grid; this is an HG TP 178 logout = success; // flag for later logout from this grid; this is an HG TP
178 179
179 if (success && m_RestrictInventoryAccessAbroad) 180 if (success && m_RestrictInventoryAccessAbroad)
180 { 181 RemoveRootFolderContents(sp.ControllingClient);
181 // TODO tell the viewer to remove the root folder
182 }
183 182
184 return success; 183 return success;
185 } 184 }
@@ -304,13 +303,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
304 base.Fail(sp, finalDestination, logout); 303 base.Fail(sp, finalDestination, logout);
305 if (logout && m_RestrictInventoryAccessAbroad) 304 if (logout && m_RestrictInventoryAccessAbroad)
306 { 305 {
307 // Restore the user's inventory, because we removed it earlier on 306 RestoreRootFolderContents(sp.ControllingClient);
308 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(sp.UUID);
309 if (root != null)
310 {
311 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring");
312 sp.ControllingClient.SendBulkUpdateInventory(root);
313 }
314 } 307 }
315 } 308 }
316 309
@@ -368,6 +361,47 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
368 361
369 #endregion 362 #endregion
370 363
364 private void RemoveRootFolderContents(IClientAPI client)
365 {
366 // TODO tell the viewer to remove the root folder's content
367 if (client is IClientCore)
368 {
369 IClientCore core = (IClientCore)client;
370 IClientInventory inv;
371
372 if (core.TryGet<IClientInventory>(out inv))
373 {
374 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
375 if (root != null)
376 {
377 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory");
378 InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
379 UUID[] ids = new UUID[content.Folders.Count];
380 int i = 0;
381 foreach (InventoryFolderBase f in content.Folders)
382 ids[i++] = f.ID;
383 inv.SendRemoveInventoryFolders(ids);
384 ids = new UUID[content.Items.Count];
385 i = 0;
386 foreach (InventoryItemBase it in content.Items)
387 ids[i++] = it.ID;
388 inv.SendRemoveInventoryItems(ids);
389 }
390 }
391 }
392 }
393
394 private void RestoreRootFolderContents(IClientAPI client)
395 {
396 // Restore the user's inventory, because we removed it earlier on
397 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
398 if (root != null)
399 {
400 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory");
401 client.SendBulkUpdateInventory(root);
402 }
403 }
404
371 private GridRegion MakeRegion(AgentCircuitData aCircuit) 405 private GridRegion MakeRegion(AgentCircuitData aCircuit)
372 { 406 {
373 GridRegion region = new GridRegion(); 407 GridRegion region = new GridRegion();
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 0397478..f4ed67b 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -297,6 +297,35 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
297 297
298 #region IUserManagement 298 #region IUserManagement
299 299
300 public UUID GetUserIdByName(string name)
301 {
302 string[] parts = name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
303 if (parts.Length < 2)
304 throw new Exception("Name must have 2 components");
305
306 return GetUserIdByName(parts[0], parts[1]);
307 }
308
309 public UUID GetUserIdByName(string firstName, string lastName)
310 {
311 // TODO: Optimize for reverse lookup if this gets used by non-console commands.
312 lock (m_UserCache)
313 {
314 foreach (UserData user in m_UserCache.Values)
315 {
316 if (user.FirstName == firstName && user.LastName == lastName)
317 return user.Id;
318 }
319 }
320
321 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
322
323 if (account != null)
324 return account.PrincipalID;
325
326 return UUID.Zero;
327 }
328
300 public string GetUserName(UUID uuid) 329 public string GetUserName(UUID uuid)
301 { 330 {
302 string[] names = GetUserNames(uuid); 331 string[] names = GetUserNames(uuid);