aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs6
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs93
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs30
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs95
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 {
356m_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 f4ca877..7f49ced 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -857,36 +857,6 @@ namespace OpenSim.Region.Framework.Scenes
857 return ret; 857 return ret;
858 } 858 }
859 859
860 public string[] GetScriptAssemblies()
861 {
862 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
863
864 List<string> ret = new List<string>();
865 if (engines == null) // No engine at all
866 return new string[0];
867
868 foreach (TaskInventoryItem item in m_items.Values)
869 {
870 if (item.InvType == (int)InventoryType.LSL)
871 {
872 foreach (IScriptModule e in engines)
873 {
874 if (e != null)
875 {
876 string n = e.GetAssemblyName(item.ItemID);
877 if (n != String.Empty)
878 {
879 if (!ret.Contains(n))
880 ret.Add(n);
881 break;
882 }
883 }
884 }
885 }
886 }
887 return ret.ToArray();
888 }
889
890 public Dictionary<UUID, string> GetScriptStates() 860 public Dictionary<UUID, string> GetScriptStates()
891 { 861 {
892 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 862 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 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)