diff options
Deleted a few old files that are no longer used.
Deleted the GridInterfaces projects, and for now moved the old local asset server into Framework.Communications, as we prepare to rewrite the asset cache and asset server.
Deleted Framework.manager as I am sure this is no longer in use.
Diffstat (limited to 'OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs')
-rw-r--r-- | OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs | 403 |
1 files changed, 0 insertions, 403 deletions
diff --git a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs deleted file mode 100644 index 835212e..0000000 --- a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs +++ /dev/null | |||
@@ -1,403 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Threading; | ||
31 | using Db4objects.Db4o; | ||
32 | using Db4objects.Db4o.Query; | ||
33 | using libsecondlife; | ||
34 | using Nini.Config; | ||
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Framework.Interfaces; | ||
37 | using OpenSim.Framework.Types; | ||
38 | using OpenSim.Framework.Utilities; | ||
39 | |||
40 | namespace OpenSim.Region.GridInterfaces.Local | ||
41 | { | ||
42 | public class LocalAssetPlugin : IAssetPlugin | ||
43 | { | ||
44 | public LocalAssetPlugin() | ||
45 | { | ||
46 | |||
47 | } | ||
48 | |||
49 | public IAssetServer GetAssetServer() | ||
50 | { | ||
51 | return (new LocalAssetServer()); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | public class LocalAssetServer : IAssetServer | ||
56 | { | ||
57 | private IAssetReceiver _receiver; | ||
58 | private BlockingQueue<ARequest> _assetRequests; | ||
59 | private IObjectContainer db; | ||
60 | private Thread _localAssetServerThread; | ||
61 | |||
62 | public LocalAssetServer() | ||
63 | { | ||
64 | bool yapfile; | ||
65 | this._assetRequests = new BlockingQueue<ARequest>(); | ||
66 | yapfile = File.Exists(Path.Combine(Util.dataDir(),"regionassets.yap")); | ||
67 | |||
68 | MainLog.Instance.Verbose("Local Asset Server class created"); | ||
69 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(),"regionassets.yap")); | ||
70 | MainLog.Instance.Verbose("Db4 Asset database creation"); | ||
71 | |||
72 | if (!yapfile) | ||
73 | { | ||
74 | this.SetUpAssetDatabase(); | ||
75 | } | ||
76 | |||
77 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); | ||
78 | this._localAssetServerThread.IsBackground = true; | ||
79 | this._localAssetServerThread.Start(); | ||
80 | |||
81 | } | ||
82 | |||
83 | public void SetReceiver(IAssetReceiver receiver) | ||
84 | { | ||
85 | this._receiver = receiver; | ||
86 | } | ||
87 | |||
88 | public void RequestAsset(LLUUID assetID, bool isTexture) | ||
89 | { | ||
90 | ARequest req = new ARequest(); | ||
91 | req.AssetID = assetID; | ||
92 | req.IsTexture = isTexture; | ||
93 | this._assetRequests.Enqueue(req); | ||
94 | } | ||
95 | |||
96 | public void UpdateAsset(AssetBase asset) | ||
97 | { | ||
98 | |||
99 | } | ||
100 | |||
101 | public void UploadNewAsset(AssetBase asset) | ||
102 | { | ||
103 | AssetStorage store = new AssetStorage(); | ||
104 | store.Data = asset.Data; | ||
105 | store.Name = asset.Name; | ||
106 | store.UUID = asset.FullID; | ||
107 | db.Set(store); | ||
108 | db.Commit(); | ||
109 | } | ||
110 | |||
111 | public void SetServerInfo(string ServerUrl, string ServerKey) | ||
112 | { | ||
113 | |||
114 | } | ||
115 | public void Close() | ||
116 | { | ||
117 | if (db != null) | ||
118 | { | ||
119 | MainLog.Instance.Verbose("Closing local asset server database"); | ||
120 | db.Close(); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | private void RunRequests() | ||
125 | { | ||
126 | while (true) | ||
127 | { | ||
128 | byte[] idata = null; | ||
129 | bool found = false; | ||
130 | AssetStorage foundAsset = null; | ||
131 | ARequest req = this._assetRequests.Dequeue(); | ||
132 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); | ||
133 | if (result.Count > 0) | ||
134 | { | ||
135 | foundAsset = (AssetStorage)result.Next(); | ||
136 | found = true; | ||
137 | } | ||
138 | |||
139 | AssetBase asset = new AssetBase(); | ||
140 | if (found) | ||
141 | { | ||
142 | asset.FullID = foundAsset.UUID; | ||
143 | asset.Type = foundAsset.Type; | ||
144 | asset.InvType = foundAsset.Type; | ||
145 | asset.Name = foundAsset.Name; | ||
146 | idata = foundAsset.Data; | ||
147 | asset.Data = idata; | ||
148 | _receiver.AssetReceived(asset, req.IsTexture); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | //asset.FullID = ; | ||
153 | _receiver.AssetNotFound(req.AssetID); | ||
154 | } | ||
155 | |||
156 | } | ||
157 | |||
158 | } | ||
159 | |||
160 | private void SetUpAssetDatabase() | ||
161 | { | ||
162 | MainLog.Instance.Verbose("Setting up asset database"); | ||
163 | |||
164 | AssetBase Image = new AssetBase(); | ||
165 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); | ||
166 | Image.Name = "Bricks"; | ||
167 | this.LoadAsset(Image, true, "bricks.jp2"); | ||
168 | AssetStorage store = new AssetStorage(); | ||
169 | store.Data = Image.Data; | ||
170 | store.Name = Image.Name; | ||
171 | store.UUID = Image.FullID; | ||
172 | db.Set(store); | ||
173 | db.Commit(); | ||
174 | |||
175 | Image = new AssetBase(); | ||
176 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); | ||
177 | Image.Name = "Plywood"; | ||
178 | this.LoadAsset(Image, true, "plywood.jp2"); | ||
179 | store = new AssetStorage(); | ||
180 | store.Data = Image.Data; | ||
181 | store.Name = Image.Name; | ||
182 | store.UUID = Image.FullID; | ||
183 | db.Set(store); | ||
184 | db.Commit(); | ||
185 | |||
186 | Image = new AssetBase(); | ||
187 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); | ||
188 | Image.Name = "Rocks"; | ||
189 | this.LoadAsset(Image, true, "rocks.jp2"); | ||
190 | store = new AssetStorage(); | ||
191 | store.Data = Image.Data; | ||
192 | store.Name = Image.Name; | ||
193 | store.UUID = Image.FullID; | ||
194 | db.Set(store); | ||
195 | db.Commit(); | ||
196 | |||
197 | Image = new AssetBase(); | ||
198 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); | ||
199 | Image.Name = "Granite"; | ||
200 | this.LoadAsset(Image, true, "granite.jp2"); | ||
201 | store = new AssetStorage(); | ||
202 | store.Data = Image.Data; | ||
203 | store.Name = Image.Name; | ||
204 | store.UUID = Image.FullID; | ||
205 | db.Set(store); | ||
206 | db.Commit(); | ||
207 | |||
208 | Image = new AssetBase(); | ||
209 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); | ||
210 | Image.Name = "Hardwood"; | ||
211 | this.LoadAsset(Image, true, "hardwood.jp2"); | ||
212 | store = new AssetStorage(); | ||
213 | store.Data = Image.Data; | ||
214 | store.Name = Image.Name; | ||
215 | store.UUID = Image.FullID; | ||
216 | db.Set(store); | ||
217 | db.Commit(); | ||
218 | |||
219 | Image = new AssetBase(); | ||
220 | Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); | ||
221 | Image.Name = "Prim Base Texture"; | ||
222 | this.LoadAsset(Image, true, "plywood.jp2"); | ||
223 | store = new AssetStorage(); | ||
224 | store.Data = Image.Data; | ||
225 | store.Name = Image.Name; | ||
226 | store.UUID = Image.FullID; | ||
227 | db.Set(store); | ||
228 | db.Commit(); | ||
229 | |||
230 | Image = new AssetBase(); | ||
231 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); | ||
232 | Image.Name = "Map Base Texture"; | ||
233 | this.LoadAsset(Image, true, "map_base.jp2"); | ||
234 | store = new AssetStorage(); | ||
235 | store.Data = Image.Data; | ||
236 | store.Name = Image.Name; | ||
237 | store.UUID = Image.FullID; | ||
238 | db.Set(store); | ||
239 | db.Commit(); | ||
240 | |||
241 | Image = new AssetBase(); | ||
242 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); | ||
243 | Image.Name = "Map Texture"; | ||
244 | this.LoadAsset(Image, true, "map1.jp2"); | ||
245 | store = new AssetStorage(); | ||
246 | store.Data = Image.Data; | ||
247 | store.Name = Image.Name; | ||
248 | store.UUID = Image.FullID; | ||
249 | db.Set(store); | ||
250 | db.Commit(); | ||
251 | |||
252 | Image = new AssetBase(); | ||
253 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); | ||
254 | Image.Name = "Female Body Texture"; | ||
255 | this.LoadAsset(Image, true, "femalebody.jp2"); | ||
256 | store = new AssetStorage(); | ||
257 | store.Data = Image.Data; | ||
258 | store.Name = Image.Name; | ||
259 | store.UUID = Image.FullID; | ||
260 | db.Set(store); | ||
261 | db.Commit(); | ||
262 | |||
263 | Image = new AssetBase(); | ||
264 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); | ||
265 | Image.Name = "Female Bottom Texture"; | ||
266 | this.LoadAsset(Image, true, "femalebottom.jp2"); | ||
267 | store = new AssetStorage(); | ||
268 | store.Data = Image.Data; | ||
269 | store.Name = Image.Name; | ||
270 | store.UUID = Image.FullID; | ||
271 | db.Set(store); | ||
272 | db.Commit(); | ||
273 | |||
274 | Image = new AssetBase(); | ||
275 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); | ||
276 | Image.Name = "Female Face Texture"; | ||
277 | this.LoadAsset(Image, true, "femaleface.jp2"); | ||
278 | store = new AssetStorage(); | ||
279 | store.Data = Image.Data; | ||
280 | store.Name = Image.Name; | ||
281 | store.UUID = Image.FullID; | ||
282 | db.Set(store); | ||
283 | db.Commit(); | ||
284 | |||
285 | Image = new AssetBase(); | ||
286 | Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | ||
287 | Image.Name = "Skin"; | ||
288 | Image.Type = 13; | ||
289 | Image.InvType = 13; | ||
290 | this.LoadAsset(Image, false, "base_skin.dat"); | ||
291 | store = new AssetStorage(); | ||
292 | store.Data = Image.Data; | ||
293 | store.Name = Image.Name; | ||
294 | store.UUID = Image.FullID; | ||
295 | db.Set(store); | ||
296 | db.Commit(); | ||
297 | |||
298 | |||
299 | Image = new AssetBase(); | ||
300 | Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
301 | Image.Name = "Shape"; | ||
302 | Image.Type = 13; | ||
303 | Image.InvType = 13; | ||
304 | this.LoadAsset(Image, false, "base_shape.dat"); | ||
305 | store = new AssetStorage(); | ||
306 | store.Data = Image.Data; | ||
307 | store.Name = Image.Name; | ||
308 | store.UUID = Image.FullID; | ||
309 | db.Set(store); | ||
310 | db.Commit(); | ||
311 | |||
312 | Image = new AssetBase(); | ||
313 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); | ||
314 | Image.Name = "Shirt"; | ||
315 | Image.Type = 5; | ||
316 | Image.InvType = 18; | ||
317 | this.LoadAsset(Image, false, "newshirt.dat"); | ||
318 | store = new AssetStorage(); | ||
319 | store.Data = Image.Data; | ||
320 | store.Name = Image.Name; | ||
321 | store.UUID = Image.FullID; | ||
322 | db.Set(store); | ||
323 | db.Commit(); | ||
324 | |||
325 | Image = new AssetBase(); | ||
326 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); | ||
327 | Image.Name = "Shirt"; | ||
328 | Image.Type = 5; | ||
329 | Image.InvType = 18; | ||
330 | this.LoadAsset(Image, false, "newpants.dat"); | ||
331 | store = new AssetStorage(); | ||
332 | store.Data = Image.Data; | ||
333 | store.Name = Image.Name; | ||
334 | store.UUID = Image.FullID; | ||
335 | db.Set(store); | ||
336 | db.Commit(); | ||
337 | |||
338 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | ||
339 | if(File.Exists(filePath)) | ||
340 | { | ||
341 | XmlConfigSource source = new XmlConfigSource(filePath); | ||
342 | ReadAssetDetails(source); | ||
343 | } | ||
344 | } | ||
345 | |||
346 | protected void ReadAssetDetails(IConfigSource source) | ||
347 | { | ||
348 | AssetBase newAsset = null; | ||
349 | for (int i = 0; i < source.Configs.Count; i++) | ||
350 | { | ||
351 | newAsset = new AssetBase(); | ||
352 | newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); | ||
353 | newAsset.Name = source.Configs[i].GetString("name", ""); | ||
354 | newAsset.Type =(sbyte) source.Configs[i].GetInt("assetType", 0); | ||
355 | newAsset.InvType =(sbyte) source.Configs[i].GetInt("inventoryType", 0); | ||
356 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
357 | if (fileName != "") | ||
358 | { | ||
359 | this.LoadAsset(newAsset, false, fileName); | ||
360 | AssetStorage store = new AssetStorage(); | ||
361 | store.Data = newAsset.Data; | ||
362 | store.Name = newAsset.Name; | ||
363 | store.UUID = newAsset.FullID; | ||
364 | db.Set(store); | ||
365 | db.Commit(); | ||
366 | } | ||
367 | } | ||
368 | } | ||
369 | |||
370 | private void LoadAsset(AssetBase info, bool image, string filename) | ||
371 | { | ||
372 | //should request Asset from storage manager | ||
373 | //but for now read from file | ||
374 | |||
375 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; | ||
376 | string fileName = Path.Combine(dataPath, filename); | ||
377 | FileInfo fInfo = new FileInfo(fileName); | ||
378 | long numBytes = fInfo.Length; | ||
379 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); | ||
380 | byte[] idata = new byte[numBytes]; | ||
381 | BinaryReader br = new BinaryReader(fStream); | ||
382 | idata = br.ReadBytes((int)numBytes); | ||
383 | br.Close(); | ||
384 | fStream.Close(); | ||
385 | info.Data = idata; | ||
386 | //info.loaded=true; | ||
387 | } | ||
388 | } | ||
389 | public class AssetUUIDQuery : Predicate | ||
390 | { | ||
391 | private LLUUID _findID; | ||
392 | |||
393 | public AssetUUIDQuery(LLUUID find) | ||
394 | { | ||
395 | _findID = find; | ||
396 | } | ||
397 | public bool Match(AssetStorage asset) | ||
398 | { | ||
399 | return (asset.UUID == _findID); | ||
400 | } | ||
401 | } | ||
402 | |||
403 | } | ||