aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2012-03-28 02:46:31 +0100
committerMelanie2012-03-28 02:46:31 +0100
commita43e804e59a255e86f5e38768f62323c46519978 (patch)
tree73688ef5c308ebf39a7c7eafc84b134ff774679d /OpenSim/Region
parentStart on Bulk inventory update via CAPS. Not functional yet. HG v2 (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-a43e804e59a255e86f5e38768f62323c46519978.zip
opensim-SC_OLD-a43e804e59a255e86f5e38768f62323c46519978.tar.gz
opensim-SC_OLD-a43e804e59a255e86f5e38768f62323c46519978.tar.bz2
opensim-SC_OLD-a43e804e59a255e86f5e38768f62323c46519978.tar.xz
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Region')
-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
-rw-r--r--OpenSim/Region/Framework/Interfaces/IUserManagement.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs15
5 files changed, 175 insertions, 16 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index be767c4..d1a1af0 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)
@@ -890,7 +895,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
890 /// Get friends from local cache only 895 /// Get friends from local cache only
891 /// </summary> 896 /// </summary>
892 /// <param name="agentID"></param> 897 /// <param name="agentID"></param>
893 /// <returns></returns> 898 /// <returns>
899 /// An empty array if the user has no friends or friends have not been cached.
900 /// </returns>
894 protected FriendInfo[] GetFriends(UUID agentID) 901 protected FriendInfo[] GetFriends(UUID agentID)
895 { 902 {
896 UserFriendData friendsData; 903 UserFriendData friendsData;
@@ -939,6 +946,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
939 } 946 }
940 } 947 }
941 948
949 /// <summary>
950 /// Are friends cached on this simulator for a particular user?
951 /// </summary>
952 /// <param name="userID"></param>
953 /// <returns></returns>
954 protected bool AreFriendsCached(UUID userID)
955 {
956 lock (m_Friends)
957 return m_Friends.ContainsKey(userID);
958 }
959
942 protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights) 960 protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights)
943 { 961 {
944 FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights); 962 FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights);
@@ -964,5 +982,61 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
964 } 982 }
965 983
966 #endregion 984 #endregion
985
986 protected void HandleFriendsShowCacheCommand(string module, string[] cmd)
987 {
988 if (cmd.Length != 5)
989 {
990 MainConsole.Instance.OutputFormat("Usage: friends show cache [<first-name> <last-name>]");
991 return;
992 }
993
994 string firstName = cmd[3];
995 string lastName = cmd[4];
996
997 IUserManagement umModule = m_Scenes[0].RequestModuleInterface<IUserManagement>();
998 UUID userId = umModule.GetUserIdByName(firstName, lastName);
999
1000// UserAccount ua
1001// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
1002
1003 if (userId == UUID.Zero)
1004 {
1005 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
1006 return;
1007 }
1008
1009 if (!AreFriendsCached(userId))
1010 {
1011 MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
1012 return;
1013 }
1014
1015 MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName);
1016
1017 MainConsole.Instance.OutputFormat("UUID\n");
1018
1019 FriendInfo[] friends = GetFriends(userId);
1020
1021 foreach (FriendInfo friend in friends)
1022 {
1023// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
1024
1025// string friendFirstName, friendLastName;
1026//
1027// UserAccount friendUa
1028// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
1029
1030 UUID friendId;
1031 string friendName;
1032
1033 if (UUID.TryParse(friend.Friend, out friendId))
1034 friendName = umModule.GetUserName(friendId);
1035 else
1036 friendName = friend.Friend;
1037
1038 MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
1039 }
1040 }
967 } 1041 }
968} 1042} \ 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 b277095..4cdf303 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 }
@@ -299,13 +298,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
299 base.Fail(sp, finalDestination, logout); 298 base.Fail(sp, finalDestination, logout);
300 if (logout && m_RestrictInventoryAccessAbroad) 299 if (logout && m_RestrictInventoryAccessAbroad)
301 { 300 {
302 // Restore the user's inventory, because we removed it earlier on 301 RestoreRootFolderContents(sp.ControllingClient);
303 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(sp.UUID);
304 if (root != null)
305 {
306 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring");
307 sp.ControllingClient.SendBulkUpdateInventory(root);
308 }
309 } 302 }
310 } 303 }
311 304
@@ -363,6 +356,47 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
363 356
364 #endregion 357 #endregion
365 358
359 private void RemoveRootFolderContents(IClientAPI client)
360 {
361 // TODO tell the viewer to remove the root folder's content
362 if (client is IClientCore)
363 {
364 IClientCore core = (IClientCore)client;
365 IClientInventory inv;
366
367 if (core.TryGet<IClientInventory>(out inv))
368 {
369 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
370 if (root != null)
371 {
372 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory");
373 InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
374 UUID[] ids = new UUID[content.Folders.Count];
375 int i = 0;
376 foreach (InventoryFolderBase f in content.Folders)
377 ids[i++] = f.ID;
378 inv.SendRemoveInventoryFolders(ids);
379 ids = new UUID[content.Items.Count];
380 i = 0;
381 foreach (InventoryItemBase it in content.Items)
382 ids[i++] = it.ID;
383 inv.SendRemoveInventoryItems(ids);
384 }
385 }
386 }
387 }
388
389 private void RestoreRootFolderContents(IClientAPI client)
390 {
391 // Restore the user's inventory, because we removed it earlier on
392 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
393 if (root != null)
394 {
395 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory");
396 client.SendBulkUpdateInventory(root);
397 }
398 }
399
366 private GridRegion MakeRegion(AgentCircuitData aCircuit) 400 private GridRegion MakeRegion(AgentCircuitData aCircuit)
367 { 401 {
368 GridRegion region = new GridRegion(); 402 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);
diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
index bfb8369..24cd069 100644
--- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
+++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
@@ -16,6 +16,21 @@ namespace OpenSim.Region.Framework.Interfaces
16 string GetUserServerURL(UUID uuid, string serverType); 16 string GetUserServerURL(UUID uuid, string serverType);
17 17
18 /// <summary> 18 /// <summary>
19 /// Get user ID by the given name.
20 /// </summary>
21 /// <param name="name"></param>
22 /// <returns>UUID.Zero if no user with that name is found or if the name is "Unknown User"</returns>
23 UUID GetUserIdByName(string name);
24
25 /// <summary>
26 /// Get user ID by the given name.
27 /// </summary>
28 /// <param name="firstName"></param>
29 /// <param name="lastName"></param>
30 /// <returns>UUID.Zero if no user with that name is found or if the name is "Unknown User"</returns>
31 UUID GetUserIdByName(string firstName, string lastName);
32
33 /// <summary>
19 /// Add a user. 34 /// Add a user.
20 /// </summary> 35 /// </summary>
21 /// <remarks> 36 /// <remarks>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0b31e0c..1f5cddd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2675,12 +2675,19 @@ namespace OpenSim.Region.Framework.Scenes
2675 // Cache the user's name 2675 // Cache the user's name
2676 CacheUserName(sp, aCircuit); 2676 CacheUserName(sp, aCircuit);
2677 2677
2678 // Let's send the Suitcase folder for incoming HG agents 2678 // Let's send the Suitcase or the real root folder folder for incoming HG agents
2679 // Visiting agents get their suitcase contents; incoming local users get their real root folder's content
2679 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) 2680 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
2680 { 2681 {
2681 m_log.DebugFormat("[SCENE]: Sending root folder to viewer..."); 2682 // HACK FOR NOW. JUST TESTING, SO KEEPING EVERYONE ELSE OUT OF THESE TESTS
2682 InventoryFolderBase suitcase = InventoryService.GetRootFolder(client.AgentId); 2683 IConfig config = m_config.Configs["HGEntityTransfer"];
2683 client.SendBulkUpdateInventory(suitcase); 2684 if (config != null && config.GetBoolean("RestrictInventoryAccessAbroad", false))
2685 {
2686 m_log.DebugFormat("[SCENE]: Sending root folder to viewer...");
2687 InventoryFolderBase root = InventoryService.GetRootFolder(client.AgentId);
2688 //InventoryCollection rootContents = InventoryService.GetFolderContent(client.AgentId, root.ID);
2689 client.SendBulkUpdateInventory(root);
2690 }
2684 } 2691 }
2685 2692
2686 EventManager.TriggerOnNewClient(client); 2693 EventManager.TriggerOnNewClient(client);