Remove GetAssemblyName and friends from the SE interface. It's now handled
internallyavinationmerge
parent
ac2fcbe224
commit
22c325aa5a
|
@ -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>
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
{
|
||||
string ScriptEngineName { get; }
|
||||
|
||||
string GetAssemblyName(UUID itemID);
|
||||
string GetXMLState(UUID itemID);
|
||||
bool CanBeDeleted(UUID itemID);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -880,36 +880,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>();
|
||||
|
|
|
@ -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 <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">
|
||||
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 <ScriptState>...</ScriptState>
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue