diff options
Diffstat (limited to 'OpenSim')
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 | |||
185 | List<UUID> GetInventoryList(); | 185 | List<UUID> GetInventoryList(); |
186 | 186 | ||
187 | /// <summary> | 187 | /// <summary> |
188 | /// Get the names of the assemblies associated with scripts in this inventory. | ||
189 | /// </summary> | ||
190 | /// <returns></returns> | ||
191 | string[] GetScriptAssemblies(); | ||
192 | |||
193 | /// <summary> | ||
194 | /// Get the xml representing the saved states of scripts in this inventory. | 188 | /// Get the xml representing the saved states of scripts in this inventory. |
195 | /// </summary> | 189 | /// </summary> |
196 | /// <returns> | 190 | /// <returns> |
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 | |||
34 | { | 34 | { |
35 | string ScriptEngineName { get; } | 35 | string ScriptEngineName { get; } |
36 | 36 | ||
37 | string GetAssemblyName(UUID itemID); | ||
38 | string GetXMLState(UUID itemID); | 37 | string GetXMLState(UUID itemID); |
39 | bool CanBeDeleted(UUID itemID); | 38 | bool CanBeDeleted(UUID itemID); |
40 | 39 | ||
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 | |||
309 | 309 | ||
310 | public string GetStateSnapshot() | 310 | public string GetStateSnapshot() |
311 | { | 311 | { |
312 | //m_log.Debug(" >>> GetStateSnapshot <<<"); | ||
313 | |||
314 | List<string> assemblies = new List<string>(); | ||
315 | Dictionary<UUID, string> states = new Dictionary<UUID, string>(); | 312 | Dictionary<UUID, string> states = new Dictionary<UUID, string>(); |
316 | 313 | ||
317 | foreach (SceneObjectPart part in m_parts.Values) | 314 | foreach (SceneObjectPart part in m_parts.Values) |
318 | { | 315 | { |
319 | foreach (string a in part.Inventory.GetScriptAssemblies()) | ||
320 | { | ||
321 | if (a != "" && !assemblies.Contains(a)) | ||
322 | assemblies.Add(a); | ||
323 | } | ||
324 | |||
325 | foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates()) | 316 | foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates()) |
326 | { | ||
327 | states[s.Key] = s.Value; | 317 | states[s.Key] = s.Value; |
328 | } | ||
329 | } | 318 | } |
330 | 319 | ||
331 | if (states.Count < 1 || assemblies.Count < 1) | 320 | if (states.Count < 1) |
332 | return ""; | 321 | return ""; |
333 | 322 | ||
334 | XmlDocument xmldoc = new XmlDocument(); | 323 | XmlDocument xmldoc = new XmlDocument(); |
@@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
342 | 331 | ||
343 | xmldoc.AppendChild(rootElement); | 332 | xmldoc.AppendChild(rootElement); |
344 | 333 | ||
345 | XmlElement wrapper = xmldoc.CreateElement("", "Assemblies", | ||
346 | ""); | ||
347 | 334 | ||
348 | rootElement.AppendChild(wrapper); | 335 | XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", |
349 | |||
350 | foreach (string assembly in assemblies) | ||
351 | { | ||
352 | string fn = Path.GetFileName(assembly); | ||
353 | if (fn == String.Empty) | ||
354 | continue; | ||
355 | |||
356 | String filedata = String.Empty; | ||
357 | |||
358 | if (File.Exists(assembly+".text")) | ||
359 | { | ||
360 | FileInfo tfi = new FileInfo(assembly+".text"); | ||
361 | |||
362 | if (tfi == null) | ||
363 | continue; | ||
364 | |||
365 | Byte[] tdata = new Byte[tfi.Length]; | ||
366 | |||
367 | try | ||
368 | { | ||
369 | FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read); | ||
370 | tfs.Read(tdata, 0, tdata.Length); | ||
371 | tfs.Close(); | ||
372 | } | ||
373 | catch (Exception e) | ||
374 | { | ||
375 | m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message); | ||
376 | } | ||
377 | |||
378 | filedata = new System.Text.ASCIIEncoding().GetString(tdata); | ||
379 | } | ||
380 | else | ||
381 | { | ||
382 | FileInfo fi = new FileInfo(assembly); | ||
383 | |||
384 | if (fi == null) | ||
385 | continue; | ||
386 | |||
387 | Byte[] data = new Byte[fi.Length]; | ||
388 | |||
389 | try | ||
390 | { | ||
391 | FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); | ||
392 | fs.Read(data, 0, data.Length); | ||
393 | fs.Close(); | ||
394 | } | ||
395 | catch (Exception e) | ||
396 | { | ||
397 | m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); | ||
398 | } | ||
399 | |||
400 | filedata = System.Convert.ToBase64String(data); | ||
401 | } | ||
402 | XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); | ||
403 | XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); | ||
404 | assemblyName.Value = fn; | ||
405 | assemblyData.Attributes.Append(assemblyName); | ||
406 | |||
407 | assemblyData.InnerText = filedata; | ||
408 | |||
409 | wrapper.AppendChild(assemblyData); | ||
410 | } | ||
411 | |||
412 | wrapper = xmldoc.CreateElement("", "ScriptStates", | ||
413 | ""); | 336 | ""); |
414 | 337 | ||
415 | rootElement.AppendChild(wrapper); | 338 | rootElement.AppendChild(wrapper); |
416 | 339 | ||
417 | foreach (KeyValuePair<UUID, string> state in states) | 340 | foreach (KeyValuePair<UUID, string> state in states) |
418 | { | 341 | { |
419 | XmlElement stateData = xmldoc.CreateElement("", "State", ""); | ||
420 | |||
421 | XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", ""); | ||
422 | stateID.Value = state.Key.ToString(); | ||
423 | stateData.Attributes.Append(stateID); | ||
424 | |||
425 | XmlDocument sdoc = new XmlDocument(); | 342 | XmlDocument sdoc = new XmlDocument(); |
426 | sdoc.LoadXml(state.Value); | 343 | sdoc.LoadXml(state.Value); |
427 | XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); | 344 | XmlNodeList rootL = sdoc.GetElementsByTagName("State"); |
428 | XmlNode rootNode = rootL[0]; | 345 | XmlNode rootNode = rootL[0]; |
429 | 346 | ||
430 | XmlNode newNode = xmldoc.ImportNode(rootNode, true); | 347 | XmlNode newNode = xmldoc.ImportNode(rootNode, true); |
431 | stateData.AppendChild(newNode); | 348 | wrapper.AppendChild(newNode); |
432 | wrapper.AppendChild(stateData); | ||
433 | } | 349 | } |
434 | 350 | ||
435 | return xmldoc.InnerXml; | 351 | return xmldoc.InnerXml; |
@@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
437 | 353 | ||
438 | public void SetState(string objXMLData, UUID RegionID) | 354 | public void SetState(string objXMLData, UUID RegionID) |
439 | { | 355 | { |
356 | m_log.Debug("SetState called with " + objXMLData); | ||
440 | if (objXMLData == String.Empty) | 357 | if (objXMLData == String.Empty) |
441 | return; | 358 | return; |
442 | 359 | ||
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 | |||
880 | return ret; | 880 | return ret; |
881 | } | 881 | } |
882 | 882 | ||
883 | public string[] GetScriptAssemblies() | ||
884 | { | ||
885 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
886 | |||
887 | List<string> ret = new List<string>(); | ||
888 | if (engines == null) // No engine at all | ||
889 | return new string[0]; | ||
890 | |||
891 | foreach (TaskInventoryItem item in m_items.Values) | ||
892 | { | ||
893 | if (item.InvType == (int)InventoryType.LSL) | ||
894 | { | ||
895 | foreach (IScriptModule e in engines) | ||
896 | { | ||
897 | if (e != null) | ||
898 | { | ||
899 | string n = e.GetAssemblyName(item.ItemID); | ||
900 | if (n != String.Empty) | ||
901 | { | ||
902 | if (!ret.Contains(n)) | ||
903 | ret.Add(n); | ||
904 | break; | ||
905 | } | ||
906 | } | ||
907 | } | ||
908 | } | ||
909 | } | ||
910 | return ret.ToArray(); | ||
911 | } | ||
912 | |||
913 | public Dictionary<UUID, string> GetScriptStates() | 883 | public Dictionary<UUID, string> GetScriptStates() |
914 | { | 884 | { |
915 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 885 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
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 | |||
1248 | } | 1248 | } |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | public string GetAssemblyName(UUID itemID) | ||
1252 | { | ||
1253 | IScriptInstance instance = GetInstance(itemID); | ||
1254 | if (instance == null) | ||
1255 | return ""; | ||
1256 | return instance.GetAssemblyName(); | ||
1257 | } | ||
1258 | |||
1259 | public string GetXMLState(UUID itemID) | 1251 | public string GetXMLState(UUID itemID) |
1260 | { | 1252 | { |
1261 | IScriptInstance instance = GetInstance(itemID); | 1253 | IScriptInstance instance = GetInstance(itemID); |
1262 | if (instance == null) | 1254 | if (instance == null) |
1263 | return ""; | 1255 | return ""; |
1264 | return instance.GetXMLState(); | 1256 | string xml = instance.GetXMLState(); |
1257 | |||
1258 | XmlDocument sdoc = new XmlDocument(); | ||
1259 | sdoc.LoadXml(xml); | ||
1260 | XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); | ||
1261 | XmlNode rootNode = rootL[0]; | ||
1262 | |||
1263 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> | ||
1264 | XmlDocument doc = new XmlDocument(); | ||
1265 | XmlElement stateData = doc.CreateElement("", "State", ""); | ||
1266 | XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); | ||
1267 | stateID.Value = itemID.ToString(); | ||
1268 | stateData.Attributes.Append(stateID); | ||
1269 | XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); | ||
1270 | assetID.Value = instance.AssetID.ToString(); | ||
1271 | stateData.Attributes.Append(assetID); | ||
1272 | doc.AppendChild(stateData); | ||
1273 | |||
1274 | // Add <ScriptState>...</ScriptState> | ||
1275 | XmlNode xmlstate = doc.ImportNode(rootNode, true); | ||
1276 | stateData.AppendChild(xmlstate); | ||
1277 | |||
1278 | string assemName = instance.GetAssemblyName(); | ||
1279 | |||
1280 | string fn = Path.GetFileName(assemName); | ||
1281 | |||
1282 | string assem = String.Empty; | ||
1283 | |||
1284 | if (File.Exists(assemName + ".text")) | ||
1285 | { | ||
1286 | FileInfo tfi = new FileInfo(assemName + ".text"); | ||
1287 | |||
1288 | if (tfi != null) | ||
1289 | { | ||
1290 | Byte[] tdata = new Byte[tfi.Length]; | ||
1291 | |||
1292 | try | ||
1293 | { | ||
1294 | FileStream tfs = File.Open(assemName + ".text", | ||
1295 | FileMode.Open, FileAccess.Read); | ||
1296 | tfs.Read(tdata, 0, tdata.Length); | ||
1297 | tfs.Close(); | ||
1298 | |||
1299 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | ||
1300 | } | ||
1301 | catch (Exception e) | ||
1302 | { | ||
1303 | m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); | ||
1304 | } | ||
1305 | } | ||
1306 | } | ||
1307 | else | ||
1308 | { | ||
1309 | FileInfo fi = new FileInfo(assemName); | ||
1310 | |||
1311 | if (fi != null) | ||
1312 | { | ||
1313 | Byte[] data = new Byte[fi.Length]; | ||
1314 | |||
1315 | try | ||
1316 | { | ||
1317 | FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); | ||
1318 | fs.Read(data, 0, data.Length); | ||
1319 | fs.Close(); | ||
1320 | |||
1321 | assem = System.Convert.ToBase64String(data); | ||
1322 | } | ||
1323 | catch (Exception e) | ||
1324 | { | ||
1325 | m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); | ||
1326 | } | ||
1327 | |||
1328 | } | ||
1329 | } | ||
1330 | |||
1331 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | ||
1332 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); | ||
1333 | |||
1334 | assemblyName.Value = fn; | ||
1335 | assemblyData.Attributes.Append(assemblyName); | ||
1336 | |||
1337 | assemblyData.InnerText = assem; | ||
1338 | |||
1339 | stateData.AppendChild(assemblyData); | ||
1340 | |||
1341 | return doc.InnerXml; | ||
1265 | } | 1342 | } |
1266 | 1343 | ||
1267 | public bool CanBeDeleted(UUID itemID) | 1344 | public bool CanBeDeleted(UUID itemID) |