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