From 22c325aa5ae06b897e5eb10404c0aa3727f8237b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:08:20 +0000 Subject: Remove GetAssemblyName and friends from the SE interface. It's now handled internally --- .../Framework/Interfaces/IEntityInventory.cs | 6 -- .../Region/Framework/Interfaces/IScriptModule.cs | 1 - .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 93 ++------------------- .../Framework/Scenes/SceneObjectPartInventory.cs | 30 ------- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 95 ++++++++++++++++++++-- 5 files changed, 91 insertions(+), 134 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2c906a2..2998f45 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -185,12 +185,6 @@ namespace OpenSim.Region.Framework.Interfaces List GetInventoryList(); /// - /// Get the names of the assemblies associated with scripts in this inventory. - /// - /// - string[] GetScriptAssemblies(); - - /// /// Get the xml representing the saved states of scripts in this inventory. /// /// diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 10835b9..72bb0f0 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces { string ScriptEngineName { get; } - string GetAssemblyName(UUID itemID); string GetXMLState(UUID itemID); bool CanBeDeleted(UUID itemID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 3cec77f..9a6f2b8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes public string GetStateSnapshot() { - //m_log.Debug(" >>> GetStateSnapshot <<<"); - - List assemblies = new List(); Dictionary states = new Dictionary(); foreach (SceneObjectPart part in m_parts.Values) { - foreach (string a in part.Inventory.GetScriptAssemblies()) - { - if (a != "" && !assemblies.Contains(a)) - assemblies.Add(a); - } - foreach (KeyValuePair s in part.Inventory.GetScriptStates()) - { states[s.Key] = s.Value; - } } - if (states.Count < 1 || assemblies.Count < 1) + if (states.Count < 1) return ""; XmlDocument xmldoc = new XmlDocument(); @@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes xmldoc.AppendChild(rootElement); - XmlElement wrapper = xmldoc.CreateElement("", "Assemblies", - ""); - rootElement.AppendChild(wrapper); - - foreach (string assembly in assemblies) - { - string fn = Path.GetFileName(assembly); - if (fn == String.Empty) - continue; - - String filedata = String.Empty; - - if (File.Exists(assembly+".text")) - { - FileInfo tfi = new FileInfo(assembly+".text"); - - if (tfi == null) - continue; - - Byte[] tdata = new Byte[tfi.Length]; - - try - { - FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read); - tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message); - } - - filedata = new System.Text.ASCIIEncoding().GetString(tdata); - } - else - { - FileInfo fi = new FileInfo(assembly); - - if (fi == null) - continue; - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); - } - - filedata = System.Convert.ToBase64String(data); - } - XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); - XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); - assemblyName.Value = fn; - assemblyData.Attributes.Append(assemblyName); - - assemblyData.InnerText = filedata; - - wrapper.AppendChild(assemblyData); - } - - wrapper = xmldoc.CreateElement("", "ScriptStates", + XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", ""); rootElement.AppendChild(wrapper); foreach (KeyValuePair state in states) { - XmlElement stateData = xmldoc.CreateElement("", "State", ""); - - XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", ""); - stateID.Value = state.Key.ToString(); - stateData.Attributes.Append(stateID); - XmlDocument sdoc = new XmlDocument(); sdoc.LoadXml(state.Value); - XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNodeList rootL = sdoc.GetElementsByTagName("State"); XmlNode rootNode = rootL[0]; XmlNode newNode = xmldoc.ImportNode(rootNode, true); - stateData.AppendChild(newNode); - wrapper.AppendChild(stateData); + wrapper.AppendChild(newNode); } return xmldoc.InnerXml; @@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetState(string objXMLData, UUID RegionID) { +m_log.Debug("SetState called with " + objXMLData); if (objXMLData == String.Empty) return; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index abb04cd..2ef8258 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -880,36 +880,6 @@ namespace OpenSim.Region.Framework.Scenes return ret; } - public string[] GetScriptAssemblies() - { - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - - List ret = new List(); - if (engines == null) // No engine at all - return new string[0]; - - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - if (e != null) - { - string n = e.GetAssemblyName(item.ItemID); - if (n != String.Empty) - { - if (!ret.Contains(n)) - ret.Add(n); - break; - } - } - } - } - } - return ret.ToArray(); - } - public Dictionary GetScriptStates() { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 8b94f28..4dc6cb8 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1248,20 +1248,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - public string GetAssemblyName(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return ""; - return instance.GetAssemblyName(); - } - public string GetXMLState(UUID itemID) { IScriptInstance instance = GetInstance(itemID); if (instance == null) return ""; - return instance.GetXMLState(); + string xml = instance.GetXMLState(); + + XmlDocument sdoc = new XmlDocument(); + sdoc.LoadXml(xml); + XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNode rootNode = rootL[0]; + + // Create + XmlDocument doc = new XmlDocument(); + XmlElement stateData = doc.CreateElement("", "State", ""); + XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); + stateID.Value = itemID.ToString(); + stateData.Attributes.Append(stateID); + XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); + assetID.Value = instance.AssetID.ToString(); + stateData.Attributes.Append(assetID); + doc.AppendChild(stateData); + + // Add ... + XmlNode xmlstate = doc.ImportNode(rootNode, true); + stateData.AppendChild(xmlstate); + + string assemName = instance.GetAssemblyName(); + + string fn = Path.GetFileName(assemName); + + string assem = String.Empty; + + if (File.Exists(assemName + ".text")) + { + FileInfo tfi = new FileInfo(assemName + ".text"); + + if (tfi != null) + { + Byte[] tdata = new Byte[tfi.Length]; + + try + { + FileStream tfs = File.Open(assemName + ".text", + FileMode.Open, FileAccess.Read); + tfs.Read(tdata, 0, tdata.Length); + tfs.Close(); + + assem = new System.Text.ASCIIEncoding().GetString(tdata); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); + } + } + } + else + { + FileInfo fi = new FileInfo(assemName); + + if (fi != null) + { + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + + assem = System.Convert.ToBase64String(data); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); + } + + } + } + + XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); + XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); + + assemblyName.Value = fn; + assemblyData.Attributes.Append(assemblyName); + + assemblyData.InnerText = assem; + + stateData.AppendChild(assemblyData); + + return doc.InnerXml; } public bool CanBeDeleted(UUID itemID) -- cgit v1.1