diff options
author | Melanie | 2009-11-26 12:08:20 +0000 |
---|---|---|
committer | Melanie | 2009-11-26 12:08:20 +0000 |
commit | 88842edc95bafeb9f3b2f2ea0ab09394028a0916 (patch) | |
tree | 17e8b01bf61004627c551345e9980cc6e4e27520 /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC_OLD-88842edc95bafeb9f3b2f2ea0ab09394028a0916.zip opensim-SC_OLD-88842edc95bafeb9f3b2f2ea0ab09394028a0916.tar.gz opensim-SC_OLD-88842edc95bafeb9f3b2f2ea0ab09394028a0916.tar.bz2 opensim-SC_OLD-88842edc95bafeb9f3b2f2ea0ab09394028a0916.tar.xz |
Remove GetAssemblyName and friends from the SE interface. It's now handled
internally
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a60c0ba..0a9af2c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1245,20 +1245,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1245 | } | 1245 | } |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | public string GetAssemblyName(UUID itemID) | ||
1249 | { | ||
1250 | IScriptInstance instance = GetInstance(itemID); | ||
1251 | if (instance == null) | ||
1252 | return ""; | ||
1253 | return instance.GetAssemblyName(); | ||
1254 | } | ||
1255 | |||
1256 | public string GetXMLState(UUID itemID) | 1248 | public string GetXMLState(UUID itemID) |
1257 | { | 1249 | { |
1258 | IScriptInstance instance = GetInstance(itemID); | 1250 | IScriptInstance instance = GetInstance(itemID); |
1259 | if (instance == null) | 1251 | if (instance == null) |
1260 | return ""; | 1252 | return ""; |
1261 | return instance.GetXMLState(); | 1253 | string xml = instance.GetXMLState(); |
1254 | |||
1255 | XmlDocument sdoc = new XmlDocument(); | ||
1256 | sdoc.LoadXml(xml); | ||
1257 | XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); | ||
1258 | XmlNode rootNode = rootL[0]; | ||
1259 | |||
1260 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> | ||
1261 | XmlDocument doc = new XmlDocument(); | ||
1262 | XmlElement stateData = doc.CreateElement("", "State", ""); | ||
1263 | XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); | ||
1264 | stateID.Value = itemID.ToString(); | ||
1265 | stateData.Attributes.Append(stateID); | ||
1266 | XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); | ||
1267 | assetID.Value = instance.AssetID.ToString(); | ||
1268 | stateData.Attributes.Append(assetID); | ||
1269 | doc.AppendChild(stateData); | ||
1270 | |||
1271 | // Add <ScriptState>...</ScriptState> | ||
1272 | XmlNode xmlstate = doc.ImportNode(rootNode, true); | ||
1273 | stateData.AppendChild(xmlstate); | ||
1274 | |||
1275 | string assemName = instance.GetAssemblyName(); | ||
1276 | |||
1277 | string fn = Path.GetFileName(assemName); | ||
1278 | |||
1279 | string assem = String.Empty; | ||
1280 | |||
1281 | if (File.Exists(assemName + ".text")) | ||
1282 | { | ||
1283 | FileInfo tfi = new FileInfo(assemName + ".text"); | ||
1284 | |||
1285 | if (tfi != null) | ||
1286 | { | ||
1287 | Byte[] tdata = new Byte[tfi.Length]; | ||
1288 | |||
1289 | try | ||
1290 | { | ||
1291 | FileStream tfs = File.Open(assemName + ".text", | ||
1292 | FileMode.Open, FileAccess.Read); | ||
1293 | tfs.Read(tdata, 0, tdata.Length); | ||
1294 | tfs.Close(); | ||
1295 | |||
1296 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | ||
1297 | } | ||
1298 | catch (Exception e) | ||
1299 | { | ||
1300 | m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); | ||
1301 | } | ||
1302 | } | ||
1303 | } | ||
1304 | else | ||
1305 | { | ||
1306 | FileInfo fi = new FileInfo(assemName); | ||
1307 | |||
1308 | if (fi != null) | ||
1309 | { | ||
1310 | Byte[] data = new Byte[fi.Length]; | ||
1311 | |||
1312 | try | ||
1313 | { | ||
1314 | FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); | ||
1315 | fs.Read(data, 0, data.Length); | ||
1316 | fs.Close(); | ||
1317 | |||
1318 | assem = System.Convert.ToBase64String(data); | ||
1319 | } | ||
1320 | catch (Exception e) | ||
1321 | { | ||
1322 | m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); | ||
1323 | } | ||
1324 | |||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | ||
1329 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); | ||
1330 | |||
1331 | assemblyName.Value = fn; | ||
1332 | assemblyData.Attributes.Append(assemblyName); | ||
1333 | |||
1334 | assemblyData.InnerText = assem; | ||
1335 | |||
1336 | stateData.AppendChild(assemblyData); | ||
1337 | |||
1338 | return doc.InnerXml; | ||
1262 | } | 1339 | } |
1263 | 1340 | ||
1264 | public bool CanBeDeleted(UUID itemID) | 1341 | public bool CanBeDeleted(UUID itemID) |