aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetServerBase.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs176
1 files changed, 92 insertions, 84 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 7073000..858019f 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -22,78 +22,27 @@ namespace OpenSim.Framework.Communications.Cache
22 protected abstract void StoreAsset(AssetBase asset); 22 protected abstract void StoreAsset(AssetBase asset);
23 protected abstract void CommitAssets(); 23 protected abstract void CommitAssets();
24 24
25 protected abstract void RunRequests();
26
25 public void LoadDefaultAssets() 27 public void LoadDefaultAssets()
26 { 28 {
27 MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); 29 MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database");
28 30
29 ForEachDefaultAsset( this, StoreAsset ); 31 ForEachDefaultAsset(StoreAsset );
30 ForEachXmlAsset( this, StoreAsset ); 32 ForEachXmlAsset(StoreAsset );
31 33
32 CommitAssets(); 34 CommitAssets();
33 } 35 }
34 36
35 37
36 public static AssetBase CreateAsset(IAssetServer assetServer, string assetIdStr, string name, string filename, bool isImage)
37 {
38 AssetBase asset = new AssetBase(
39 new LLUUID(assetIdStr),
40 name
41 );
42
43 if (!String.IsNullOrEmpty(filename))
44 {
45 MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename );
46
47 assetServer.LoadAsset(asset, isImage, filename);
48 }
49 else
50 {
51 MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name );
52 }
53
54 return asset;
55 }
56
57 private static AssetBase CreateImageAsset(IAssetServer assetServer, string assetIdStr, string name, string filename)
58 {
59 return CreateAsset(assetServer, assetIdStr, name, filename, true);
60 }
61
62 public static List<AssetBase> GetDefaultAssets(IAssetServer assetServer)
63 {
64 List<AssetBase> assets = new List<AssetBase>();
65
66 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2"));
67 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2"));
68 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2"));
69 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2"));
70 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2"));
71 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2"));
72 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2"));
73 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2"));
74 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2"));
75 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2"));
76 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2"));
77 assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2"));
78
79 assets.Add(CreateAsset(assetServer, "77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false));
80 assets.Add(CreateAsset(assetServer, "66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false));
81 assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false));
82 assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false));
83
84 return assets;
85 }
86
87 public static void ForEachDefaultAsset(IAssetServer assetServer, Action<AssetBase> action)
88 {
89 List<AssetBase> assets = GetDefaultAssets(assetServer);
90 assets.ForEach(action);
91 }
92
93 public AssetServerBase() 38 public AssetServerBase()
94 { 39 {
95 System.Console.WriteLine("Starting Db4o asset storage system"); 40 System.Console.WriteLine("Starting Db4o asset storage system");
96 this._assetRequests = new BlockingQueue<ARequest>(); 41 this._assetRequests = new BlockingQueue<ARequest>();
42
43 this._localAssetServerThread = new Thread( RunRequests );
44 this._localAssetServerThread.IsBackground = true;
45 this._localAssetServerThread.Start();
97 } 46 }
98 47
99 public void LoadAsset(AssetBase info, bool image, string filename) 48 public void LoadAsset(AssetBase info, bool image, string filename)
@@ -115,30 +64,6 @@ namespace OpenSim.Framework.Communications.Cache
115 //info.loaded=true; 64 //info.loaded=true;
116 } 65 }
117 66
118 public static void ForEachXmlAsset(IAssetServer assetServer, Action<AssetBase> action)
119 {
120 string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml");
121 if (File.Exists(filePath))
122 {
123 XmlConfigSource source = new XmlConfigSource(filePath);
124
125 for (int i = 0; i < source.Configs.Count; i++)
126 {
127 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
128 string name = source.Configs[i].GetString("name", "");
129 sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0);
130 sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0);
131 string fileName = source.Configs[i].GetString("fileName", "");
132
133 AssetBase newAsset = CreateAsset(assetServer, assetIdStr, name, fileName, false);
134
135 newAsset.Type = type;
136 newAsset.InvType = invType;
137
138 }
139 }
140 }
141
142 public void SetReceiver(IAssetReceiver receiver) 67 public void SetReceiver(IAssetReceiver receiver)
143 { 68 {
144 this._receiver = receiver; 69 this._receiver = receiver;
@@ -170,11 +95,94 @@ namespace OpenSim.Framework.Communications.Cache
170 } 95 }
171 } 96 }
172 97
98 public virtual void Close()
99 {
100 _localAssetServerThread.Abort( );
101 }
102
173 public void SetServerInfo(string ServerUrl, string ServerKey) 103 public void SetServerInfo(string ServerUrl, string ServerKey)
174 { 104 {
175 105
176 } 106 }
177 107
178 public abstract void Close(); 108 public virtual List<AssetBase> GetDefaultAssets()
109 {
110 List<AssetBase> assets = new List<AssetBase>();
111
112 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2"));
113 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2"));
114 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2"));
115 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2"));
116 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2"));
117 assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2"));
118 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2"));
119 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2"));
120 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2"));
121 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2"));
122 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2"));
123
124 assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false));
125 assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false));
126 assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false));
127 assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false));
128
129 return assets;
130 }
131
132 public AssetBase CreateImageAsset(string assetIdStr, string name, string filename)
133 {
134 return CreateAsset(assetIdStr, name, filename, true);
135 }
136
137 public void ForEachDefaultAsset(Action<AssetBase> action)
138 {
139 List<AssetBase> assets = GetDefaultAssets();
140 assets.ForEach(action);
141 }
142
143 public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage)
144 {
145 AssetBase asset = new AssetBase(
146 new LLUUID(assetIdStr),
147 name
148 );
149
150 if (!String.IsNullOrEmpty(filename))
151 {
152 MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename );
153
154 LoadAsset(asset, isImage, filename);
155 }
156 else
157 {
158 MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name );
159 }
160
161 return asset;
162 }
163
164 public void ForEachXmlAsset(Action<AssetBase> action)
165 {
166 string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml");
167 if (File.Exists(filePath))
168 {
169 XmlConfigSource source = new XmlConfigSource(filePath);
170
171 for (int i = 0; i < source.Configs.Count; i++)
172 {
173 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
174 string name = source.Configs[i].GetString("name", "");
175 sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0);
176 sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0);
177 string fileName = source.Configs[i].GetString("fileName", "");
178
179 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
180
181 newAsset.Type = type;
182 newAsset.InvType = invType;
183
184 }
185 }
186 }
179 } 187 }
180} \ No newline at end of file 188} \ No newline at end of file