aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-11-09 17:36:28 +0000
committerJustin Clark-Casey (justincc)2009-11-09 17:36:28 +0000
commit7f5d0a6735585d47e081cb0b717de46d5e23260d (patch)
treed463176be6e07c4bb6948f428958fe7452866758 /OpenSim/Framework
parentrefactor out iar escaping (diff)
parentremove the debug stuff (diff)
downloadopensim-SC_OLD-7f5d0a6735585d47e081cb0b717de46d5e23260d.zip
opensim-SC_OLD-7f5d0a6735585d47e081cb0b717de46d5e23260d.tar.gz
opensim-SC_OLD-7f5d0a6735585d47e081cb0b717de46d5e23260d.tar.bz2
opensim-SC_OLD-7f5d0a6735585d47e081cb0b717de46d5e23260d.tar.xz
Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AssetBase.cs50
-rw-r--r--OpenSim/Framework/AssetLandmark.cs4
-rw-r--r--OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs21
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs5
-rw-r--r--OpenSim/Framework/Tests/AssetBaseTest.cs3
5 files changed, 59 insertions, 24 deletions
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs
index 9679ff2..212f41d 100644
--- a/OpenSim/Framework/AssetBase.cs
+++ b/OpenSim/Framework/AssetBase.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Xml.Serialization; 29using System.Xml.Serialization;
30using System.Reflection;
31using log4net;
30using OpenMetaverse; 32using OpenMetaverse;
31 33
32namespace OpenSim.Framework 34namespace OpenSim.Framework
@@ -37,6 +39,8 @@ namespace OpenSim.Framework
37 [Serializable] 39 [Serializable]
38 public class AssetBase 40 public class AssetBase
39 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
40 /// <summary> 44 /// <summary>
41 /// Data of the Asset 45 /// Data of the Asset
42 /// </summary> 46 /// </summary>
@@ -47,16 +51,44 @@ namespace OpenSim.Framework
47 /// </summary> 51 /// </summary>
48 private AssetMetadata m_metadata; 52 private AssetMetadata m_metadata;
49 53
54 // This is needed for .NET serialization!!!
55 // Do NOT "Optimize" away!
50 public AssetBase() 56 public AssetBase()
51 { 57 {
52 m_metadata = new AssetMetadata(); 58 m_metadata = new AssetMetadata();
59 m_metadata.FullID = UUID.Zero;
60 m_metadata.ID = UUID.Zero.ToString();
61 m_metadata.Type = (sbyte)AssetType.Unknown;
53 } 62 }
54 63
55 public AssetBase(UUID assetId, string name) 64 public AssetBase(UUID assetID, string name, sbyte assetType)
56 { 65 {
66 if (assetType == (sbyte)AssetType.Unknown)
67 {
68 System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true);
69 m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}",
70 name, assetID, trace.ToString());
71 }
72
57 m_metadata = new AssetMetadata(); 73 m_metadata = new AssetMetadata();
58 m_metadata.FullID = assetId; 74 m_metadata.FullID = assetID;
59 m_metadata.Name = name; 75 m_metadata.Name = name;
76 m_metadata.Type = assetType;
77 }
78
79 public AssetBase(string assetID, string name, sbyte assetType)
80 {
81 if (assetType == (sbyte)AssetType.Unknown)
82 {
83 System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true);
84 m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}",
85 name, assetID, trace.ToString());
86 }
87
88 m_metadata = new AssetMetadata();
89 m_metadata.ID = assetID;
90 m_metadata.Name = name;
91 m_metadata.Type = assetType;
60 } 92 }
61 93
62 public bool ContainsReferences 94 public bool ContainsReferences
@@ -193,11 +225,11 @@ namespace OpenSim.Framework
193 private string m_name = String.Empty; 225 private string m_name = String.Empty;
194 private string m_description = String.Empty; 226 private string m_description = String.Empty;
195 private DateTime m_creation_date; 227 private DateTime m_creation_date;
196 private sbyte m_type; 228 private sbyte m_type = (sbyte)AssetType.Unknown;
197 private string m_content_type; 229 private string m_content_type;
198 private byte[] m_sha1; 230 private byte[] m_sha1;
199 private bool m_local = false; 231 private bool m_local;
200 private bool m_temporary = false; 232 private bool m_temporary;
201 //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>(); 233 //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>();
202 //private OSDMap m_extra_data; 234 //private OSDMap m_extra_data;
203 235
@@ -211,7 +243,13 @@ namespace OpenSim.Framework
211 { 243 {
212 //get { return m_fullid.ToString(); } 244 //get { return m_fullid.ToString(); }
213 //set { m_fullid = new UUID(value); } 245 //set { m_fullid = new UUID(value); }
214 get { return m_id; } 246 get
247 {
248 if (String.IsNullOrEmpty(m_id))
249 m_id = m_fullid.ToString();
250
251 return m_id;
252 }
215 set 253 set
216 { 254 {
217 UUID uuid = UUID.Zero; 255 UUID uuid = UUID.Zero;
diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs
index fd7a2cd..058b442 100644
--- a/OpenSim/Framework/AssetLandmark.cs
+++ b/OpenSim/Framework/AssetLandmark.cs
@@ -38,11 +38,9 @@ namespace OpenSim.Framework
38 public int Version; 38 public int Version;
39 39
40 public AssetLandmark(AssetBase a) 40 public AssetLandmark(AssetBase a)
41 : base(a.FullID, a.Name, a.Type)
41 { 42 {
42 Data = a.Data; 43 Data = a.Data;
43 FullID = a.FullID;
44 Type = a.Type;
45 Name = a.Name;
46 Description = a.Description; 44 Description = a.Description;
47 InternData(); 45 InternData();
48 } 46 }
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
index a394b1a..9497a2e 100644
--- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
+++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
@@ -43,18 +43,15 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 protected static AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage) 46 protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type)
47 { 47 {
48 AssetBase asset = new AssetBase( 48 AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type);
49 new UUID(assetIdStr),
50 name
51 );
52 49
53 if (!String.IsNullOrEmpty(path)) 50 if (!String.IsNullOrEmpty(path))
54 { 51 {
55 //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path); 52 //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path);
56 53
57 LoadAsset(asset, isImage, path); 54 LoadAsset(asset, path);
58 } 55 }
59 else 56 else
60 { 57 {
@@ -64,8 +61,14 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
64 return asset; 61 return asset;
65 } 62 }
66 63
67 protected static void LoadAsset(AssetBase info, bool image, string path) 64 protected static void LoadAsset(AssetBase info, string path)
68 { 65 {
66 bool image =
67 (info.Type == (sbyte)AssetType.Texture ||
68 info.Type == (sbyte)AssetType.TextureTGA ||
69 info.Type == (sbyte)AssetType.ImageJPEG ||
70 info.Type == (sbyte)AssetType.ImageTGA);
71
69 FileInfo fInfo = new FileInfo(path); 72 FileInfo fInfo = new FileInfo(path);
70 long numBytes = fInfo.Length; 73 long numBytes = fInfo.Length;
71 if (fInfo.Exists) 74 if (fInfo.Exists)
@@ -138,10 +141,10 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
138 { 141 {
139 string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString()); 142 string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString());
140 string name = source.Configs[i].GetString("name", String.Empty); 143 string name = source.Configs[i].GetString("name", String.Empty);
141 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); 144 sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0);
142 string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty)); 145 string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty));
143 146
144 AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false); 147 AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, type);
145 148
146 newAsset.Type = type; 149 newAsset.Type = type;
147 assets.Add(newAsset); 150 assets.Add(newAsset);
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index ccfe800..72231ca 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -888,10 +888,7 @@ namespace OpenSim.Framework.Capabilities
888 } 888 }
889 889
890 AssetBase asset; 890 AssetBase asset;
891 asset = new AssetBase(); 891 asset = new AssetBase(assetID, assetName, assType);
892 asset.FullID = assetID;
893 asset.Type = assType;
894 asset.Name = assetName;
895 asset.Data = data; 892 asset.Data = data;
896 if (AddNewAsset != null) 893 if (AddNewAsset != null)
897 AddNewAsset(asset); 894 AddNewAsset(asset);
diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs
index 3dc6b4e..18a3e01 100644
--- a/OpenSim/Framework/Tests/AssetBaseTest.cs
+++ b/OpenSim/Framework/Tests/AssetBaseTest.cs
@@ -67,8 +67,7 @@ namespace OpenSim.Framework.Tests
67 67
68 private void CheckContainsReferences(AssetType assetType, bool expected) 68 private void CheckContainsReferences(AssetType assetType, bool expected)
69 { 69 {
70 AssetBase asset = new AssetBase(); 70 AssetBase asset = new AssetBase(UUID.Zero, String.Empty, (sbyte)assetType);
71 asset.Type = (sbyte)assetType;
72 bool actual = asset.ContainsReferences; 71 bool actual = asset.ContainsReferences;
73 Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); 72 Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+".");
74 } 73 }