From 465d1095dd0dd5c4c5231a81bb69e46a21f290fb Mon Sep 17 00:00:00 2001 From: dahlia Date: Tue, 18 Aug 2009 17:06:14 -0700 Subject: Added new OpenSim.ini setting: "client_throttle_max_bps" which overrides user's viewer network throttle settings --- .../Region/ClientStack/LindenUDP/LLPacketQueue.cs | 36 +++++++++++++--------- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 11 +++++-- bin/OpenSim.ini.example | 3 ++ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index bf0b06d..798c1e7 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs @@ -128,28 +128,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Store the throttle multiplier for posterity. throttleMultiplier = userSettings.ClientThrottleMultipler; + + int throttleMaxBPS = 1500000; + if (userSettings.TotalThrottleSettings != null) + throttleMaxBPS = userSettings.TotalThrottleSettings.Max; + // Set up the throttle classes (min, max, current) in bits per second - ResendThrottle = new LLPacketThrottle(5000, 100000, 16000, userSettings.ClientThrottleMultipler); - LandThrottle = new LLPacketThrottle(1000, 100000, 2000, userSettings.ClientThrottleMultipler); - WindThrottle = new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler); - CloudThrottle = new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler); - TaskThrottle = new LLPacketThrottle(1000, 800000, 3000, userSettings.ClientThrottleMultipler); - AssetThrottle = new LLPacketThrottle(1000, 800000, 1000, userSettings.ClientThrottleMultipler); - TextureThrottle = new LLPacketThrottle(1000, 800000, 4000, userSettings.ClientThrottleMultipler); - - // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second. + ResendThrottle = new LLPacketThrottle(5000, throttleMaxBPS / 15, 16000, userSettings.ClientThrottleMultipler); + LandThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 15, 2000, userSettings.ClientThrottleMultipler); + WindThrottle = new LLPacketThrottle(0, throttleMaxBPS / 15, 0, userSettings.ClientThrottleMultipler); + CloudThrottle = new LLPacketThrottle(0, throttleMaxBPS / 15, 0, userSettings.ClientThrottleMultipler); + TaskThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 3000, userSettings.ClientThrottleMultipler); + AssetThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 1000, userSettings.ClientThrottleMultipler); + TextureThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 4000, userSettings.ClientThrottleMultipler); + + + // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second. + + ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings; if (null == totalThrottleSettings) - { - totalThrottleSettings = new ThrottleSettings(0, 1500000, 28000); + { + totalThrottleSettings = new ThrottleSettings(0, throttleMaxBPS, 28000); } - - TotalThrottle + + TotalThrottle = new LLPacketThrottle( totalThrottleSettings.Min, totalThrottleSettings.Max, totalThrottleSettings.Current, userSettings.ClientThrottleMultipler); - throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor)); + throttleTimer = new Timer((int)(throttletimems / throttleTimeDivisor)); throttleTimer.Elapsed += ThrottleTimerElapsed; throttleTimer.Start(); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 5184e35..9ee8df5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -152,11 +152,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP ClientStackUserSettings userSettings = new ClientStackUserSettings(); IConfig config = configSource.Configs["ClientStack.LindenUDP"]; - + if (config != null) { + if (config.Contains("client_throttle_max_bps")) + { + int maxBPS = config.GetInt("client_throttle_max_bps", 1500000); + userSettings.TotalThrottleSettings = new ThrottleSettings(0, maxBPS, + maxBPS > 28000 ? maxBPS : 28000); + } + if (config.Contains("client_throttle_multiplier")) - userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier"); + userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier"); if (config.Contains("client_socket_rcvbuf_size")) m_clientSocketReceiveBuffer = config.GetInt("client_socket_rcvbuf_size"); } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 9a17c58..cff5d19 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -374,6 +374,9 @@ ; ; client_socket_rcvbuf_size = 8388608 + ; Maximum bits per second to send to any single client. This will override the user's viewer preference settings. + + ; client_throttle_max_bps = 1500000 [Chat] ; Controls whether the chat module is enabled. Default is true. -- cgit v1.1 From 32cc00ec7b26290e4b65e326164510ad6fc831d3 Mon Sep 17 00:00:00 2001 From: Jeff Lee Date: Tue, 18 Aug 2009 00:41:38 -0400 Subject: osGetLinkPrimitiveParams fix --- .../Shared/Api/Implementation/LSL_Api.cs | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2dbbf70..4e665e9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1978,6 +1978,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Rotation(q.X, q.Y, q.Z, q.W); } + private LSL_Rotation GetPartRot( SceneObjectPart part ) + { + Quaternion q; + if (part.LinkNum == 0 || part.LinkNum == 1) // unlinked or root prim + { + if (part.ParentGroup.RootPart.AttachmentPoint != 0) + { + ScenePresence avatar = World.GetScenePresence(part.AttachedAvatar); + if (avatar != null) + if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) + q = avatar.CameraRotation; // Mouselook + else + q = avatar.Rotation; // Currently infrequently updated so may be inaccurate + else + q = part.ParentGroup.GroupRotation; // Likely never get here but just in case + } + else + q = part.ParentGroup.GroupRotation; // just the group rotation + return new LSL_Rotation(q.X, q.Y, q.Z, q.W); + } + q = part.GetWorldRotation(); + return new LSL_Rotation(q.X, q.Y, q.Z, q.W); + } + public LSL_Rotation llGetLocalRot() { m_host.AddScriptLPS(1); @@ -7299,7 +7323,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_ROTATION: - res.Add(llGetRot()); + res.Add(GetPartRot(part)); break; case (int)ScriptBaseClass.PRIM_TYPE: -- cgit v1.1 From 99c7a43ffdb9c3b4dee984f7cd788742c6ee3e53 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Aug 2009 04:39:02 +0100 Subject: Add rest console support to the user server. Will ask new questions at startup. To use, run it normally once, answering the questions, then run again with -console=rest. Also now supports -console=basic for a console that reads stdin --- OpenSim/Framework/UserConfig.cs | 14 +++++++++++ OpenSim/Grid/UserServer/Main.cs | 39 ++++++++++++++++++++++++++++++- OpenSim/Server/Base/ServicesServerBase.cs | 28 ++++++++++++++++++++++ prebuild.xml | 1 + 4 files changed, 81 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index 31838ad..b9e3665 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs @@ -46,6 +46,8 @@ namespace OpenSim.Framework public bool HttpSSL = ConfigSettings.DefaultUserServerHttpSSL; public uint DefaultUserLevel = 0; public string LibraryXmlfile = ""; + public string ConsoleUser = String.Empty; + public string ConsolePass = String.Empty; private Uri m_inventoryUrl; @@ -155,6 +157,12 @@ namespace OpenSim.Framework m_configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Minimum Level a user should have to login [0 default]", "0", false); + m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access user name [Default: disabled]", "0", false); + + m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access password [Default: disabled]", "0", false); + } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -209,6 +217,12 @@ namespace OpenSim.Framework case "library_location": LibraryXmlfile = (string)configuration_result; break; + case "console_user": + ConsoleUser = (string)configuration_result; + break; + case "console_pass": + ConsolePass = (string)configuration_result; + break; } return true; diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 86c2abb..f47a96e 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -43,6 +43,7 @@ using OpenSim.Framework.Statistics; using OpenSim.Grid.Communications.OGS1; using OpenSim.Grid.Framework; using OpenSim.Grid.UserServer.Modules; +using Nini.Config; namespace OpenSim.Grid.UserServer { @@ -73,8 +74,22 @@ namespace OpenSim.Grid.UserServer protected AvatarCreationModule m_appearanceModule; + protected static string m_consoleType = "local"; + protected static IConfigSource m_config = null; + public static void Main(string[] args) { + ArgvConfigSource argvSource = new ArgvConfigSource(args); + argvSource.AddSwitch("Startup", "console", "c"); + + IConfig startupConfig = argvSource.Configs["Startup"]; + if (startupConfig != null) + { + m_consoleType = startupConfig.GetString("console", "local"); + } + + m_config = argvSource; + XmlConfigurator.Configure(); m_log.Info("Launching UserServer..."); @@ -87,7 +102,18 @@ namespace OpenSim.Grid.UserServer public OpenUser_Main() { - m_console = new LocalConsole("User"); + switch (m_consoleType) + { + case "rest": + m_console = new RemoteConsole("User"); + break; + case "basic": + m_console = new CommandConsole("User"); + break; + default: + m_console = new LocalConsole("User"); + break; + } MainConsole.Instance = m_console; } @@ -129,6 +155,17 @@ namespace OpenSim.Grid.UserServer m_httpServer = new BaseHttpServer(Cfg.HttpPort); + if (m_console is RemoteConsole) + { + System.Console.WriteLine("Initialized REST console"); + RemoteConsole c = (RemoteConsole)m_console; + c.SetServer(m_httpServer); + IConfig netConfig = m_config.AddConfig("Network"); + netConfig.Set("ConsoleUser", Cfg.ConsoleUser); + netConfig.Set("ConsolePass", Cfg.ConsolePass); + c.ReadConfig(m_config); + } + RegisterInterface(m_console); RegisterInterface(Cfg); diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 619c2d1..1d9eb0d 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -65,6 +65,10 @@ namespace OpenSim.Server.Base // private bool m_Running = true; + // PID file + // + private string m_pidFile = String.Empty; + // Handle all the automagical stuff // public ServicesServerBase(string prompt, string[] args) @@ -211,6 +215,11 @@ namespace OpenSim.Server.Base } } + if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) + { + CreatePIDFile(startupConfig.GetString("PIDFile")); + } + // Register the quit command // MainConsole.Instance.Commands.AddCommand("base", false, "quit", @@ -230,6 +239,8 @@ namespace OpenSim.Server.Base MainConsole.Instance.Prompt(); } + if (m_pidFile != String.Empty) + File.Delete(m_pidFile); return 0; } @@ -246,5 +257,22 @@ namespace OpenSim.Server.Base protected virtual void Initialise() { } + + protected void CreatePIDFile(string path) + { + try + { + string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); + FileStream fs = File.Create(path); + System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + Byte[] buf = enc.GetBytes(pidstring); + fs.Write(buf, 0, buf.Length); + fs.Close(); + m_pidFile = path; + } + catch (Exception) + { + } + } } } diff --git a/prebuild.xml b/prebuild.xml index 5e44169..4f110c4 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1178,6 +1178,7 @@ + -- cgit v1.1 From dd0234f5005127c03760c2b9862ed1672f4a2e91 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Aug 2009 05:15:25 +0100 Subject: Graft the REST console onto the grid server. Same procedure as with the user server. --- OpenSim/Framework/GridConfig.cs | 16 +++++++++++++++- OpenSim/Grid/GridServer/GridServerBase.cs | 27 +++++++++++++++++++++++++-- OpenSim/Grid/GridServer/Program.cs | 12 ++++++++++++ OpenSim/Grid/UserServer/Main.cs | 1 - prebuild.xml | 1 + 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/GridConfig.cs b/OpenSim/Framework/GridConfig.cs index a3c1032..87fd3f0 100644 --- a/OpenSim/Framework/GridConfig.cs +++ b/OpenSim/Framework/GridConfig.cs @@ -45,6 +45,8 @@ namespace OpenSim.Framework public string SimSendKey = String.Empty; public string UserRecvKey = String.Empty; public string UserSendKey = String.Empty; + public string ConsoleUser = String.Empty; + public string ConsolePass = String.Empty; public GridConfig(string description, string filename) { @@ -95,6 +97,12 @@ namespace OpenSim.Framework "Allow regions to register immediately upon grid server startup? true/false", "True", false); + m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access user name [Default: disabled]", "0", false); + + m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access password [Default: disabled]", "0", false); + } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -140,9 +148,15 @@ namespace OpenSim.Framework case "allow_region_registration": AllowRegionRegistration = (bool)configuration_result; break; + case "console_user": + ConsoleUser = (string)configuration_result; + break; + case "console_pass": + ConsolePass = (string)configuration_result; + break; } return true; } } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index c41a728..e3ad52a 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -31,6 +31,7 @@ using System.IO; using System.Reflection; using System.Timers; using log4net; +using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -46,6 +47,8 @@ namespace OpenSim.Grid.GridServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected GridConfig m_config; + public string m_consoleType = "local"; + public IConfigSource m_configSource = null; public GridConfig Config { @@ -71,16 +74,36 @@ namespace OpenSim.Grid.GridServer public GridServerBase() { - m_console = new LocalConsole("Grid"); - MainConsole.Instance = m_console; } protected override void StartupSpecific() { + switch (m_consoleType) + { + case "rest": + m_console = new RemoteConsole("Grid"); + break; + case "basic": + m_console = new CommandConsole("Grid"); + break; + default: + m_console = new LocalConsole("Grid"); + break; + } + MainConsole.Instance = m_console; m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); m_log.Info("[GRID]: Starting HTTP process"); m_httpServer = new BaseHttpServer(m_config.HttpPort); + if (m_console is RemoteConsole) + { + RemoteConsole c = (RemoteConsole)m_console; + c.SetServer(m_httpServer); + IConfig netConfig = m_configSource.AddConfig("Network"); + netConfig.Set("ConsoleUser", m_config.ConsoleUser); + netConfig.Set("ConsolePass", m_config.ConsolePass); + c.ReadConfig(m_configSource); + } LoadPlugins(); diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Grid/GridServer/Program.cs index 9618b85..c7ba897 100644 --- a/OpenSim/Grid/GridServer/Program.cs +++ b/OpenSim/Grid/GridServer/Program.cs @@ -26,6 +26,7 @@ */ using log4net.Config; +using Nini.Config; namespace OpenSim.Grid.GridServer { @@ -33,10 +34,21 @@ namespace OpenSim.Grid.GridServer { public static void Main(string[] args) { + ArgvConfigSource argvSource = new ArgvConfigSource(args); + argvSource.AddSwitch("Startup", "console", "c"); + XmlConfigurator.Configure(); GridServerBase app = new GridServerBase(); + IConfig startupConfig = argvSource.Configs["Startup"]; + if (startupConfig != null) + { + app.m_consoleType = startupConfig.GetString("console", "local"); + } + + app.m_configSource = argvSource; + // if (args.Length > 0 && args[0] == "-setuponly") // { // app.Config(); diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index f47a96e..1ee53ef 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -157,7 +157,6 @@ namespace OpenSim.Grid.UserServer if (m_console is RemoteConsole) { - System.Console.WriteLine("Initialized REST console"); RemoteConsole c = (RemoteConsole)m_console; c.SetServer(m_httpServer); IConfig netConfig = m_config.AddConfig("Network"); diff --git a/prebuild.xml b/prebuild.xml index 4f110c4..216a02e 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -911,6 +911,7 @@ + -- cgit v1.1 From 2111c66f89033b3426ceedba6a3ec6ed8fb3363f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Aug 2009 05:40:23 +0100 Subject: Graft the REST console onto the message server as well. What a dirty hack! Works the same as the others. --- OpenSim/Framework/MessageServerConfig.cs | 16 ++++++- OpenSim/Grid/MessagingServer/Main.cs | 79 ++++++++++++++++++++++++-------- prebuild.xml | 1 + 3 files changed, 75 insertions(+), 21 deletions(-) diff --git a/OpenSim/Framework/MessageServerConfig.cs b/OpenSim/Framework/MessageServerConfig.cs index d0ceebc..61e5ea7 100644 --- a/OpenSim/Framework/MessageServerConfig.cs +++ b/OpenSim/Framework/MessageServerConfig.cs @@ -46,6 +46,8 @@ namespace OpenSim.Framework public string UserRecvKey = String.Empty; public string UserSendKey = String.Empty; public string UserServerURL = String.Empty; + public string ConsoleUser = String.Empty; + public string ConsolePass = String.Empty; public MessageServerConfig(string description, string filename) { @@ -88,6 +90,12 @@ namespace OpenSim.Framework "Use SSL? true/false", ConfigSettings.DefaultMessageServerHttpSSL.ToString(), false); m_configMember.addConfigurationOption("published_ip", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "My Published IP Address", "127.0.0.1", false); + m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access user name [Default: disabled]", "0", false); + + m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Remote console access password [Default: disabled]", "0", false); + } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -130,9 +138,15 @@ namespace OpenSim.Framework case "published_ip": MessageServerIP = (string) configuration_result; break; + case "console_user": + ConsoleUser = (string)configuration_result; + break; + case "console_pass": + ConsolePass = (string)configuration_result; + break; } return true; } } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index dcefeea..654e770 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using log4net; +using Nini.Config; using log4net.Config; using OpenSim.Framework; using OpenSim.Framework.Console; @@ -56,8 +57,22 @@ namespace OpenSim.Grid.MessagingServer // private UUID m_lastCreatedUser = UUID.Random(); + protected static string m_consoleType = "local"; + protected static IConfigSource m_config = null; + public static void Main(string[] args) { + ArgvConfigSource argvSource = new ArgvConfigSource(args); + argvSource.AddSwitch("Startup", "console", "c"); + + IConfig startupConfig = argvSource.Configs["Startup"]; + if (startupConfig != null) + { + m_consoleType = startupConfig.GetString("console", "local"); + } + + m_config = argvSource; + XmlConfigurator.Configure(); m_log.Info("[SERVER]: Launching MessagingServer..."); @@ -70,7 +85,18 @@ namespace OpenSim.Grid.MessagingServer public OpenMessage_Main() { - m_console = new LocalConsole("Messaging"); + switch (m_consoleType) + { + case "rest": + m_console = new RemoteConsole("Messaging"); + break; + case "basic": + m_console = new CommandConsole("Messaging"); + break; + default: + m_console = new LocalConsole("Messaging"); + break; + } MainConsole.Instance = m_console; } @@ -88,20 +114,33 @@ namespace OpenSim.Grid.MessagingServer { if (m_userServerModule.registerWithUserServer()) { - m_log.Info("[SERVER]: Starting HTTP process"); - m_httpServer = new BaseHttpServer(Cfg.HttpPort); - - m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); - m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); - m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); - m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); - m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); - m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); - - m_httpServer.AddXmlRPCHandler("region_startup", m_regionModule.RegionStartup); - m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown); - - m_httpServer.Start(); + if (m_httpServer == null) + { + m_log.Info("[SERVER]: Starting HTTP process"); + m_httpServer = new BaseHttpServer(Cfg.HttpPort); + + if (m_console is RemoteConsole) + { + RemoteConsole c = (RemoteConsole)m_console; + c.SetServer(m_httpServer); + IConfig netConfig = m_config.AddConfig("Network"); + netConfig.Set("ConsoleUser", Cfg.ConsoleUser); + netConfig.Set("ConsolePass", Cfg.ConsolePass); + c.ReadConfig(m_config); + } + + m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); + m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); + m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); + m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); + m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); + m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); + + m_httpServer.AddXmlRPCHandler("region_startup", m_regionModule.RegionStartup); + m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown); + + m_httpServer.Start(); + } m_log.Info("[SERVER]: Userserver registration was successful"); } else @@ -114,12 +153,12 @@ namespace OpenSim.Grid.MessagingServer private void deregisterFromUserServer() { m_userServerModule.deregisterWithUserServer(); - if (m_httpServer != null) - { +// if (m_httpServer != null) +// { // try a completely fresh registration, with fresh handlers, too - m_httpServer.Stop(); - m_httpServer = null; - } +// m_httpServer.Stop(); +// m_httpServer = null; +// } m_console.Output("[SERVER]: Deregistered from userserver."); } diff --git a/prebuild.xml b/prebuild.xml index 216a02e..ebe5c62 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1281,6 +1281,7 @@ + -- cgit v1.1 From 124f66bfc25984a01491b8447fa97bea2633281c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 18 Aug 2009 22:17:47 -0700 Subject: jhurliman's patch in http://opensimulator.org/mantis/view.php?id=4024 --- OpenSim/Framework/InventoryFolderBase.cs | 6 ++++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 4 +-- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 3 +- .../CoreModules/Avatar/Gestures/GesturesModule.cs | 6 ++-- .../Inventory/Transfer/InventoryTransferModule.cs | 13 ++++---- .../Inventory/HGInventoryBroker.cs | 3 +- .../World/Permissions/PermissionsModule.cs | 9 ++++-- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 35 ++++++++++++++-------- .../Framework/Scenes/Scene.PacketHandlers.cs | 3 +- 9 files changed, 52 insertions(+), 30 deletions(-) diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs index 05f11a4..1869d48 100644 --- a/OpenSim/Framework/InventoryFolderBase.cs +++ b/OpenSim/Framework/InventoryFolderBase.cs @@ -78,6 +78,12 @@ namespace OpenSim.Framework ID = id; } + public InventoryFolderBase(UUID id, UUID owner) + { + ID = id; + Owner = owner; + } + public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version) { ID = id; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 06bea3d..16ce9e0 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -6633,9 +6633,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else // Agent { - //InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(itemID); IInventoryService invService = m_scene.RequestModuleInterface(); - InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId); + assetRequestItem = invService.GetItem(assetRequestItem); if (assetRequestItem == null) { assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 582beee..35c59aa 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -130,7 +130,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } else { - InventoryItemBase baseItem = invService.GetItem(new InventoryItemBase(appearance.Wearables[i].ItemID)); + InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID); + baseItem = invService.GetItem(baseItem); if (baseItem != null) { diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs index a68db1b..ff12361 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs @@ -65,7 +65,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gestures { IInventoryService invService = m_scene.InventoryService; - InventoryItemBase item = invService.GetItem(new InventoryItemBase(gestureId)); + InventoryItemBase item = new InventoryItemBase(gestureId, client.AgentId); + item = invService.GetItem(item); if (item != null) { item.Flags = 1; @@ -80,7 +81,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gestures { IInventoryService invService = m_scene.InventoryService; - InventoryItemBase item = invService.GetItem(new InventoryItemBase(gestureId)); + InventoryItemBase item = new InventoryItemBase(gestureId, client.AgentId); + item = invService.GetItem(item); if (item != null) { item.Flags = 0; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 5315c11..3a65336 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -257,8 +257,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip - - InventoryItemBase item = invService.GetItem(new InventoryItemBase(inventoryEntityID)); + + InventoryItemBase item = new InventoryItemBase(inventoryEntityID, client.AgentId); + item = invService.GetItem(item); InventoryFolderBase folder = null; if (item != null && trashFolder != null) @@ -271,7 +272,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer } else { - folder = invService.GetFolder(new InventoryFolderBase(inventoryEntityID)); + folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); + folder = invService.GetFolder(folder); if (folder != null & trashFolder != null) { @@ -451,10 +453,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer else { UUID itemID = new UUID(msg.binaryBucket, 1); - InventoryItemBase item = new InventoryItemBase(); - - item.ID = itemID; - item.Owner = user.ControllingClient.AgentId; + InventoryItemBase item = new InventoryItemBase(itemID, user.ControllingClient.AgentId); // Fetch from service // diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index dd451ef..492598e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -483,12 +483,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); string uri = m_LocalGridInventoryURI.TrimEnd('/'); - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, comparing {0} to {1}.", userInventoryServerURI, uri); - if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) { return true; } + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user is foreign({0} - {1})", userInventoryServerURI, uri); return false; } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 9c71b41..f360577 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -966,7 +966,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (objectID == UUID.Zero) // User inventory { IInventoryService invService = m_scene.InventoryService; - InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(notecard)); + InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); + assetRequestItem = invService.GetItem(assetRequestItem); if (assetRequestItem == null) // Library item { assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); @@ -1385,7 +1386,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (objectID == UUID.Zero) // User inventory { IInventoryService invService = m_scene.InventoryService; - InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(script)); + InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); + assetRequestItem = invService.GetItem(assetRequestItem); if (assetRequestItem == null) // Library item { assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); @@ -1479,7 +1481,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (objectID == UUID.Zero) // User inventory { IInventoryService invService = m_scene.InventoryService; - InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(notecard)); + InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); + assetRequestItem = invService.GetItem(assetRequestItem); if (assetRequestItem == null) // Library item { assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 46777e1..48c7f4e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -140,7 +140,8 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -315,7 +316,8 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, UUID itemID, InventoryItemBase itemUpd) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -408,7 +410,8 @@ namespace OpenSim.Region.Framework.Scenes { Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemId)); + InventoryItemBase item = new InventoryItemBase(itemId, senderId); + item = InventoryService.GetItem(item); if ((item != null) && (item.Owner == senderId)) { @@ -558,7 +561,8 @@ namespace OpenSim.Region.Framework.Scenes if (item == null) { - item = InventoryService.GetItem(new InventoryItemBase(oldItemID)); + item = new InventoryItemBase(oldItemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item == null) { @@ -636,7 +640,8 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId); - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -1224,7 +1229,8 @@ namespace OpenSim.Region.Framework.Scenes UUID copyID = UUID.Random(); if (itemID != UUID.Zero) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); // Try library if (null == item) @@ -1287,7 +1293,8 @@ namespace OpenSim.Region.Framework.Scenes if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); // Try library // XXX clumsy, possibly should be one call @@ -1672,7 +1679,7 @@ namespace OpenSim.Region.Framework.Scenes if (DeRezAction.SaveToExistingUserInventoryItem == action) { - item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID); + item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); item = InventoryService.GetItem(item); //item = userInfo.RootFolder.FindItem( @@ -1834,7 +1841,8 @@ namespace OpenSim.Region.Framework.Scenes string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -1984,7 +1992,8 @@ namespace OpenSim.Region.Framework.Scenes BypassRayCast, bRayEndIsIntersection,true,scale, false); // Rez object - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -2309,7 +2318,8 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence; if (TryGetAvatar(remoteClient.AgentId, out presence)) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID, remoteClient.AgentId)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); IAvatarFactory ava = RequestModuleInterface(); @@ -2360,7 +2370,8 @@ namespace OpenSim.Region.Framework.Scenes if (TryGetAvatar(remoteClient.AgentId, out presence)) { // XXYY!! - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); IAvatarFactory ava = RequestModuleInterface(); if (ava != null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index fde922f..1bbca49 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -404,7 +404,8 @@ namespace OpenSim.Region.Framework.Scenes return; } - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { -- cgit v1.1 From e5f33e75055a8f83cf4e11a6120774cb90dbc3be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 18 Aug 2009 22:36:03 -0700 Subject: GetFolderItems implemented. It's not being called, but it might. --- .../ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | 11 +++++++++-- .../Inventory/RemoteInventoryServiceConnector.cs | 3 ++- .../Connectors/Inventory/HGInventoryServiceConnector.cs | 13 +++++++++++++ .../Inventory/ISessionAuthInventoryService.cs | 7 +++++++ .../Connectors/Inventory/InventoryServiceConnector.cs | 17 +++++++++++++++++ 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 492598e..3649097 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -290,7 +290,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public override List GetFolderItems(UUID userID, UUID folderID) { - return new List(); + if (IsLocalGridUser(userID)) + return m_GridService.GetFolderItems(userID, folderID); + else + { + UUID sessionID = GetSessionID(userID); + string uri = GetUserInventoryURI(userID) + "/" + userID; + return m_HGService.GetFolderItems(uri, folderID, sessionID); + } } public override bool AddFolder(InventoryFolderBase folder) @@ -487,7 +494,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { return true; } - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user is foreign({0} - {1})", userInventoryServerURI, uri); + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user {0} is foreign({1} - {2})", userID, userInventoryServerURI, uri); return false; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index bef716b..522f680 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -212,7 +212,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public override List GetFolderItems(UUID userID, UUID folderID) { - return new List(); + UUID sessionID = GetSessionID(userID); + return m_RemoteConnector.GetFolderItems(userID.ToString(), folderID, sessionID); } public override bool AddFolder(InventoryFolderBase folder) diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 94b4ad9..75fa516 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -214,6 +214,19 @@ namespace OpenSim.Services.Connectors.Inventory return false; } + public List GetFolderItems(string id, UUID folderID, UUID sessionID) + { + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.GetFolderItems(userID, folderID, sessionID); + } + return new List(); + } + public bool AddItem(string id, InventoryItemBase item, UUID sessionID) { string url = string.Empty; diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index f50bcf5..7f051f3 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs @@ -96,6 +96,13 @@ namespace OpenSim.Services.Connectors bool PurgeFolder(string userID, InventoryFolderBase folder, UUID session_id); /// + /// Get items from a folder. + /// + /// + /// true if the folder was successfully purged + List GetFolderItems(string userID, UUID folderID, UUID session_id); + + /// /// Add a new item to the user's inventory /// /// diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5d94eac..5aa4b30 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -334,6 +334,23 @@ namespace OpenSim.Services.Connectors return false; } + public List GetFolderItems(string userID, UUID folderID, UUID sessionID) + { + try + { + InventoryFolderBase folder = new InventoryFolderBase(folderID, new UUID(userID)); + return SynchronousRestSessionObjectPoster>.BeginPostObject( + "POST", m_ServerURI + "/GetItems/", folder, sessionID.ToString(), userID); + } + catch (Exception e) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed, {0} {1}", + e.Source, e.Message); + } + + return null; + } + public bool AddItem(string userID, InventoryItemBase item, UUID sessionID) { try -- cgit v1.1 From c5af39239f7f2a1725d9c08bea80522de8835e0f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 00:13:51 -0700 Subject: A better purge of trash folder. --- .../Rest/Inventory/RestInventoryServices.cs | 8 ++++-- .../Communications/Cache/CachedUserInfo.cs | 4 ++- .../Communications/Tests/LoginServiceTests.cs | 2 +- OpenSim/Framework/IClientAPI.cs | 2 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 25 ++++++++++------- .../Inventory/Transfer/InventoryTransferModule.cs | 4 ++- .../Inventory/BaseInventoryConnector.cs | 2 +- .../Inventory/HGInventoryBroker.cs | 18 ++++++++----- .../Inventory/LocalInventoryServiceConnector.cs | 4 +-- .../Inventory/RemoteInventoryServiceConnector.cs | 10 ++++--- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 +++++++++++++++++----- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 +- .../Inventory/InventoryServerInConnector.cs | 13 +++++++-- .../Inventory/HGInventoryServiceConnector.cs | 4 +-- .../Inventory/ISessionAuthInventoryService.cs | 2 +- .../Inventory/InventoryServiceConnector.cs | 9 ++++--- .../QuickAndDirtyInventoryServiceConnector.cs | 2 +- OpenSim/Services/Interfaces/IInventoryService.cs | 3 ++- .../Services/InventoryService/InventoryService.cs | 12 ++++++--- OpenSim/Tests/Common/Mock/TestInventoryService.cs | 2 +- 20 files changed, 106 insertions(+), 53 deletions(-) diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index aec06be..59431bb 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs @@ -851,7 +851,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // Delete the old item - Rest.InventoryServices.DeleteItem(uri); + List uuids = new List(); + uuids.Add(uri.ID); + Rest.InventoryServices.DeleteItems(uri.Owner, uuids); // Add the new item to the inventory @@ -927,7 +929,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory InventoryItemBase item = (InventoryItemBase) InventoryNode; Rest.Log.DebugFormat("{0} {1}: Item {2} will be deleted", MsgId, rdata.method, rdata.path); - Rest.InventoryServices.DeleteItem(item); + List uuids = new List(); + uuids.Add(item.ID); + Rest.InventoryServices.DeleteItems(item.Owner, uuids); rdata.appendStatus(String.Format("

Deleted item {0} UUID {1}

", item.Name, item.ID)); } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index ca641d0..238810a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -653,7 +653,9 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - return m_InventoryService.DeleteItem(item); + List uuids = new List(); + uuids.Add(itemID); + return m_InventoryService.DeleteItems(this.UserProfile.ID, uuids); } } else diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 22dcef9..d5d4d1e 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -547,7 +547,7 @@ namespace OpenSim.Framework.Communications.Tests return false; } - public bool DeleteItem(InventoryItemBase item) + public bool DeleteItems(UUID owner, List items) { return false; } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index e451dd8..ca37a5b 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -257,7 +257,7 @@ namespace OpenSim.Framework IClientAPI remoteClient, UUID folderID, UUID itemID, int length, string newName); public delegate void RemoveInventoryItem( - IClientAPI remoteClient, UUID itemID); + IClientAPI remoteClient, List itemIDs); public delegate void RemoveInventoryFolder( IClientAPI remoteClient, UUID folderID); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 16ce9e0..e2fb659 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7053,14 +7053,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnRemoveInventoryItem != null) { handlerRemoveInventoryItem = null; + List uuids = new List(); foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) { - handlerRemoveInventoryItem = OnRemoveInventoryItem; - if (handlerRemoveInventoryItem != null) - { - handlerRemoveInventoryItem(this, datablock.ItemID); - } + uuids.Add(datablock.ItemID); } + handlerRemoveInventoryItem = OnRemoveInventoryItem; + if (handlerRemoveInventoryItem != null) + { + handlerRemoveInventoryItem(this, uuids); + } + } break; case PacketType.RemoveInventoryFolder: @@ -7116,13 +7119,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnRemoveInventoryItem != null) { handlerRemoveInventoryItem = null; + List uuids = new List(); foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) { - handlerRemoveInventoryItem = OnRemoveInventoryItem; - if (handlerRemoveInventoryItem != null) - { - handlerRemoveInventoryItem(this, datablock.ItemID); - } + uuids.Add(datablock.ItemID); + } + handlerRemoveInventoryItem = OnRemoveInventoryItem; + if (handlerRemoveInventoryItem != null) + { + handlerRemoveInventoryItem(this, uuids); } } break; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 3a65336..5afbf68 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -267,7 +267,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer item.Folder = trashFolder.ID; // Diva comment: can't we just update this item??? - invService.DeleteItem(item); + List uuids = new List(); + uuids.Add(item.ID); + invService.DeleteItems(item.Owner, uuids); scene.AddInventoryItem(client, item); } else diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs index ef5ffe1..d1ae3e4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs @@ -186,7 +186,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// true if the item was successfully deleted - public abstract bool DeleteItem(InventoryItemBase item); + public abstract bool DeleteItems(UUID ownerID, List itemIDs); public abstract InventoryItemBase GetItem(InventoryItemBase item); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 3649097..6a1f2d5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -393,18 +393,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public override bool DeleteItem(InventoryItemBase item) + public override bool DeleteItems(UUID ownerID, List itemIDs) { - if (item == null) + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID); + + if (itemIDs == null) return false; + if (itemIDs.Count == 0) + return true; - if (IsLocalGridUser(item.Owner)) - return m_GridService.DeleteItem(item); + if (IsLocalGridUser(ownerID)) + return m_GridService.DeleteItems(ownerID, itemIDs); else { - UUID sessionID = GetSessionID(item.Owner); - string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); - return m_HGService.DeleteItem(uri, item, sessionID); + UUID sessionID = GetSessionID(ownerID); + string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); + return m_HGService.DeleteItems(uri, itemIDs, sessionID); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 2fbc5fe..b2640af 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -294,9 +294,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// true if the item was successfully deleted - public override bool DeleteItem(InventoryItemBase item) + public override bool DeleteItems(UUID ownerID, List itemIDs) { - return m_InventoryService.DeleteItem(item); + return m_InventoryService.DeleteItems(ownerID, itemIDs); } public override InventoryItemBase GetItem(InventoryItemBase item) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 522f680..012f0e3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -273,13 +273,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID); } - public override bool DeleteItem(InventoryItemBase item) + public override bool DeleteItems(UUID ownerID, List itemIDs) { - if (item == null) + if (itemIDs == null) return false; + if (itemIDs.Count == 0) + return true; - UUID sessionID = GetSessionID(item.Owner); - return m_RemoteConnector.DeleteItem(item.Owner.ToString(), item, sessionID); + UUID sessionID = GetSessionID(ownerID); + return m_RemoteConnector.DeleteItems(ownerID.ToString(), itemIDs, sessionID); } public override InventoryItemBase GetItem(InventoryItemBase item) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 48c7f4e..5e2eb73 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -477,7 +477,11 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - InventoryService.DeleteItem(new InventoryItemBase(itemId)); + { + List items = new List(); + items.Add(itemId); + InventoryService.DeleteItems(senderId, items); + } } return itemCopy; @@ -652,7 +656,9 @@ namespace OpenSim.Region.Framework.Scenes item.Folder = folderID; // Diva comment: can't we just update? - InventoryService.DeleteItem(item); + List uuids = new List(); + uuids.Add(item.ID); + InventoryService.DeleteItems(item.Owner, uuids); AddInventoryItem(remoteClient, item); } @@ -799,9 +805,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - private void RemoveInventoryItem(IClientAPI remoteClient, UUID itemID) + private void RemoveInventoryItem(IClientAPI remoteClient, List itemIDs) { - InventoryService.DeleteItem(new InventoryItemBase(itemID)); + //m_log.Debug("[SCENE INVENTORY]: user " + remoteClient.AgentId); + InventoryService.DeleteItems(remoteClient.AgentId, itemIDs); } ///

@@ -1248,7 +1255,11 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - RemoveInventoryItem(remoteClient, itemID); + { + List uuids = new List(); + uuids.Add(itemID); + RemoveInventoryItem(remoteClient, uuids); + } } } else @@ -2144,7 +2155,11 @@ namespace OpenSim.Region.Framework.Scenes // copy ones will be lost, so avoid it // if (!attachment) - InventoryService.DeleteItem(item); + { + List uuids = new List(); + uuids.Add(item.ID); + InventoryService.DeleteItems(item.Owner, uuids); + } } } @@ -2404,7 +2419,9 @@ namespace OpenSim.Region.Framework.Scenes } part.ParentGroup.DetachToGround(); - InventoryService.DeleteItem(new InventoryItemBase(inventoryID)); + List uuids = new List(); + uuids.Add(inventoryID); + InventoryService.DeleteItems(remoteClient.AgentId, uuids); remoteClient.SendRemoveInventoryItem(inventoryID); } SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 1bbca49..a2414e5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -560,7 +560,7 @@ namespace OpenSim.Region.Framework.Scenes public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) { - InventoryFolderBase folder = new InventoryFolderBase(folderID); + InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId); if (InventoryService.PurgeFolder(folder)) m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID); diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index 30b3cae..6cfc7df 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs @@ -105,8 +105,8 @@ namespace OpenSim.Server.Handlers.Inventory "POST", "/PurgeFolder/", m_InventoryService.PurgeFolder, CheckAuthSession)); m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/DeleteItem/", m_InventoryService.DeleteItem, CheckAuthSession)); + new RestDeserialiseSecureHandler, bool>( + "POST", "/DeleteItem/", DeleteItems, CheckAuthSession)); m_httpServer.AddStreamHandler( new RestDeserialiseSecureHandler( @@ -247,6 +247,15 @@ namespace OpenSim.Server.Handlers.Inventory return m_InventoryService.GetAssetPermissions(item.Owner, item.AssetID); } + public bool DeleteItems(List items) + { + List uuids = new List(); + foreach (Guid g in items) + uuids.Add(new UUID(g)); + // oops we lost the user info here. Bad bad handlers + return m_InventoryService.DeleteItems(UUID.Zero, uuids); + } + #endregion /// diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 75fa516..00b74b5 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -253,7 +253,7 @@ namespace OpenSim.Services.Connectors.Inventory return false; } - public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID) + public bool DeleteItems(string id, List itemIDs, UUID sessionID) { string url = string.Empty; string userID = string.Empty; @@ -261,7 +261,7 @@ namespace OpenSim.Services.Connectors.Inventory if (StringToUrlAndUserID(id, out url, out userID)) { ISessionAuthInventoryService connector = GetConnector(url); - return connector.UpdateItem(userID, item, sessionID); + return connector.DeleteItems(userID, itemIDs, sessionID); } return false; } diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index 7f051f3..e4e713c 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs @@ -121,7 +121,7 @@ namespace OpenSim.Services.Connectors /// /// /// true if the item was successfully deleted - bool DeleteItem(string userID, InventoryItemBase item, UUID session_id); + bool DeleteItems(string userID, List itemIDs, UUID session_id); InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id); diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5aa4b30..9b2e331 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -383,12 +383,15 @@ namespace OpenSim.Services.Connectors return false; } - public bool DeleteItem(string userID, InventoryItemBase item, UUID sessionID) + public bool DeleteItems(string userID, List items, UUID sessionID) { try { - return SynchronousRestSessionObjectPoster.BeginPostObject( - "POST", m_ServerURI + "/DeleteItem/", item, sessionID.ToString(), item.Owner.ToString()); + List guids = new List(); + foreach (UUID u in items) + guids.Add(u.Guid); + return SynchronousRestSessionObjectPoster, bool>.BeginPostObject( + "POST", m_ServerURI + "/DeleteItem/", guids, sessionID.ToString(), userID); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index 5cbd307..3bbf129 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs @@ -151,7 +151,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool DeleteItem(InventoryItemBase item) + public bool DeleteItems(UUID owner, List itemIDs) { return false; } diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index a89a238..6409b57 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -147,7 +147,8 @@ namespace OpenSim.Services.Interfaces /// /// /// true if the item was successfully deleted - bool DeleteItem(InventoryItemBase item); + //bool DeleteItem(InventoryItemBase item); + bool DeleteItems(UUID userID, List itemIDs); /// /// Get an item, given by its UUID diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index 65c2d96..69b1b28 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -387,12 +387,14 @@ namespace OpenSim.Services.InventoryService } // See IInventoryServices - public virtual bool DeleteItem(InventoryItemBase item) + public virtual bool DeleteItems(UUID owner, List itemIDs) { m_log.InfoFormat( - "[INVENTORY SERVICE]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); + "[INVENTORY SERVICE]: Deleting {0} items from user {1}", itemIDs.Count, owner); - m_Database.deleteInventoryItem(item.ID); + // uhh..... + foreach (UUID uuid in itemIDs) + m_Database.deleteInventoryItem(uuid); // FIXME: Should return false on failure return true; @@ -439,10 +441,12 @@ namespace OpenSim.Services.InventoryService List items = GetFolderItems(folder.Owner, folder.ID); + List uuids = new List(); foreach (InventoryItemBase item in items) { - DeleteItem(item); + uuids.Add(item.ID); } + DeleteItems(folder.Owner, uuids); // FIXME: Should return false on failure return true; diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/TestInventoryService.cs index ba9cbe9..f770f75 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryService.cs @@ -143,7 +143,7 @@ namespace OpenSim.Tests.Common.Mock return false; } - public bool DeleteItem(InventoryItemBase item) + public bool DeleteItems(UUID ownerID, List itemIDs) { return false; } -- cgit v1.1 From 4382f28efc6ffe70e3c6f6e8cd7e7c729d1f12af Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 00:33:02 -0700 Subject: Async purge so that the client thread doesn't wait. --- .../Inventory/RemoteInventoryServiceConnector.cs | 10 ++++----- .../Framework/Scenes/Scene.PacketHandlers.cs | 24 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 012f0e3..081d0f7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -323,14 +323,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private UUID GetSessionID(UUID userID) { - if (m_Scene == null) - { - m_log.Debug("[INVENTORY CONNECTOR]: OOPS! scene is null"); - } + //if (m_Scene == null) + //{ + // m_log.Debug("[INVENTORY CONNECTOR]: OOPS! scene is null"); + //} if (m_UserProfileService == null) { - m_log.Debug("[INVENTORY CONNECTOR]: OOPS! UserProfileCacheService is null"); + //m_log.Debug("[INVENTORY CONNECTOR]: OOPS! UserProfileCacheService is null"); return UUID.Zero; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index a2414e5..77b980c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.Threading; using OpenMetaverse; @@ -558,15 +559,34 @@ namespace OpenSim.Region.Framework.Scenes /// /// + delegate void PurgeFolderDelegate(UUID userID, UUID folder); + public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) { - InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId); + PurgeFolderDelegate d = PurgeFolderAsync; + try + { + d.BeginInvoke(remoteClient.AgentId, folderID, PurgeFolderCompleted, d); + } + catch (Exception e) + { + m_log.WarnFormat("[AGENT INVENTORY]: Exception on purge folder for user {0}: {1}", remoteClient.AgentId, e.Message); + } + } + + + private void PurgeFolderAsync(UUID userID, UUID folderID) + { + InventoryFolderBase folder = new InventoryFolderBase(folderID, userID); if (InventoryService.PurgeFolder(folder)) m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID); else m_log.WarnFormat("[AGENT INVENTORY]: could not purge folder {0}", folderID); - } + } + private void PurgeFolderCompleted(IAsyncResult iar) + { + } } } -- cgit v1.1 From d519f1885f587409592cf92bc0f4ba8533a1866f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 10:56:08 -0700 Subject: Added MoveItems, which is most useful upon viewer-delete inventory operation. Moving a batch of items is a 1-time operation. Made it async anyway, so that the viewer doesn't wait in case the DB layer is dumb (which is the case currently). --- .../Communications/Tests/LoginServiceTests.cs | 5 +++ OpenSim/Framework/IClientAPI.cs | 2 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 19 ++++++---- .../Inventory/BaseInventoryConnector.cs | 2 ++ .../Inventory/HGInventoryBroker.cs | 17 +++++++++ .../Inventory/LocalInventoryServiceConnector.cs | 6 ++++ .../Inventory/RemoteInventoryServiceConnector.cs | 10 ++++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 +++------------- .../Inventory/InventoryServerInConnector.cs | 21 ++++++++--- .../Inventory/HGInventoryServiceConnector.cs | 13 +++++++ .../Inventory/ISessionAuthInventoryService.cs | 2 ++ .../Inventory/InventoryServiceConnector.cs | 42 ++++++++++++++++++++++ .../QuickAndDirtyInventoryServiceConnector.cs | 5 +++ OpenSim/Services/Interfaces/IInventoryService.cs | 2 ++ .../Services/InventoryService/InventoryService.cs | 18 ++++++++++ OpenSim/Tests/Common/Mock/TestInventoryService.cs | 5 +++ 16 files changed, 162 insertions(+), 38 deletions(-) diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index d5d4d1e..6f86704 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -547,6 +547,11 @@ namespace OpenSim.Framework.Communications.Tests return false; } + public bool MoveItems(UUID owner, List items) + { + return false; + } + public bool DeleteItems(UUID owner, List items) { return false; diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index ca37a5b..c6cdcaa 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -254,7 +254,7 @@ namespace OpenSim.Framework string newName); public delegate void MoveInventoryItem( - IClientAPI remoteClient, UUID folderID, UUID itemID, int length, string newName); + IClientAPI remoteClient, List items); public delegate void RemoveInventoryItem( IClientAPI remoteClient, List itemIDs); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index e2fb659..6969a3d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7027,14 +7027,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnMoveInventoryItem != null) { handlerMoveInventoryItem = null; + InventoryItemBase itm = null; + List items = new List(); foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) { - handlerMoveInventoryItem = OnMoveInventoryItem; - if (handlerMoveInventoryItem != null) - { - handlerMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, - Util.FieldToString(datablock.NewName)); - } + itm = new InventoryItemBase(datablock.ItemID, AgentId); + itm.Folder = datablock.FolderID; + itm.Name = Util.FieldToString(datablock.NewName); + // weird, comes out as empty string + //m_log.DebugFormat("[XXX] new name: {0}", itm.Name); + items.Add(itm); + } + handlerMoveInventoryItem = OnMoveInventoryItem; + if (handlerMoveInventoryItem != null) + { + handlerMoveInventoryItem(this, items); } } break; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs index d1ae3e4..d4cb616 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs @@ -181,6 +181,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// true if the item was successfully updated public abstract bool UpdateItem(InventoryItemBase item); + public abstract bool MoveItems(UUID ownerID, List items); + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 6a1f2d5..787c6c8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -393,6 +393,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } + public override bool MoveItems(UUID ownerID, List items) + { + if (items == null) + return false; + if (items.Count == 0) + return true; + + if (IsLocalGridUser(ownerID)) + return m_GridService.MoveItems(ownerID, items); + else + { + UUID sessionID = GetSessionID(ownerID); + string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); + return m_HGService.MoveItems(uri, items, sessionID); + } + } + public override bool DeleteItems(UUID ownerID, List itemIDs) { m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index b2640af..562c5dd 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -289,6 +289,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_InventoryService.UpdateItem(item); } + + public override bool MoveItems(UUID ownerID, List items) + { + return m_InventoryService.MoveItems(ownerID, items); + } + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 081d0f7..201442c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -273,6 +273,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID); } + public override bool MoveItems(UUID ownerID, List items) + { + if (items == null) + return false; + + UUID sessionID = GetSessionID(ownerID); + return m_RemoteConnector.MoveItems(ownerID.ToString(), items, sessionID); + } + + public override bool DeleteItems(UUID ownerID, List itemIDs) { if (itemIDs == null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5e2eb73..a119efc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -638,36 +638,13 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void MoveInventoryItem(IClientAPI remoteClient, UUID folderID, UUID itemID, int length, - string newName) + public void MoveInventoryItem(IClientAPI remoteClient, List items) { m_log.DebugFormat( - "[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId); + "[AGENT INVENTORY]: Moving {0} items for user {1}", items.Count, remoteClient.AgentId); - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = InventoryService.GetItem(item); - - if (item != null) - { - if (newName != String.Empty) - { - item.Name = newName; - } - item.Folder = folderID; - - // Diva comment: can't we just update? - List uuids = new List(); - uuids.Add(item.ID); - InventoryService.DeleteItems(item.Owner, uuids); - - AddInventoryItem(remoteClient, item); - } - else - { - m_log.Warn("[AGENT INVENTORY]: Failed to find item " + itemID.ToString()); - - return; - } + if (!InventoryService.MoveItems(remoteClient.AgentId, items)) + m_log.Warn("[AGENT INVENTORY]: Failed to move items for user " + remoteClient.AgentId); } /// diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index 6cfc7df..6ef1d9d 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs @@ -125,8 +125,8 @@ namespace OpenSim.Server.Handlers.Inventory "POST", "/NewFolder/", m_InventoryService.AddFolder, CheckAuthSession)); m_httpServer.AddStreamHandler( - new RestDeserialiseTrustedHandler( - "POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckTrustSource)); + new RestDeserialiseSecureHandler( + "POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckAuthSession)); m_httpServer.AddStreamHandler( new RestDeserialiseSecureHandler( @@ -137,9 +137,13 @@ namespace OpenSim.Server.Handlers.Inventory "POST", "/AddNewItem/", m_InventoryService.AddItem, CheckTrustSource)); m_httpServer.AddStreamHandler( - new RestDeserialiseTrustedHandler>( - "POST", "/GetItems/", GetFolderItems, CheckTrustSource)); + new RestDeserialiseSecureHandler>( + "POST", "/GetItems/", GetFolderItems, CheckAuthSession)); + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler, bool>( + "POST", "/MoveItems/", MoveItems, CheckAuthSession)); + // for persistent active gestures m_httpServer.AddStreamHandler( new RestDeserialiseTrustedHandler> @@ -256,6 +260,15 @@ namespace OpenSim.Server.Handlers.Inventory return m_InventoryService.DeleteItems(UUID.Zero, uuids); } + public bool MoveItems(List items) + { + // oops we lost the user info here. Bad bad handlers + // let's peek at one item + UUID ownerID = UUID.Zero; + if (items.Count > 0) + ownerID = items[0].Owner; + return m_InventoryService.MoveItems(ownerID, items); + } #endregion /// diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 00b74b5..45e921a 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -253,6 +253,19 @@ namespace OpenSim.Services.Connectors.Inventory return false; } + public bool MoveItems(string id, List items, UUID sessionID) + { + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.MoveItems(userID, items, sessionID); + } + return false; + } + public bool DeleteItems(string id, List itemIDs, UUID sessionID) { string url = string.Empty; diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index e4e713c..c89c9b7 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs @@ -116,6 +116,8 @@ namespace OpenSim.Services.Connectors /// true if the item was successfully updated bool UpdateItem(string userID, InventoryItemBase item, UUID session_id); + bool MoveItems(string userID, List items, UUID session_id); + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 9b2e331..bcf9d87 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -383,6 +383,48 @@ namespace OpenSim.Services.Connectors return false; } + /** + * MoveItems Async group + */ + + delegate void MoveItemsDelegate(string userID, List items, UUID sessionID); + + private void MoveItemsAsync(string userID, List items, UUID sessionID) + { + try + { + SynchronousRestSessionObjectPoster, bool>.BeginPostObject( + "POST", m_ServerURI + "/MoveItems/", items, sessionID.ToString(), userID.ToString()); + + // Success + return; + } + catch (Exception e) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory items operation failed, {0} {1} (old server?). Trying slow way.", + e.Source, e.Message); + } + + foreach (InventoryItemBase item in items) + { + InventoryItemBase itm = this.QueryItem(userID, item, sessionID); + itm.Name = item.Name; + itm.Folder = item.Folder; + this.UpdateItem(userID, itm, sessionID); + } + } + + private void MoveItemsCompleted(IAsyncResult iar) + { + } + + public bool MoveItems(string userID, List items, UUID sessionID) + { + MoveItemsDelegate d = MoveItemsAsync; + d.BeginInvoke(userID, items, sessionID, MoveItemsCompleted, d); + return true; + } + public bool DeleteItems(string userID, List items, UUID sessionID) { try diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index 3bbf129..cd283ff 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs @@ -151,6 +151,11 @@ namespace OpenSim.Services.Connectors return false; } + public bool MoveItems(UUID ownerID, List items) + { + return false; + } + public bool DeleteItems(UUID owner, List itemIDs) { return false; diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index 6409b57..ebdb09a 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -142,6 +142,8 @@ namespace OpenSim.Services.Interfaces /// true if the item was successfully updated bool UpdateItem(InventoryItemBase item); + bool MoveItems(UUID ownerID, List items); + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index 69b1b28..e0217f6 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -386,6 +386,24 @@ namespace OpenSim.Services.InventoryService return true; } + public virtual bool MoveItems(UUID ownerID, List items) + { + m_log.InfoFormat( + "[INVENTORY SERVICE]: Moving {0} items from user {1}", items.Count, ownerID); + + InventoryItemBase itm = null; + foreach (InventoryItemBase item in items) + { + itm = GetInventoryItem(item.ID); + itm.Folder = item.Folder; + if ((item.Name != null) && !item.Name.Equals(string.Empty)) + itm.Name = item.Name; + m_Database.updateInventoryItem(itm); + } + + return true; + } + // See IInventoryServices public virtual bool DeleteItems(UUID owner, List itemIDs) { diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/TestInventoryService.cs index f770f75..ee22e5e 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryService.cs @@ -143,6 +143,11 @@ namespace OpenSim.Tests.Common.Mock return false; } + public bool MoveItems(UUID ownerID, List items) + { + return false; + } + public bool DeleteItems(UUID ownerID, List itemIDs) { return false; -- cgit v1.1