Remove GetAssemblyName and friends from the SE interface. It's now handled

internally
This commit is contained in:
Melanie
2009-11-26 12:08:20 +00:00
parent cc3617f74f
commit 88842edc95
5 changed files with 91 additions and 134 deletions

View File

@@ -184,12 +184,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns></returns>
List<UUID> GetInventoryList();
/// <summary>
/// Get the names of the assemblies associated with scripts in this inventory.
/// </summary>
/// <returns></returns>
string[] GetScriptAssemblies();
/// <summary>
/// Get the xml representing the saved states of scripts in this inventory.
/// </summary>

View File

@@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
{
string ScriptEngineName { get; }
string GetAssemblyName(UUID itemID);
string GetXMLState(UUID itemID);
bool CanBeDeleted(UUID itemID);

View File

@@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes
public string GetStateSnapshot()
{
//m_log.Debug(" >>> GetStateSnapshot <<<");
List<string> assemblies = new List<string>();
Dictionary<UUID, string> states = new Dictionary<UUID, string>();
foreach (SceneObjectPart part in m_parts.Values)
{
foreach (string a in part.Inventory.GetScriptAssemblies())
{
if (a != "" && !assemblies.Contains(a))
assemblies.Add(a);
}
foreach (KeyValuePair<UUID, string> 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<UUID, string> 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;

View File

@@ -857,36 +857,6 @@ namespace OpenSim.Region.Framework.Scenes
return ret;
}
public string[] GetScriptAssemblies()
{
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
List<string> ret = new List<string>();
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<UUID, string> GetScriptStates()
{
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();