aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Communications/Cache
parent* Deleted .user file (diff)
downloadopensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs207
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServer.cs24
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs26
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs37
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactions.cs199
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs37
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs21
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolder.cs41
-rw-r--r--OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs82
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs21
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCache.cs72
11 files changed, 362 insertions, 405 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 39e2887..ca2fc35 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -29,12 +29,9 @@
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection;
33using System.Threading; 32using System.Threading;
34using libsecondlife; 33using libsecondlife;
35using libsecondlife.Packets; 34using libsecondlife.Packets;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework;
38using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
39 36
40namespace OpenSim.Framework.Communications.Cache 37namespace OpenSim.Framework.Communications.Cache
@@ -51,18 +48,22 @@ namespace OpenSim.Framework.Communications.Cache
51 public Dictionary<LLUUID, AssetInfo> Assets; 48 public Dictionary<LLUUID, AssetInfo> Assets;
52 public Dictionary<LLUUID, TextureImage> Textures; 49 public Dictionary<LLUUID, TextureImage> Textures;
53 50
54 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers 51 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
55 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent 52 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent
56 53
57 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server 54 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>();
58 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server 55 //Assets requested from the asset server
56
57 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>();
58 //Textures requested from the asset server
59 59
60 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>(); 60 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>();
61 private BlockingQueue<TextureSender> QueueTextures = new BlockingQueue<TextureSender>(); 61 private BlockingQueue<TextureSender> QueueTextures = new BlockingQueue<TextureSender>();
62 62
63 private Dictionary<LLUUID, List<LLUUID>> AvatarRecievedTextures = new Dictionary<LLUUID, List<LLUUID>>(); 63 private Dictionary<LLUUID, List<LLUUID>> AvatarRecievedTextures = new Dictionary<LLUUID, List<LLUUID>>();
64 64
65 private Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent = new Dictionary<LLUUID, Dictionary<LLUUID, int>>(); 65 private Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent =
66 new Dictionary<LLUUID, Dictionary<LLUUID, int>>();
66 67
67 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>(); 68 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
68 69
@@ -76,19 +77,18 @@ namespace OpenSim.Framework.Communications.Cache
76 /// </summary> 77 /// </summary>
77 public AssetCache(IAssetServer assetServer) 78 public AssetCache(IAssetServer assetServer)
78 { 79 {
79 OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache"); 80 MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache");
80 _assetServer = assetServer; 81 _assetServer = assetServer;
81 _assetServer.SetReceiver(this); 82 _assetServer.SetReceiver(this);
82 Assets = new Dictionary<LLUUID, AssetInfo>(); 83 Assets = new Dictionary<LLUUID, AssetInfo>();
83 Textures = new Dictionary<LLUUID, TextureImage>(); 84 Textures = new Dictionary<LLUUID, TextureImage>();
84 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); 85 _assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
85 this._assetCacheThread.IsBackground = true; 86 _assetCacheThread.IsBackground = true;
86 this._assetCacheThread.Start(); 87 _assetCacheThread.Start();
87
88 this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders));
89 this.TextureSenderThread.IsBackground = true;
90 this.TextureSenderThread.Start();
91 88
89 TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders));
90 TextureSenderThread.IsBackground = true;
91 TextureSenderThread.Start();
92 } 92 }
93 93
94 /// <summary> 94 /// <summary>
@@ -100,8 +100,8 @@ namespace OpenSim.Framework.Communications.Cache
100 { 100 {
101 try 101 try
102 { 102 {
103 this.ProcessAssetQueue(); 103 ProcessAssetQueue();
104 this.ProcessTextureQueue(); 104 ProcessTextureQueue();
105 Thread.Sleep(500); 105 Thread.Sleep(500);
106 } 106 }
107 catch (Exception e) 107 catch (Exception e)
@@ -115,13 +115,13 @@ namespace OpenSim.Framework.Communications.Cache
115 public AssetBase GetAsset(LLUUID assetID) 115 public AssetBase GetAsset(LLUUID assetID)
116 { 116 {
117 AssetBase asset = null; 117 AssetBase asset = null;
118 if (this.Textures.ContainsKey(assetID)) 118 if (Textures.ContainsKey(assetID))
119 { 119 {
120 asset = this.Textures[assetID]; 120 asset = Textures[assetID];
121 } 121 }
122 else if (this.Assets.ContainsKey(assetID)) 122 else if (Assets.ContainsKey(assetID))
123 { 123 {
124 asset = this.Assets[assetID]; 124 asset = Assets[assetID];
125 } 125 }
126 return asset; 126 return asset;
127 } 127 }
@@ -129,13 +129,13 @@ namespace OpenSim.Framework.Communications.Cache
129 public void GetAsset(LLUUID assetID, AssetRequestCallback callback) 129 public void GetAsset(LLUUID assetID, AssetRequestCallback callback)
130 { 130 {
131 AssetBase asset = null; 131 AssetBase asset = null;
132 if (this.Textures.ContainsKey(assetID)) 132 if (Textures.ContainsKey(assetID))
133 { 133 {
134 asset = this.Textures[assetID]; 134 asset = Textures[assetID];
135 } 135 }
136 else if (this.Assets.ContainsKey(assetID)) 136 else if (Assets.ContainsKey(assetID))
137 { 137 {
138 asset = this.Assets[assetID]; 138 asset = Assets[assetID];
139 } 139 }
140 140
141 if (asset != null) 141 if (asset != null)
@@ -145,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache
145 else 145 else
146 { 146 {
147 NewAssetRequest req = new NewAssetRequest(assetID, callback); 147 NewAssetRequest req = new NewAssetRequest(assetID, callback);
148 if (this.RequestLists.ContainsKey(assetID)) 148 if (RequestLists.ContainsKey(assetID))
149 { 149 {
150 lock (RequestLists) 150 lock (RequestLists)
151 { 151 {
@@ -161,7 +161,7 @@ namespace OpenSim.Framework.Communications.Cache
161 RequestLists.Add(assetID, reqList); 161 RequestLists.Add(assetID, reqList);
162 } 162 }
163 } 163 }
164 this._assetServer.FetchAsset(assetID, false); 164 _assetServer.FetchAsset(assetID, false);
165 } 165 }
166 } 166 }
167 167
@@ -171,22 +171,23 @@ namespace OpenSim.Framework.Communications.Cache
171 AssetBase asset = GetAsset(assetID); 171 AssetBase asset = GetAsset(assetID);
172 if (asset == null) 172 if (asset == null)
173 { 173 {
174 this._assetServer.FetchAsset(assetID, isTexture); 174 _assetServer.FetchAsset(assetID, isTexture);
175 } 175 }
176 return asset; 176 return asset;
177 } 177 }
178 178
179 public void AddAsset(AssetBase asset) 179 public void AddAsset(AssetBase asset)
180 { 180 {
181 //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); 181 //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated());
182 if (asset.Type == 0) 182 if (asset.Type == 0)
183 { 183 {
184 //Console.WriteLine("which is a texture"); 184 //Console.WriteLine("which is a texture");
185 if (!Textures.ContainsKey(asset.FullID)) 185 if (!Textures.ContainsKey(asset.FullID))
186 { //texture 186 {
187 //texture
187 TextureImage textur = new TextureImage(asset); 188 TextureImage textur = new TextureImage(asset);
188 Textures.Add(textur.FullID, textur); 189 Textures.Add(textur.FullID, textur);
189 if(!asset.Temporary) 190 if (!asset.Temporary)
190 _assetServer.StoreAndCommitAsset(asset); 191 _assetServer.StoreAndCommitAsset(asset);
191 } 192 }
192 else 193 else
@@ -219,49 +220,47 @@ namespace OpenSim.Framework.Communications.Cache
219 /// </summary> 220 /// </summary>
220 private void ProcessTextureQueue() 221 private void ProcessTextureQueue()
221 { 222 {
222 if (this.TextureRequests.Count == 0) 223 if (TextureRequests.Count == 0)
223 { 224 {
224 //no requests waiting 225 //no requests waiting
225 return; 226 return;
226 } 227 }
227 int num; 228 int num;
228 num = this.TextureRequests.Count; 229 num = TextureRequests.Count;
229 230
230 AssetRequest req; 231 AssetRequest req;
231 for (int i = 0; i < num; i++) 232 for (int i = 0; i < num; i++)
232 { 233 {
233 req = (AssetRequest)this.TextureRequests[i]; 234 req = (AssetRequest) TextureRequests[i];
234 if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) 235 if (!SendingTextures.ContainsKey(req.ImageInfo.FullID))
235 { 236 {
236 //Console.WriteLine("new texture to send"); 237 //Console.WriteLine("new texture to send");
237 TextureSender sender = new TextureSender(req); 238 TextureSender sender = new TextureSender(req);
238 //sender.OnComplete += this.TextureSent; 239 //sender.OnComplete += this.TextureSent;
239 this.SendingTextures.Add(req.ImageInfo.FullID, sender); 240 SendingTextures.Add(req.ImageInfo.FullID, sender);
240 this.QueueTextures.Enqueue(sender); 241 QueueTextures.Enqueue(sender);
241 } 242 }
242
243 } 243 }
244 244
245 this.TextureRequests.Clear(); 245 TextureRequests.Clear();
246 } 246 }
247 247
248 public void ProcessTextureSenders() 248 public void ProcessTextureSenders()
249 { 249 {
250 while (true) 250 while (true)
251 { 251 {
252 TextureSender sender = this.QueueTextures.Dequeue(); 252 TextureSender sender = QueueTextures.Dequeue();
253 253
254 bool finished = sender.SendTexture(); 254 bool finished = sender.SendTexture();
255 if (finished) 255 if (finished)
256 { 256 {
257 this.TextureSent(sender); 257 TextureSent(sender);
258 } 258 }
259 else 259 else
260 { 260 {
261 // Console.WriteLine("readding texture"); 261 // Console.WriteLine("readding texture");
262 this.QueueTextures.Enqueue(sender); 262 QueueTextures.Enqueue(sender);
263 } 263 }
264
265 } 264 }
266 } 265 }
267 266
@@ -271,16 +270,16 @@ namespace OpenSim.Framework.Communications.Cache
271 /// <param name="sender"></param> 270 /// <param name="sender"></param>
272 public void TextureSent(TextureSender sender) 271 public void TextureSent(TextureSender sender)
273 { 272 {
274 if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) 273 if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
275 { 274 {
276 this.SendingTextures.Remove(sender.request.ImageInfo.FullID); 275 SendingTextures.Remove(sender.request.ImageInfo.FullID);
277 // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); 276 // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID);
278 } 277 }
279 } 278 }
280 279
281 public void AssetReceived(AssetBase asset, bool IsTexture) 280 public void AssetReceived(AssetBase asset, bool IsTexture)
282 { 281 {
283 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server 282 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
284 { 283 {
285 //check if it is a texture or not 284 //check if it is a texture or not
286 //then add to the correct cache list 285 //then add to the correct cache list
@@ -292,48 +291,48 @@ namespace OpenSim.Framework.Communications.Cache
292 //Console.WriteLine("asset recieved from asset server"); 291 //Console.WriteLine("asset recieved from asset server");
293 292
294 TextureImage image = new TextureImage(asset); 293 TextureImage image = new TextureImage(asset);
295 if (!this.Textures.ContainsKey(image.FullID)) 294 if (!Textures.ContainsKey(image.FullID))
296 { 295 {
297 this.Textures.Add(image.FullID, image); 296 Textures.Add(image.FullID, image);
298 if (this.RequestedTextures.ContainsKey(image.FullID)) 297 if (RequestedTextures.ContainsKey(image.FullID))
299 { 298 {
300 AssetRequest req = this.RequestedTextures[image.FullID]; 299 AssetRequest req = RequestedTextures[image.FullID];
301 req.ImageInfo = image; 300 req.ImageInfo = image;
302 if (image.Data.LongLength > 600) 301 if (image.Data.LongLength > 600)
303 { 302 {
304 //over 600 bytes so split up file 303 //over 600 bytes so split up file
305 req.NumPackets = 1 + (int)(image.Data.Length - 600) / 1000; 304 req.NumPackets = 1 + (int) (image.Data.Length - 600)/1000;
306 } 305 }
307 else 306 else
308 { 307 {
309 req.NumPackets = 1; 308 req.NumPackets = 1;
310 } 309 }
311 this.RequestedTextures.Remove(image.FullID); 310 RequestedTextures.Remove(image.FullID);
312 this.TextureRequests.Add(req); 311 TextureRequests.Add(req);
313 } 312 }
314 } 313 }
315 } 314 }
316 else 315 else
317 { 316 {
318 AssetInfo assetInf = new AssetInfo(asset); 317 AssetInfo assetInf = new AssetInfo(asset);
319 if (!this.Assets.ContainsKey(assetInf.FullID)) 318 if (!Assets.ContainsKey(assetInf.FullID))
320 { 319 {
321 this.Assets.Add(assetInf.FullID, assetInf); 320 Assets.Add(assetInf.FullID, assetInf);
322 if (this.RequestedAssets.ContainsKey(assetInf.FullID)) 321 if (RequestedAssets.ContainsKey(assetInf.FullID))
323 { 322 {
324 AssetRequest req = this.RequestedAssets[assetInf.FullID]; 323 AssetRequest req = RequestedAssets[assetInf.FullID];
325 req.AssetInf = assetInf; 324 req.AssetInf = assetInf;
326 if (assetInf.Data.LongLength > 600) 325 if (assetInf.Data.LongLength > 600)
327 { 326 {
328 //over 600 bytes so split up file 327 //over 600 bytes so split up file
329 req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; 328 req.NumPackets = 1 + (int) (assetInf.Data.Length - 600 + 999)/1000;
330 } 329 }
331 else 330 else
332 { 331 {
333 req.NumPackets = 1; 332 req.NumPackets = 1;
334 } 333 }
335 this.RequestedAssets.Remove(assetInf.FullID); 334 RequestedAssets.Remove(assetInf.FullID);
336 this.AssetRequests.Add(req); 335 AssetRequests.Add(req);
337 } 336 }
338 } 337 }
339 } 338 }
@@ -345,7 +344,7 @@ namespace OpenSim.Framework.Communications.Cache
345 { 344 {
346 req.Callback(asset.FullID, asset); 345 req.Callback(asset.FullID, asset);
347 } 346 }
348 347
349 lock (RequestLists) 348 lock (RequestLists)
350 { 349 {
351 RequestLists.Remove(asset.FullID); 350 RequestLists.Remove(asset.FullID);
@@ -373,6 +372,7 @@ namespace OpenSim.Framework.Communications.Cache
373 } 372 }
374 373
375 #region Assets 374 #region Assets
375
376 /// <summary> 376 /// <summary>
377 /// 377 ///
378 /// </summary> 378 /// </summary>
@@ -396,11 +396,11 @@ namespace OpenSim.Framework.Communications.Cache
396 } 396 }
397 //check to see if asset is in local cache, if not we need to request it from asset server. 397 //check to see if asset is in local cache, if not we need to request it from asset server.
398 //Console.WriteLine("asset request " + requestID); 398 //Console.WriteLine("asset request " + requestID);
399 if (!this.Assets.ContainsKey(requestID)) 399 if (!Assets.ContainsKey(requestID))
400 { 400 {
401 //not found asset 401 //not found asset
402 // so request from asset server 402 // so request from asset server
403 if (!this.RequestedAssets.ContainsKey(requestID)) 403 if (!RequestedAssets.ContainsKey(requestID))
404 { 404 {
405 AssetRequest request = new AssetRequest(); 405 AssetRequest request = new AssetRequest();
406 request.RequestUser = userInfo; 406 request.RequestUser = userInfo;
@@ -408,13 +408,13 @@ namespace OpenSim.Framework.Communications.Cache
408 request.TransferRequestID = transferRequest.TransferInfo.TransferID; 408 request.TransferRequestID = transferRequest.TransferInfo.TransferID;
409 request.AssetRequestSource = source; 409 request.AssetRequestSource = source;
410 request.Params = transferRequest.TransferInfo.Params; 410 request.Params = transferRequest.TransferInfo.Params;
411 this.RequestedAssets.Add(requestID, request); 411 RequestedAssets.Add(requestID, request);
412 this._assetServer.FetchAsset(requestID, false); 412 _assetServer.FetchAsset(requestID, false);
413 } 413 }
414 return; 414 return;
415 } 415 }
416 //it is in our cache 416 //it is in our cache
417 AssetInfo asset = this.Assets[requestID]; 417 AssetInfo asset = Assets[requestID];
418 418
419 //work out how many packets it should be sent in 419 //work out how many packets it should be sent in
420 // and add to the AssetRequests list 420 // and add to the AssetRequests list
@@ -429,14 +429,14 @@ namespace OpenSim.Framework.Communications.Cache
429 if (asset.Data.LongLength > 600) 429 if (asset.Data.LongLength > 600)
430 { 430 {
431 //over 600 bytes so split up file 431 //over 600 bytes so split up file
432 req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; 432 req.NumPackets = 1 + (int) (asset.Data.Length - 600 + 999)/1000;
433 } 433 }
434 else 434 else
435 { 435 {
436 req.NumPackets = 1; 436 req.NumPackets = 1;
437 } 437 }
438 438
439 this.AssetRequests.Add(req); 439 AssetRequests.Add(req);
440 } 440 }
441 441
442 /// <summary> 442 /// <summary>
@@ -444,17 +444,17 @@ namespace OpenSim.Framework.Communications.Cache
444 /// </summary> 444 /// </summary>
445 private void ProcessAssetQueue() 445 private void ProcessAssetQueue()
446 { 446 {
447 if (this.AssetRequests.Count == 0) 447 if (AssetRequests.Count == 0)
448 { 448 {
449 //no requests waiting 449 //no requests waiting
450 return; 450 return;
451 } 451 }
452 int num; 452 int num;
453 453
454 if (this.AssetRequests.Count < 5) 454 if (AssetRequests.Count < 5)
455 { 455 {
456 //lower than 5 so do all of them 456 //lower than 5 so do all of them
457 num = this.AssetRequests.Count; 457 num = AssetRequests.Count;
458 } 458 }
459 else 459 else
460 { 460 {
@@ -463,7 +463,7 @@ namespace OpenSim.Framework.Communications.Cache
463 AssetRequest req; 463 AssetRequest req;
464 for (int i = 0; i < num; i++) 464 for (int i = 0; i < num; i++)
465 { 465 {
466 req = (AssetRequest)this.AssetRequests[i]; 466 req = (AssetRequest) AssetRequests[i];
467 //Console.WriteLine("sending asset " + req.RequestAssetID); 467 //Console.WriteLine("sending asset " + req.RequestAssetID);
468 TransferInfoPacket Transfer = new TransferInfoPacket(); 468 TransferInfoPacket Transfer = new TransferInfoPacket();
469 Transfer.TransferInfo.ChannelType = 2; 469 Transfer.TransferInfo.ChannelType = 2;
@@ -473,7 +473,7 @@ namespace OpenSim.Framework.Communications.Cache
473 { 473 {
474 Transfer.TransferInfo.Params = new byte[20]; 474 Transfer.TransferInfo.Params = new byte[20];
475 Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); 475 Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
476 int assType = (int)req.AssetInf.Type; 476 int assType = (int) req.AssetInf.Type;
477 Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); 477 Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
478 } 478 }
479 else if (req.AssetRequestSource == 3) 479 else if (req.AssetRequestSource == 3)
@@ -483,7 +483,7 @@ namespace OpenSim.Framework.Communications.Cache
483 //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); 483 //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
484 //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); 484 //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
485 } 485 }
486 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; 486 Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length;
487 Transfer.TransferInfo.TransferID = req.TransferRequestID; 487 Transfer.TransferInfo.TransferID = req.TransferRequestID;
488 req.RequestUser.OutPacket(Transfer); 488 req.RequestUser.OutPacket(Transfer);
489 489
@@ -533,19 +533,19 @@ namespace OpenSim.Framework.Communications.Cache
533 req.RequestUser.OutPacket(TransferPacket); 533 req.RequestUser.OutPacket(TransferPacket);
534 } 534 }
535 } 535 }
536
537 } 536 }
538 537
539 //remove requests that have been completed 538 //remove requests that have been completed
540 for (int i = 0; i < num; i++) 539 for (int i = 0; i < num; i++)
541 { 540 {
542 this.AssetRequests.RemoveAt(0); 541 AssetRequests.RemoveAt(0);
543 } 542 }
544
545 } 543 }
544
546 #endregion 545 #endregion
547 546
548 #region Textures 547 #region Textures
548
549 /// <summary> 549 /// <summary>
550 /// 550 ///
551 /// </summary> 551 /// </summary>
@@ -553,21 +553,21 @@ namespace OpenSim.Framework.Communications.Cache
553 /// <param name="imageID"></param> 553 /// <param name="imageID"></param>
554 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) 554 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard)
555 { 555 {
556 // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); 556 // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber);
557 //check to see if texture is in local cache, if not request from asset server 557 //check to see if texture is in local cache, if not request from asset server
558 if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) 558 if (!AvatarRecievedTextures.ContainsKey(userInfo.AgentId))
559 { 559 {
560 this.AvatarRecievedTextures.Add(userInfo.AgentId, new List<LLUUID>()); 560 AvatarRecievedTextures.Add(userInfo.AgentId, new List<LLUUID>());
561 } 561 }
562 /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) 562 /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID))
563 { 563 {
564 //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); 564 //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them");
565 return; 565 return;
566 }*/ 566 }*/
567 567
568 if (!this.Textures.ContainsKey(imageID)) 568 if (!Textures.ContainsKey(imageID))
569 { 569 {
570 if (!this.RequestedTextures.ContainsKey(imageID)) 570 if (!RequestedTextures.ContainsKey(imageID))
571 { 571 {
572 //not is cache so request from asset server 572 //not is cache so request from asset server
573 AssetRequest request = new AssetRequest(); 573 AssetRequest request = new AssetRequest();
@@ -575,14 +575,14 @@ namespace OpenSim.Framework.Communications.Cache
575 request.RequestAssetID = imageID; 575 request.RequestAssetID = imageID;
576 request.IsTextureRequest = true; 576 request.IsTextureRequest = true;
577 request.DiscardLevel = discard; 577 request.DiscardLevel = discard;
578 this.RequestedTextures.Add(imageID, request); 578 RequestedTextures.Add(imageID, request);
579 this._assetServer.FetchAsset(imageID, true); 579 _assetServer.FetchAsset(imageID, true);
580 } 580 }
581 return; 581 return;
582 } 582 }
583 583
584 // System.Console.WriteLine("texture already in cache"); 584 // System.Console.WriteLine("texture already in cache");
585 TextureImage imag = this.Textures[imageID]; 585 TextureImage imag = Textures[imageID];
586 AssetRequest req = new AssetRequest(); 586 AssetRequest req = new AssetRequest();
587 req.RequestUser = userInfo; 587 req.RequestUser = userInfo;
588 req.RequestAssetID = imageID; 588 req.RequestAssetID = imageID;
@@ -594,7 +594,7 @@ namespace OpenSim.Framework.Communications.Cache
594 { 594 {
595 //Console.WriteLine("{0}", imag.Data.LongLength); 595 //Console.WriteLine("{0}", imag.Data.LongLength);
596 //over 600 bytes so split up file 596 //over 600 bytes so split up file
597 req.NumPackets = 2 + (int)(imag.Data.Length - 601) / 1000; 597 req.NumPackets = 2 + (int) (imag.Data.Length - 601)/1000;
598 //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); 598 //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets");
599 } 599 }
600 else 600 else
@@ -603,12 +603,11 @@ namespace OpenSim.Framework.Communications.Cache
603 } 603 }
604 if (packetNumber != 0) 604 if (packetNumber != 0)
605 { 605 {
606 req.PacketCounter = (int)packetNumber; 606 req.PacketCounter = (int) packetNumber;
607 } 607 }
608 this.TextureRequests.Add(req); 608 TextureRequests.Add(req);
609 } 609 }
610 610
611
612 #endregion 611 #endregion
613 612
614 public class AssetRequest 613 public class AssetRequest
@@ -630,7 +629,6 @@ namespace OpenSim.Framework.Communications.Cache
630 629
631 public AssetRequest() 630 public AssetRequest()
632 { 631 {
633
634 } 632 }
635 } 633 }
636 634
@@ -638,7 +636,6 @@ namespace OpenSim.Framework.Communications.Cache
638 { 636 {
639 public AssetInfo() 637 public AssetInfo()
640 { 638 {
641
642 } 639 }
643 640
644 public AssetInfo(AssetBase aBase) 641 public AssetInfo(AssetBase aBase)
@@ -656,7 +653,6 @@ namespace OpenSim.Framework.Communications.Cache
656 { 653 {
657 public TextureImage() 654 public TextureImage()
658 { 655 {
659
660 } 656 }
661 657
662 public TextureImage(AssetBase aBase) 658 public TextureImage(AssetBase aBase)
@@ -678,7 +674,6 @@ namespace OpenSim.Framework.Communications.Cache
678 public TextureSender(AssetRequest req) 674 public TextureSender(AssetRequest req)
679 { 675 {
680 request = req; 676 request = req;
681
682 } 677 }
683 678
684 public bool SendTexture() 679 public bool SendTexture()
@@ -686,7 +681,8 @@ namespace OpenSim.Framework.Communications.Cache
686 SendPacket(); 681 SendPacket();
687 counter++; 682 counter++;
688 683
689 if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | (request.DiscardLevel == -1)) 684 if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) |
685 (request.DiscardLevel == -1))
690 { 686 {
691 return true; 687 return true;
692 } 688 }
@@ -707,7 +703,7 @@ namespace OpenSim.Framework.Communications.Cache
707 im.Header.Reliable = false; 703 im.Header.Reliable = false;
708 im.ImageID.Packets = 1; 704 im.ImageID.Packets = 1;
709 im.ImageID.ID = req.ImageInfo.FullID; 705 im.ImageID.ID = req.ImageInfo.FullID;
710 im.ImageID.Size = (uint)req.ImageInfo.Data.Length; 706 im.ImageID.Size = (uint) req.ImageInfo.Data.Length;
711 im.ImageData.Data = req.ImageInfo.Data; 707 im.ImageData.Data = req.ImageInfo.Data;
712 im.ImageID.Codec = 2; 708 im.ImageID.Codec = 2;
713 req.RequestUser.OutPacket(im); 709 req.RequestUser.OutPacket(im);
@@ -721,9 +717,9 @@ namespace OpenSim.Framework.Communications.Cache
721 //more than one packet so split file up 717 //more than one packet so split file up
722 ImageDataPacket im = new ImageDataPacket(); 718 ImageDataPacket im = new ImageDataPacket();
723 im.Header.Reliable = false; 719 im.Header.Reliable = false;
724 im.ImageID.Packets = (ushort)(req.NumPackets); 720 im.ImageID.Packets = (ushort) (req.NumPackets);
725 im.ImageID.ID = req.ImageInfo.FullID; 721 im.ImageID.ID = req.ImageInfo.FullID;
726 im.ImageID.Size = (uint)req.ImageInfo.Data.Length; 722 im.ImageID.Size = (uint) req.ImageInfo.Data.Length;
727 im.ImageData.Data = new byte[600]; 723 im.ImageData.Data = new byte[600];
728 Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); 724 Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600);
729 im.ImageID.Codec = 2; 725 im.ImageID.Codec = 2;
@@ -742,19 +738,18 @@ namespace OpenSim.Framework.Communications.Cache
742 //more than one packet so split file up 738 //more than one packet so split file up
743 ImagePacketPacket im = new ImagePacketPacket(); 739 ImagePacketPacket im = new ImagePacketPacket();
744 im.Header.Reliable = false; 740 im.Header.Reliable = false;
745 im.ImageID.Packet = (ushort)(req.PacketCounter); 741 im.ImageID.Packet = (ushort) (req.PacketCounter);
746 im.ImageID.ID = req.ImageInfo.FullID; 742 im.ImageID.ID = req.ImageInfo.FullID;
747 int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1)); 743 int size = req.ImageInfo.Data.Length - 600 - (1000*(req.PacketCounter - 1));
748 if (size > 1000) size = 1000; 744 if (size > 1000) size = 1000;
749 //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); 745 //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size);
750 im.ImageData.Data = new byte[size]; 746 im.ImageData.Data = new byte[size];
751 Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter - 1)), im.ImageData.Data, 0, size); 747 Array.Copy(req.ImageInfo.Data, 600 + (1000*(req.PacketCounter - 1)), im.ImageData.Data, 0, size);
752 req.RequestUser.OutPacket(im); 748 req.RequestUser.OutPacket(im);
753 req.PacketCounter++; 749 req.PacketCounter++;
754 //req.ImageInfo.last_used = time; 750 //req.ImageInfo.last_used = time;
755 //System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID); 751 //System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID);
756 } 752 }
757
758 } 753 }
759 754
760 private void SaveAssetToFile(string filename, byte[] data) 755 private void SaveAssetToFile(string filename, byte[] data)
@@ -789,7 +784,5 @@ namespace OpenSim.Framework.Communications.Cache
789 AssetID = assetID; 784 AssetID = assetID;
790 Callback = callback; 785 Callback = callback;
791 } 786 }
792
793
794 } 787 }
795} 788} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs
index c927571..fa421c7 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs
@@ -25,18 +25,11 @@
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;
29using System.Collections.Generic;
30using System.IO; 28using System.IO;
31using System.Threading;
32using Db4objects.Db4o; 29using Db4objects.Db4o;
33using Db4objects.Db4o.Query; 30using Db4objects.Db4o.Query;
34using libsecondlife; 31using libsecondlife;
35using Nini.Config;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework;
40 33
41namespace OpenSim.Framework.Communications.Cache 34namespace OpenSim.Framework.Communications.Cache
42{ 35{
@@ -50,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache
50 yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); 43 yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap"));
51 44
52 db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); 45 db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap"));
53 MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation"); 46 MainLog.Instance.Verbose("ASSETS", "Db4 Asset database creation");
54 47
55 if (!yapfile) 48 if (!yapfile)
56 { 49 {
@@ -68,29 +61,29 @@ namespace OpenSim.Framework.Communications.Cache
68 db.Commit(); 61 db.Commit();
69 } 62 }
70 63
71 override public void Close() 64 public override void Close()
72 { 65 {
73 base.Close(); 66 base.Close();
74 67
75 if (db != null) 68 if (db != null)
76 { 69 {
77 MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database"); 70 MainLog.Instance.Verbose("ASSETSERVER", "Closing local asset server database");
78 db.Close(); 71 db.Close();
79 } 72 }
80 } 73 }
81 74
82 override protected void RunRequests() 75 protected override void RunRequests()
83 { 76 {
84 while (true) 77 while (true)
85 { 78 {
86 byte[] idata = null; 79 byte[] idata = null;
87 bool found = false; 80 bool found = false;
88 AssetStorage foundAsset = null; 81 AssetStorage foundAsset = null;
89 ARequest req = this._assetRequests.Dequeue(); 82 ARequest req = _assetRequests.Dequeue();
90 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); 83 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
91 if (result.Count > 0) 84 if (result.Count > 0)
92 { 85 {
93 foundAsset = (AssetStorage)result.Next(); 86 foundAsset = (AssetStorage) result.Next();
94 found = true; 87 found = true;
95 } 88 }
96 89
@@ -110,12 +103,10 @@ namespace OpenSim.Framework.Communications.Cache
110 //asset.FullID = ; 103 //asset.FullID = ;
111 _receiver.AssetNotFound(req.AssetID); 104 _receiver.AssetNotFound(req.AssetID);
112 } 105 }
113
114 } 106 }
115
116 } 107 }
117 108
118 override protected void StoreAsset(AssetBase asset) 109 protected override void StoreAsset(AssetBase asset)
119 { 110 {
120 AssetStorage store = new AssetStorage(); 111 AssetStorage store = new AssetStorage();
121 store.Data = asset.Data; 112 store.Data = asset.Data;
@@ -148,6 +139,7 @@ namespace OpenSim.Framework.Communications.Cache
148 { 139 {
149 _findID = find; 140 _findID = find;
150 } 141 }
142
151 public bool Match(AssetStorage asset) 143 public bool Match(AssetStorage asset)
152 { 144 {
153 return (asset.UUID == _findID); 145 return (asset.UUID == _findID);
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 0771a20..7109910 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -5,8 +5,6 @@ using System.Threading;
5using libsecondlife; 5using libsecondlife;
6using Nini.Config; 6using Nini.Config;
7using OpenSim.Framework.Console; 7using OpenSim.Framework.Console;
8using OpenSim.Framework.Interfaces;
9using OpenSim.Framework;
10 8
11namespace OpenSim.Framework.Communications.Cache 9namespace OpenSim.Framework.Communications.Cache
12{ 10{
@@ -36,13 +34,12 @@ namespace OpenSim.Framework.Communications.Cache
36 34
37 public AssetServerBase() 35 public AssetServerBase()
38 { 36 {
37 MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
38 _assetRequests = new BlockingQueue<ARequest>();
39 39
40 OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting asset storage system"); 40 _localAssetServerThread = new Thread(RunRequests);
41 this._assetRequests = new BlockingQueue<ARequest>(); 41 _localAssetServerThread.IsBackground = true;
42 42 _localAssetServerThread.Start();
43 this._localAssetServerThread = new Thread(RunRequests);
44 this._localAssetServerThread.IsBackground = true;
45 this._localAssetServerThread.Start();
46 } 43 }
47 44
48 public void LoadAsset(AssetBase info, bool image, string filename) 45 public void LoadAsset(AssetBase info, bool image, string filename)
@@ -57,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache
57 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); 54 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
58 byte[] idata = new byte[numBytes]; 55 byte[] idata = new byte[numBytes];
59 BinaryReader br = new BinaryReader(fStream); 56 BinaryReader br = new BinaryReader(fStream);
60 idata = br.ReadBytes((int)numBytes); 57 idata = br.ReadBytes((int) numBytes);
61 br.Close(); 58 br.Close();
62 fStream.Close(); 59 fStream.Close();
63 info.Data = idata; 60 info.Data = idata;
@@ -66,7 +63,7 @@ namespace OpenSim.Framework.Communications.Cache
66 63
67 public void SetReceiver(IAssetReceiver receiver) 64 public void SetReceiver(IAssetReceiver receiver)
68 { 65 {
69 this._receiver = receiver; 66 _receiver = receiver;
70 } 67 }
71 68
72 public void FetchAsset(LLUUID assetID, bool isTexture) 69 public void FetchAsset(LLUUID assetID, bool isTexture)
@@ -74,7 +71,7 @@ namespace OpenSim.Framework.Communications.Cache
74 ARequest req = new ARequest(); 71 ARequest req = new ARequest();
75 req.AssetID = assetID; 72 req.AssetID = assetID;
76 req.IsTexture = isTexture; 73 req.IsTexture = isTexture;
77 this._assetRequests.Enqueue(req); 74 _assetRequests.Enqueue(req);
78 } 75 }
79 76
80 public void UpdateAsset(AssetBase asset) 77 public void UpdateAsset(AssetBase asset)
@@ -102,7 +99,6 @@ namespace OpenSim.Framework.Communications.Cache
102 99
103 public void SetServerInfo(string ServerUrl, string ServerKey) 100 public void SetServerInfo(string ServerUrl, string ServerKey)
104 { 101 {
105
106 } 102 }
107 103
108 public virtual List<AssetBase> GetDefaultAssets() 104 public virtual List<AssetBase> GetDefaultAssets()
@@ -175,8 +171,8 @@ namespace OpenSim.Framework.Communications.Cache
175 // System.Console.WriteLine("loading asset into database"); 171 // System.Console.WriteLine("loading asset into database");
176 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); 172 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
177 string name = source.Configs[i].GetString("name", ""); 173 string name = source.Configs[i].GetString("name", "");
178 sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); 174 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
179 sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); 175 sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
180 string fileName = source.Configs[i].GetString("fileName", ""); 176 string fileName = source.Configs[i].GetString("fileName", "");
181 177
182 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); 178 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
@@ -189,4 +185,4 @@ namespace OpenSim.Framework.Communications.Cache
189 assets.ForEach(action); 185 assets.ForEach(action);
190 } 186 }
191 } 187 }
192} 188} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
index d622e02..55b255a 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
@@ -25,15 +25,8 @@
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;
29using System.Collections;
30using System.Collections.Generic; 28using System.Collections.Generic;
31using System.Text;
32using System.IO;
33using libsecondlife; 29using libsecondlife;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework;
36using OpenSim.Framework.Data;
37 30
38namespace OpenSim.Framework.Communications.Cache 31namespace OpenSim.Framework.Communications.Cache
39{ 32{
@@ -41,7 +34,10 @@ namespace OpenSim.Framework.Communications.Cache
41 { 34 {
42 // Fields 35 // Fields
43 public CommunicationsManager CommsManager; 36 public CommunicationsManager CommsManager;
44 public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>(); 37
38 public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
39 new Dictionary<LLUUID, AgentAssetTransactions>();
40
45 private bool m_dumpAssetsToFile; 41 private bool m_dumpAssetsToFile;
46 42
47 public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile) 43 public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile)
@@ -53,10 +49,10 @@ namespace OpenSim.Framework.Communications.Cache
53 // Methods 49 // Methods
54 public AgentAssetTransactions AddUser(LLUUID userID) 50 public AgentAssetTransactions AddUser(LLUUID userID)
55 { 51 {
56 if (!this.AgentTransactions.ContainsKey(userID)) 52 if (!AgentTransactions.ContainsKey(userID))
57 { 53 {
58 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); 54 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
59 this.AgentTransactions.Add(userID, transactions); 55 AgentTransactions.Add(userID, transactions);
60 return transactions; 56 return transactions;
61 } 57 }
62 return null; 58 return null;
@@ -64,27 +60,30 @@ namespace OpenSim.Framework.Communications.Cache
64 60
65 public AgentAssetTransactions GetUserTransActions(LLUUID userID) 61 public AgentAssetTransactions GetUserTransActions(LLUUID userID)
66 { 62 {
67 if (this.AgentTransactions.ContainsKey(userID)) 63 if (AgentTransactions.ContainsKey(userID))
68 { 64 {
69 return this.AgentTransactions[userID]; 65 return AgentTransactions[userID];
70 } 66 }
71 return null; 67 return null;
72 } 68 }
73 69
74 public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) 70 public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
71 uint callbackID, string description, string name, sbyte invType,
72 sbyte type, byte wearableType, uint nextOwnerMask)
75 { 73 {
76 AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); 74 AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
77 if (transactions != null) 75 if (transactions != null)
78 { 76 {
79 transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); 77 transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description,
78 name, invType, type, wearableType, nextOwnerMask);
80 } 79 }
81
82 } 80 }
83 81
84 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) 82 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
83 byte[] data, bool storeLocal)
85 { 84 {
86 // Console.WriteLine("asset upload of " + assetID); 85 // Console.WriteLine("asset upload of " + assetID);
87 AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); 86 AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
88 if (transactions != null) 87 if (transactions != null)
89 { 88 {
90 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); 89 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
@@ -97,7 +96,7 @@ namespace OpenSim.Framework.Communications.Cache
97 96
98 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) 97 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
99 { 98 {
100 AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); 99 AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
101 if (transactions != null) 100 if (transactions != null)
102 { 101 {
103 transactions.HandleXfer(xferID, packetID, data); 102 transactions.HandleXfer(xferID, packetID, data);
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
index e78f4f7..6b08fc9 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
@@ -26,17 +26,12 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections;
30using System.Collections.Generic; 29using System.Collections.Generic;
31using System.Text;
32using System.IO; 30using System.IO;
33using libsecondlife; 31using libsecondlife;
34using libsecondlife.Packets; 32using libsecondlife.Packets;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework;
38using OpenSim.Region.Capabilities;
39using OpenSim.Framework.Servers; 33using OpenSim.Framework.Servers;
34using OpenSim.Region.Capabilities;
40 35
41namespace OpenSim.Framework.Communications.Cache 36namespace OpenSim.Framework.Communications.Cache
42{ 37{
@@ -53,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
53 // Methods 48 // Methods
54 public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile) 49 public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile)
55 { 50 {
56 this.UserID = agentID; 51 UserID = agentID;
57 Manager = manager; 52 Manager = manager;
58 m_dumpAssetsToFile = dumpAssetsToFile; 53 m_dumpAssetsToFile = dumpAssetsToFile;
59 } 54 }
@@ -61,24 +56,24 @@ namespace OpenSim.Framework.Communications.Cache
61 public AssetCapsUploader RequestCapsUploader() 56 public AssetCapsUploader RequestCapsUploader()
62 { 57 {
63 AssetCapsUploader uploader = new AssetCapsUploader(); 58 AssetCapsUploader uploader = new AssetCapsUploader();
64 this.CapsUploaders.Add(uploader); 59 CapsUploaders.Add(uploader);
65 return uploader; 60 return uploader;
66 } 61 }
67 62
68 public NoteCardCapsUpdate RequestNoteCardUpdater() 63 public NoteCardCapsUpdate RequestNoteCardUpdater()
69 { 64 {
70 NoteCardCapsUpdate update = new NoteCardCapsUpdate(); 65 NoteCardCapsUpdate update = new NoteCardCapsUpdate();
71 this.NotecardUpdaters.Add(update); 66 NotecardUpdaters.Add(update);
72 return update; 67 return update;
73 } 68 }
74 69
75 public AssetXferUploader RequestXferUploader(LLUUID transactionID) 70 public AssetXferUploader RequestXferUploader(LLUUID transactionID)
76 { 71 {
77 if (!this.XferUploaders.ContainsKey(transactionID)) 72 if (!XferUploaders.ContainsKey(transactionID))
78 { 73 {
79 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); 74 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile);
80 75
81 this.XferUploaders.Add(transactionID, uploader); 76 XferUploaders.Add(transactionID, uploader);
82 return uploader; 77 return uploader;
83 } 78 }
84 return null; 79 return null;
@@ -86,7 +81,7 @@ namespace OpenSim.Framework.Communications.Cache
86 81
87 public void HandleXfer(ulong xferID, uint packetID, byte[] data) 82 public void HandleXfer(ulong xferID, uint packetID, byte[] data)
88 { 83 {
89 foreach (AssetXferUploader uploader in this.XferUploaders.Values) 84 foreach (AssetXferUploader uploader in XferUploaders.Values)
90 { 85 {
91 if (uploader.XferID == xferID) 86 if (uploader.XferID == xferID)
92 { 87 {
@@ -96,17 +91,21 @@ namespace OpenSim.Framework.Communications.Cache
96 } 91 }
97 } 92 }
98 93
99 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) 94 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
95 uint callbackID, string description, string name, sbyte invType,
96 sbyte type, byte wearableType, uint nextOwnerMask)
100 { 97 {
101 if (this.XferUploaders.ContainsKey(transactionID)) 98 if (XferUploaders.ContainsKey(transactionID))
102 { 99 {
103 this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); 100 XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID,
101 callbackID, description, name, invType, type,
102 wearableType, nextOwnerMask);
104 } 103 }
105 } 104 }
106 105
107 public AssetBase GetTransactionAsset(LLUUID transactionID) 106 public AssetBase GetTransactionAsset(LLUUID transactionID)
108 { 107 {
109 if (this.XferUploaders.ContainsKey(transactionID)) 108 if (XferUploaders.ContainsKey(transactionID))
110 { 109 {
111 return XferUploaders[transactionID].GetAssetData(); 110 return XferUploaders[transactionID].GetAssetData();
112 } 111 }
@@ -130,15 +129,16 @@ namespace OpenSim.Framework.Communications.Cache
130 public event UpLoadedAsset OnUpLoad; 129 public event UpLoadedAsset OnUpLoad;
131 130
132 // Methods 131 // Methods
133 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) 132 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem,
133 LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile)
134 { 134 {
135 this.m_assetName = assetName; 135 m_assetName = assetName;
136 this.m_assetDescription = assetDescription; 136 m_assetDescription = assetDescription;
137 this.m_folderID = folderID; 137 m_folderID = folderID;
138 this.newAssetID = assetID; 138 newAssetID = assetID;
139 this.inventoryItemID = inventoryItem; 139 inventoryItemID = inventoryItem;
140 this.uploaderPath = path; 140 uploaderPath = path;
141 this.httpListener = httpServer; 141 httpListener = httpServer;
142 m_dumpImageToFile = dumpImageToFile; 142 m_dumpImageToFile = dumpImageToFile;
143 } 143 }
144 144
@@ -156,18 +156,18 @@ namespace OpenSim.Framework.Communications.Cache
156 LLUUID inventoryItemID = this.inventoryItemID; 156 LLUUID inventoryItemID = this.inventoryItemID;
157 string text = ""; 157 string text = "";
158 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); 158 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
159 complete.new_asset = this.newAssetID.ToStringHyphenated(); 159 complete.new_asset = newAssetID.ToStringHyphenated();
160 complete.new_inventory_item = inventoryItemID; 160 complete.new_inventory_item = inventoryItemID;
161 complete.state = "complete"; 161 complete.state = "complete";
162 text = LLSDHelpers.SerialiseLLSDReply(complete); 162 text = LLSDHelpers.SerialiseLLSDReply(complete);
163 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); 163 httpListener.RemoveStreamHandler("POST", uploaderPath);
164 if (this.m_dumpImageToFile) 164 if (m_dumpImageToFile)
165 { 165 {
166 this.SaveImageToFile(this.m_assetName + ".jp2", data); 166 SaveImageToFile(m_assetName + ".jp2", data);
167 } 167 }
168 if (this.OnUpLoad != null) 168 if (OnUpLoad != null)
169 { 169 {
170 this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , ""); 170 OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
171 } 171 }
172 return text; 172 return text;
173 } 173 }
@@ -196,90 +196,91 @@ namespace OpenSim.Framework.Communications.Cache
196 196
197 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 197 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
198 { 198 {
199 this.m_userTransactions = transactions; 199 m_userTransactions = transactions;
200 m_dumpAssetToFile = dumpAssetToFile; 200 m_dumpAssetToFile = dumpAssetToFile;
201 } 201 }
202 202
203 // Methods 203 // Methods
204 public void HandleXferPacket(ulong xferID, uint packetID, byte[] data) 204 public void HandleXferPacket(ulong xferID, uint packetID, byte[] data)
205 { 205 {
206 if (this.XferID == xferID) 206 if (XferID == xferID)
207 { 207 {
208 if (this.Asset.Data.Length > 1) 208 if (Asset.Data.Length > 1)
209 { 209 {
210 byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; 210 byte[] destinationArray = new byte[Asset.Data.Length + data.Length];
211 Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); 211 Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length);
212 Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); 212 Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length);
213 this.Asset.Data = destinationArray; 213 Asset.Data = destinationArray;
214 } 214 }
215 else 215 else
216 { 216 {
217 byte[] buffer2 = new byte[data.Length - 4]; 217 byte[] buffer2 = new byte[data.Length - 4];
218 Array.Copy(data, 4, buffer2, 0, data.Length - 4); 218 Array.Copy(data, 4, buffer2, 0, data.Length - 4);
219 this.Asset.Data = buffer2; 219 Asset.Data = buffer2;
220 } 220 }
221 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); 221 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
222 newPack.XferID.ID = xferID; 222 newPack.XferID.ID = xferID;
223 newPack.XferID.Packet = packetID; 223 newPack.XferID.Packet = packetID;
224 this.ourClient.OutPacket(newPack); 224 ourClient.OutPacket(newPack);
225 if ((packetID & 0x80000000) != 0) 225 if ((packetID & 0x80000000) != 0)
226 { 226 {
227 this.SendCompleteMessage(); 227 SendCompleteMessage();
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) 232 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data,
233 bool storeLocal)
233 { 234 {
234 this.ourClient = remoteClient; 235 ourClient = remoteClient;
235 this.Asset = new AssetBase(); 236 Asset = new AssetBase();
236 this.Asset.FullID = assetID; 237 Asset.FullID = assetID;
237 this.Asset.InvType = type; 238 Asset.InvType = type;
238 this.Asset.Type = type; 239 Asset.Type = type;
239 this.Asset.Data = data; 240 Asset.Data = data;
240 this.Asset.Name = "blank"; 241 Asset.Name = "blank";
241 this.Asset.Description = "empty"; 242 Asset.Description = "empty";
242 this.TransactionID = transaction; 243 TransactionID = transaction;
243 this.m_storeLocal = storeLocal; 244 m_storeLocal = storeLocal;
244 if (this.Asset.Data.Length > 2) 245 if (Asset.Data.Length > 2)
245 { 246 {
246 this.SendCompleteMessage(); 247 SendCompleteMessage();
247 } 248 }
248 else 249 else
249 { 250 {
250 this.ReqestStartXfer(); 251 ReqestStartXfer();
251 } 252 }
252 } 253 }
253 254
254 protected void ReqestStartXfer() 255 protected void ReqestStartXfer()
255 { 256 {
256 this.UploadComplete = false; 257 UploadComplete = false;
257 this.XferID = Util.GetNextXferID(); 258 XferID = Util.GetNextXferID();
258 RequestXferPacket newPack = new RequestXferPacket(); 259 RequestXferPacket newPack = new RequestXferPacket();
259 newPack.XferID.ID = this.XferID; 260 newPack.XferID.ID = XferID;
260 newPack.XferID.VFileType = this.Asset.Type; 261 newPack.XferID.VFileType = Asset.Type;
261 newPack.XferID.VFileID = this.Asset.FullID; 262 newPack.XferID.VFileID = Asset.FullID;
262 newPack.XferID.FilePath = 0; 263 newPack.XferID.FilePath = 0;
263 newPack.XferID.Filename = new byte[0]; 264 newPack.XferID.Filename = new byte[0];
264 this.ourClient.OutPacket(newPack); 265 ourClient.OutPacket(newPack);
265 } 266 }
266 267
267 protected void SendCompleteMessage() 268 protected void SendCompleteMessage()
268 { 269 {
269 this.UploadComplete = true; 270 UploadComplete = true;
270 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); 271 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
271 newPack.AssetBlock.Type = this.Asset.Type; 272 newPack.AssetBlock.Type = Asset.Type;
272 newPack.AssetBlock.Success = true; 273 newPack.AssetBlock.Success = true;
273 newPack.AssetBlock.UUID = this.Asset.FullID; 274 newPack.AssetBlock.UUID = Asset.FullID;
274 this.ourClient.OutPacket(newPack); 275 ourClient.OutPacket(newPack);
275 this.m_finished = true; 276 m_finished = true;
276 if (m_createItem) 277 if (m_createItem)
277 { 278 {
278 DoCreateItem(); 279 DoCreateItem();
279 } 280 }
280 else if (m_storeLocal) 281 else if (m_storeLocal)
281 { 282 {
282 this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); 283 m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
283 } 284 }
284 285
285 // Console.WriteLine("upload complete "+ this.TransactionID); 286 // Console.WriteLine("upload complete "+ this.TransactionID);
@@ -287,8 +288,10 @@ namespace OpenSim.Framework.Communications.Cache
287 if (m_dumpAssetToFile) 288 if (m_dumpAssetToFile)
288 { 289 {
289 DateTime now = DateTime.Now; 290 DateTime now = DateTime.Now;
290 string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type ); 291 string filename =
291 SaveAssetToFile(filename, this.Asset.Data); 292 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day,
293 now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type);
294 SaveAssetToFile(filename, Asset.Data);
292 } 295 }
293 } 296 }
294 297
@@ -301,20 +304,22 @@ namespace OpenSim.Framework.Communications.Cache
301 fs.Close(); 304 fs.Close();
302 } 305 }
303 306
304 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) 307 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
308 uint callbackID, string description, string name, sbyte invType,
309 sbyte type, byte wearableType, uint nextOwnerMask)
305 { 310 {
306 if (this.TransactionID == transactionID) 311 if (TransactionID == transactionID)
307 { 312 {
308 this.InventFolder = folderID; 313 InventFolder = folderID;
309 this.m_name = name; 314 m_name = name;
310 this.m_description = description; 315 m_description = description;
311 this.type = type; 316 this.type = type;
312 this.invType = invType; 317 this.invType = invType;
313 this.nextPerm = nextOwnerMask; 318 nextPerm = nextOwnerMask;
314 this.Asset.Name = name; 319 Asset.Name = name;
315 this.Asset.Description = description; 320 Asset.Description = description;
316 this.Asset.Type = type; 321 Asset.Type = type;
317 this.Asset.InvType = invType; 322 Asset.InvType = invType;
318 m_createItem = true; 323 m_createItem = true;
319 if (m_finished) 324 if (m_finished)
320 { 325 {
@@ -326,22 +331,23 @@ namespace OpenSim.Framework.Communications.Cache
326 private void DoCreateItem() 331 private void DoCreateItem()
327 { 332 {
328 //really need to fix this call, if lbsa71 saw this he would die. 333 //really need to fix this call, if lbsa71 saw this he would die.
329 this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); 334 m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
330 CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); 335 CachedUserInfo userInfo =
336 m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId);
331 if (userInfo != null) 337 if (userInfo != null)
332 { 338 {
333 InventoryItemBase item = new InventoryItemBase(); 339 InventoryItemBase item = new InventoryItemBase();
334 item.avatarID = this.ourClient.AgentId; 340 item.avatarID = ourClient.AgentId;
335 item.creatorsID = ourClient.AgentId; 341 item.creatorsID = ourClient.AgentId;
336 item.inventoryID = LLUUID.Random(); 342 item.inventoryID = LLUUID.Random();
337 item.assetID = Asset.FullID; 343 item.assetID = Asset.FullID;
338 item.inventoryDescription = this.m_description; 344 item.inventoryDescription = m_description;
339 item.inventoryName = m_name; 345 item.inventoryName = m_name;
340 item.assetType = type; 346 item.assetType = type;
341 item.invType = this.invType; 347 item.invType = invType;
342 item.parentFolderID = this.InventFolder; 348 item.parentFolderID = InventFolder;
343 item.inventoryCurrentPermissions = 2147483647; 349 item.inventoryCurrentPermissions = 2147483647;
344 item.inventoryNextPermissions = this.nextPerm; 350 item.inventoryNextPermissions = nextPerm;
345 351
346 userInfo.AddItem(ourClient.AgentId, item); 352 userInfo.AddItem(ourClient.AgentId, item);
347 ourClient.SendInventoryItemUpdate(item); 353 ourClient.SendInventoryItemUpdate(item);
@@ -350,14 +356,13 @@ namespace OpenSim.Framework.Communications.Cache
350 356
351 public void UpdateInventoryItem(LLUUID itemID) 357 public void UpdateInventoryItem(LLUUID itemID)
352 { 358 {
353
354 } 359 }
355 360
356 public AssetBase GetAssetData() 361 public AssetBase GetAssetData()
357 { 362 {
358 if (m_finished) 363 if (m_finished)
359 { 364 {
360 return this.Asset; 365 return Asset;
361 } 366 }
362 return null; 367 return null;
363 } 368 }
@@ -379,10 +384,10 @@ namespace OpenSim.Framework.Communications.Cache
379 // Methods 384 // Methods
380 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) 385 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer)
381 { 386 {
382 this.inventoryItemID = inventoryItem; 387 inventoryItemID = inventoryItem;
383 this.uploaderPath = path; 388 uploaderPath = path;
384 this.httpListener = httpServer; 389 httpListener = httpServer;
385 this.newAssetID = LLUUID.Random(); 390 newAssetID = LLUUID.Random();
386 } 391 }
387 392
388 private void SaveImageToFile(string filename, byte[] data) 393 private void SaveImageToFile(string filename, byte[] data)
@@ -399,18 +404,18 @@ namespace OpenSim.Framework.Communications.Cache
399 LLUUID inventoryItemID = this.inventoryItemID; 404 LLUUID inventoryItemID = this.inventoryItemID;
400 string text = ""; 405 string text = "";
401 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); 406 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
402 complete.new_asset = this.newAssetID.ToStringHyphenated(); 407 complete.new_asset = newAssetID.ToStringHyphenated();
403 complete.new_inventory_item = inventoryItemID; 408 complete.new_inventory_item = inventoryItemID;
404 complete.state = "complete"; 409 complete.state = "complete";
405 text = LLSDHelpers.SerialiseLLSDReply(complete); 410 text = LLSDHelpers.SerialiseLLSDReply(complete);
406 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); 411 httpListener.RemoveStreamHandler("POST", uploaderPath);
407 if (this.SaveImages) 412 if (SaveImages)
408 { 413 {
409 this.SaveImageToFile(this.m_assetName + "notecard.txt", data); 414 SaveImageToFile(m_assetName + "notecard.txt", data);
410 } 415 }
411 if (this.OnUpLoad != null) 416 if (OnUpLoad != null)
412 { 417 {
413 this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "" ); 418 OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
414 } 419 }
415 return text; 420 return text;
416 } 421 }
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 2d639d6..8fbc3fd 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -26,7 +26,6 @@
26* 26*
27*/ 27*/
28using libsecondlife; 28using libsecondlife;
29using OpenSim.Framework;
30 29
31namespace OpenSim.Framework.Communications.Cache 30namespace OpenSim.Framework.Communications.Cache
32{ 31{
@@ -45,22 +44,22 @@ namespace OpenSim.Framework.Communications.Cache
45 // Methods 44 // Methods
46 public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) 45 public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo)
47 { 46 {
48 if (userID == this.UserProfile.UUID) 47 if (userID == UserProfile.UUID)
49 { 48 {
50 if (this.RootFolder == null) 49 if (RootFolder == null)
51 { 50 {
52 if (folderInfo.parentID == LLUUID.Zero) 51 if (folderInfo.parentID == LLUUID.Zero)
53 { 52 {
54 this.RootFolder = folderInfo; 53 RootFolder = folderInfo;
55 } 54 }
56 } 55 }
57 else if (this.RootFolder.folderID == folderInfo.parentID) 56 else if (RootFolder.folderID == folderInfo.parentID)
58 { 57 {
59 this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); 58 RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
60 } 59 }
61 else 60 else
62 { 61 {
63 InventoryFolderImpl folder = this.RootFolder.HasSubFolder(folderInfo.parentID); 62 InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID);
64 if (folder != null) 63 if (folder != null)
65 { 64 {
66 folder.SubFolders.Add(folderInfo.folderID, folderInfo); 65 folder.SubFolders.Add(folderInfo.folderID, folderInfo);
@@ -71,18 +70,18 @@ namespace OpenSim.Framework.Communications.Cache
71 70
72 public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) 71 public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
73 { 72 {
74 if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) 73 if ((userID == UserProfile.UUID) && (RootFolder != null))
75 { 74 {
76 if (itemInfo.parentFolderID == this.RootFolder.folderID) 75 if (itemInfo.parentFolderID == RootFolder.folderID)
77 { 76 {
78 this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); 77 RootFolder.Items.Add(itemInfo.inventoryID, itemInfo);
79 } 78 }
80 else 79 else
81 { 80 {
82 InventoryFolderImpl folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); 81 InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.parentFolderID);
83 if (folder != null) 82 if (folder != null)
84 { 83 {
85 folder.Items.Add(itemInfo.inventoryID, itemInfo); 84 folder.Items.Add(itemInfo.inventoryID, itemInfo);
86 } 85 }
87 } 86 }
88 } 87 }
@@ -90,30 +89,30 @@ namespace OpenSim.Framework.Communications.Cache
90 89
91 public void AddItem(LLUUID userID, InventoryItemBase itemInfo) 90 public void AddItem(LLUUID userID, InventoryItemBase itemInfo)
92 { 91 {
93 if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) 92 if ((userID == UserProfile.UUID) && (RootFolder != null))
94 { 93 {
95 this.ItemReceive(userID, itemInfo); 94 ItemReceive(userID, itemInfo);
96 this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); 95 m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
97 } 96 }
98 } 97 }
99 98
100 public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) 99 public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo)
101 { 100 {
102 if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) 101 if ((userID == UserProfile.UUID) && (RootFolder != null))
103 { 102 {
104 this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); 103 m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
105 } 104 }
106 } 105 }
107 106
108 public bool DeleteItem(LLUUID userID, InventoryItemBase item) 107 public bool DeleteItem(LLUUID userID, InventoryItemBase item)
109 { 108 {
110 bool result = false; 109 bool result = false;
111 if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) 110 if ((userID == UserProfile.UUID) && (RootFolder != null))
112 { 111 {
113 result = RootFolder.DeleteItem(item.inventoryID); 112 result = RootFolder.DeleteItem(item.inventoryID);
114 if (result) 113 if (result)
115 { 114 {
116 this.m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); 115 m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item);
117 } 116 }
118 } 117 }
119 return result; 118 return result;
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
index 4904293..74a1ef4 100644
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -25,19 +25,13 @@
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*/
28
28using System; 29using System;
30using System.Collections.Generic;
29using System.IO; 31using System.IO;
30using System.Threading;
31using System.Reflection;
32using System.Xml.Serialization; 32using System.Xml.Serialization;
33
34using libsecondlife; 33using libsecondlife;
35
36using Nini.Config;
37using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41 35
42namespace OpenSim.Framework.Communications.Cache 36namespace OpenSim.Framework.Communications.Cache
43{ 37{
@@ -63,7 +57,6 @@ namespace OpenSim.Framework.Communications.Cache
63 Stream s = null; 57 Stream s = null;
64 try 58 try
65 { 59 {
66
67 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); 60 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString());
68 61
69 RestClient rc = new RestClient(_assetServerUrl); 62 RestClient rc = new RestClient(_assetServerUrl);
@@ -77,8 +70,8 @@ namespace OpenSim.Framework.Communications.Cache
77 70
78 if (s.Length > 0) 71 if (s.Length > 0)
79 { 72 {
80 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 73 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
81 AssetBase asset = (AssetBase)xs.Deserialize(s); 74 AssetBase asset = (AssetBase) xs.Deserialize(s);
82 75
83 _receiver.AssetReceived(asset, isTexture); 76 _receiver.AssetReceived(asset, isTexture);
84 } 77 }
@@ -106,7 +99,7 @@ namespace OpenSim.Framework.Communications.Cache
106 { 99 {
107 MemoryStream s = new MemoryStream(); 100 MemoryStream s = new MemoryStream();
108 101
109 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 102 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
110 xs.Serialize(s, asset); 103 xs.Serialize(s, asset);
111 RestClient rc = new RestClient(_assetServerUrl); 104 RestClient rc = new RestClient(_assetServerUrl);
112 rc.AddResourcePath("assets"); 105 rc.AddResourcePath("assets");
@@ -129,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache
129 throw new Exception("The method or operation is not implemented."); 122 throw new Exception("The method or operation is not implemented.");
130 } 123 }
131 124
132 public System.Collections.Generic.List<AssetBase> GetDefaultAssets() 125 public List<AssetBase> GetDefaultAssets()
133 { 126 {
134 throw new Exception("The method or operation is not implemented."); 127 throw new Exception("The method or operation is not implemented.");
135 } 128 }
@@ -156,4 +149,4 @@ namespace OpenSim.Framework.Communications.Cache
156 149
157 #endregion 150 #endregion
158 } 151 }
159} 152} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs
index 0905af8..3495e55 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs
@@ -25,14 +25,8 @@
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;
29using System.Collections;
30using System.Collections.Generic; 28using System.Collections.Generic;
31using System.Text;
32using System.IO;
33using libsecondlife; 29using libsecondlife;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework;
36 30
37namespace OpenSim.Framework.Communications.Cache 31namespace OpenSim.Framework.Communications.Cache
38{ 32{
@@ -44,17 +38,16 @@ namespace OpenSim.Framework.Communications.Cache
44 38
45 public InventoryFolderImpl(InventoryFolderBase folderbase) 39 public InventoryFolderImpl(InventoryFolderBase folderbase)
46 { 40 {
47 this.agentID = folderbase.agentID; 41 agentID = folderbase.agentID;
48 this.folderID = folderbase.folderID; 42 folderID = folderbase.folderID;
49 this.name = folderbase.name; 43 name = folderbase.name;
50 this.parentID = folderbase.parentID; 44 parentID = folderbase.parentID;
51 this.type = folderbase.type; 45 type = folderbase.type;
52 this.version = folderbase.version; 46 version = folderbase.version;
53 } 47 }
54 48
55 public InventoryFolderImpl() 49 public InventoryFolderImpl()
56 { 50 {
57
58 } 51 }
59 52
60 // Methods 53 // Methods
@@ -65,19 +58,19 @@ namespace OpenSim.Framework.Communications.Cache
65 subFold.folderID = folderID; 58 subFold.folderID = folderID;
66 subFold.type = (short) type; 59 subFold.type = (short) type;
67 subFold.parentID = this.folderID; 60 subFold.parentID = this.folderID;
68 subFold.agentID = this.agentID; 61 subFold.agentID = agentID;
69 this.SubFolders.Add(subFold.folderID, subFold); 62 SubFolders.Add(subFold.folderID, subFold);
70 return subFold; 63 return subFold;
71 } 64 }
72 65
73 public InventoryItemBase HasItem(LLUUID itemID) 66 public InventoryItemBase HasItem(LLUUID itemID)
74 { 67 {
75 InventoryItemBase base2 = null; 68 InventoryItemBase base2 = null;
76 if (this.Items.ContainsKey(itemID)) 69 if (Items.ContainsKey(itemID))
77 { 70 {
78 return this.Items[itemID]; 71 return Items[itemID];
79 } 72 }
80 foreach (InventoryFolderImpl folder in this.SubFolders.Values) 73 foreach (InventoryFolderImpl folder in SubFolders.Values)
81 { 74 {
82 base2 = folder.HasItem(itemID); 75 base2 = folder.HasItem(itemID);
83 if (base2 != null) 76 if (base2 != null)
@@ -91,12 +84,12 @@ namespace OpenSim.Framework.Communications.Cache
91 public bool DeleteItem(LLUUID itemID) 84 public bool DeleteItem(LLUUID itemID)
92 { 85 {
93 bool found = false; 86 bool found = false;
94 if (this.Items.ContainsKey(itemID)) 87 if (Items.ContainsKey(itemID))
95 { 88 {
96 Items.Remove(itemID); 89 Items.Remove(itemID);
97 return true; 90 return true;
98 } 91 }
99 foreach (InventoryFolderImpl folder in this.SubFolders.Values) 92 foreach (InventoryFolderImpl folder in SubFolders.Values)
100 { 93 {
101 found = folder.DeleteItem(itemID); 94 found = folder.DeleteItem(itemID);
102 if (found == true) 95 if (found == true)
@@ -111,13 +104,13 @@ namespace OpenSim.Framework.Communications.Cache
111 public InventoryFolderImpl HasSubFolder(LLUUID folderID) 104 public InventoryFolderImpl HasSubFolder(LLUUID folderID)
112 { 105 {
113 InventoryFolderImpl returnFolder = null; 106 InventoryFolderImpl returnFolder = null;
114 if (this.SubFolders.ContainsKey(folderID)) 107 if (SubFolders.ContainsKey(folderID))
115 { 108 {
116 returnFolder = this.SubFolders[folderID]; 109 returnFolder = SubFolders[folderID];
117 } 110 }
118 else 111 else
119 { 112 {
120 foreach (InventoryFolderImpl folder in this.SubFolders.Values) 113 foreach (InventoryFolderImpl folder in SubFolders.Values)
121 { 114 {
122 returnFolder = folder.HasSubFolder(folderID); 115 returnFolder = folder.HasSubFolder(folderID);
123 if (returnFolder != null) 116 if (returnFolder != null)
@@ -132,7 +125,7 @@ namespace OpenSim.Framework.Communications.Cache
132 public List<InventoryItemBase> RequestListOfItems() 125 public List<InventoryItemBase> RequestListOfItems()
133 { 126 {
134 List<InventoryItemBase> itemList = new List<InventoryItemBase>(); 127 List<InventoryItemBase> itemList = new List<InventoryItemBase>();
135 foreach (InventoryItemBase item in this.Items.Values) 128 foreach (InventoryItemBase item in Items.Values)
136 { 129 {
137 itemList.Add(item); 130 itemList.Add(item);
138 } 131 }
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
index 60f9b6b..765c42e 100644
--- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
+++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
@@ -26,12 +26,8 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.IO; 29using System.IO;
31using System.Collections.Generic;
32using System.Text;
33using libsecondlife; 30using libsecondlife;
34using OpenSim.Framework;
35using Nini.Config; 31using Nini.Config;
36 32
37namespace OpenSim.Framework.Communications.Cache 33namespace OpenSim.Framework.Communications.Cache
@@ -40,43 +36,42 @@ namespace OpenSim.Framework.Communications.Cache
40 /// Basically a hack to give us a Inventory library while we don't have a inventory server 36 /// Basically a hack to give us a Inventory library while we don't have a inventory server
41 /// once the server is fully implemented then should read the data from that 37 /// once the server is fully implemented then should read the data from that
42 /// </summary> 38 /// </summary>
43 public class LibraryRootFolder : Cache.InventoryFolderImpl 39 public class LibraryRootFolder : InventoryFolderImpl
44 { 40 {
45 private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); 41 private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
46 private Cache.InventoryFolderImpl m_textureFolder; 42 private InventoryFolderImpl m_textureFolder;
47 43
48 public LibraryRootFolder() 44 public LibraryRootFolder()
49 { 45 {
50 this.agentID = libOwner; 46 agentID = libOwner;
51 this.folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); 47 folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
52 this.name = "OpenSim Library"; 48 name = "OpenSim Library";
53 this.parentID = LLUUID.Zero; 49 parentID = LLUUID.Zero;
54 this.type = (short)-1; 50 type = (short) -1;
55 this.version = (ushort)1; 51 version = (ushort) 1;
56 52
57 Cache.InventoryFolderImpl folderInfo = new InventoryFolderImpl(); 53 InventoryFolderImpl folderInfo = new InventoryFolderImpl();
58 folderInfo.agentID = libOwner; 54 folderInfo.agentID = libOwner;
59 folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); 55 folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001");
60 folderInfo.name = "Texture Library"; 56 folderInfo.name = "Texture Library";
61 folderInfo.parentID = this.folderID; 57 folderInfo.parentID = folderID;
62 folderInfo.type = -1; 58 folderInfo.type = -1;
63 folderInfo.version = 1; 59 folderInfo.version = 1;
64 this.SubFolders.Add(folderInfo.folderID, folderInfo); 60 SubFolders.Add(folderInfo.folderID, folderInfo);
65 this.m_textureFolder = folderInfo; 61 m_textureFolder = folderInfo;
66 62
67 this.CreateLibraryItems(); 63 CreateLibraryItems();
68 64
69 string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); 65 string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml");
70 if (File.Exists(filePath)) 66 if (File.Exists(filePath))
71 { 67 {
72 XmlConfigSource source = new XmlConfigSource(filePath); 68 XmlConfigSource source = new XmlConfigSource(filePath);
73 this.ReadItemsFromFile(source); 69 ReadItemsFromFile(source);
74 } 70 }
75 } 71 }
76 72
77 private void CreateLibraryItems() 73 private void CreateLibraryItems()
78 { 74 {
79
80 InventoryItemBase item = new InventoryItemBase(); 75 InventoryItemBase item = new InventoryItemBase();
81 item.avatarID = libOwner; 76 item.avatarID = libOwner;
82 item.creatorsID = libOwner; 77 item.creatorsID = libOwner;
@@ -90,7 +85,7 @@ namespace OpenSim.Framework.Communications.Cache
90 item.inventoryEveryOnePermissions = 0x7FFFFFFF; 85 item.inventoryEveryOnePermissions = 0x7FFFFFFF;
91 item.inventoryCurrentPermissions = 0x7FFFFFFF; 86 item.inventoryCurrentPermissions = 0x7FFFFFFF;
92 item.inventoryNextPermissions = 0x7FFFFFFF; 87 item.inventoryNextPermissions = 0x7FFFFFFF;
93 this.m_textureFolder.Items.Add(item.inventoryID, item); 88 m_textureFolder.Items.Add(item.inventoryID, item);
94 89
95 item = new InventoryItemBase(); 90 item = new InventoryItemBase();
96 item.avatarID = libOwner; 91 item.avatarID = libOwner;
@@ -105,7 +100,7 @@ namespace OpenSim.Framework.Communications.Cache
105 item.inventoryEveryOnePermissions = 0x7FFFFFFF; 100 item.inventoryEveryOnePermissions = 0x7FFFFFFF;
106 item.inventoryCurrentPermissions = 0x7FFFFFFF; 101 item.inventoryCurrentPermissions = 0x7FFFFFFF;
107 item.inventoryNextPermissions = 0x7FFFFFFF; 102 item.inventoryNextPermissions = 0x7FFFFFFF;
108 this.m_textureFolder.Items.Add(item.inventoryID, item); 103 m_textureFolder.Items.Add(item.inventoryID, item);
109 104
110 item = new InventoryItemBase(); 105 item = new InventoryItemBase();
111 item.avatarID = libOwner; 106 item.avatarID = libOwner;
@@ -120,7 +115,7 @@ namespace OpenSim.Framework.Communications.Cache
120 item.inventoryEveryOnePermissions = 0x7FFFFFFF; 115 item.inventoryEveryOnePermissions = 0x7FFFFFFF;
121 item.inventoryCurrentPermissions = 0x7FFFFFFF; 116 item.inventoryCurrentPermissions = 0x7FFFFFFF;
122 item.inventoryNextPermissions = 0x7FFFFFFF; 117 item.inventoryNextPermissions = 0x7FFFFFFF;
123 this.m_textureFolder.Items.Add(item.inventoryID, item); 118 m_textureFolder.Items.Add(item.inventoryID, item);
124 119
125 item = new InventoryItemBase(); 120 item = new InventoryItemBase();
126 item.avatarID = libOwner; 121 item.avatarID = libOwner;
@@ -135,7 +130,7 @@ namespace OpenSim.Framework.Communications.Cache
135 item.inventoryEveryOnePermissions = 0x7FFFFFFF; 130 item.inventoryEveryOnePermissions = 0x7FFFFFFF;
136 item.inventoryCurrentPermissions = 0x7FFFFFFF; 131 item.inventoryCurrentPermissions = 0x7FFFFFFF;
137 item.inventoryNextPermissions = 0x7FFFFFFF; 132 item.inventoryNextPermissions = 0x7FFFFFFF;
138 this.m_textureFolder.Items.Add(item.inventoryID, item); 133 m_textureFolder.Items.Add(item.inventoryID, item);
139 134
140 item = new InventoryItemBase(); 135 item = new InventoryItemBase();
141 item.avatarID = libOwner; 136 item.avatarID = libOwner;
@@ -150,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache
150 item.inventoryEveryOnePermissions = 0x7FFFFFFF; 145 item.inventoryEveryOnePermissions = 0x7FFFFFFF;
151 item.inventoryCurrentPermissions = 0x7FFFFFFF; 146 item.inventoryCurrentPermissions = 0x7FFFFFFF;
152 item.inventoryNextPermissions = 0x7FFFFFFF; 147 item.inventoryNextPermissions = 0x7FFFFFFF;
153 this.m_textureFolder.Items.Add(item.inventoryID, item); 148 m_textureFolder.Items.Add(item.inventoryID, item);
154 149
155 item = new InventoryItemBase(); 150 item = new InventoryItemBase();
156 item.avatarID = libOwner; 151 item.avatarID = libOwner;
@@ -161,10 +156,10 @@ namespace OpenSim.Framework.Communications.Cache
161 item.inventoryName = "Default Shape"; 156 item.inventoryName = "Default Shape";
162 item.assetType = 13; 157 item.assetType = 13;
163 item.invType = 18; 158 item.invType = 18;
164 item.parentFolderID = this.folderID; 159 item.parentFolderID = folderID;
165 item.inventoryCurrentPermissions = 0; 160 item.inventoryCurrentPermissions = 0;
166 item.inventoryNextPermissions = 0; 161 item.inventoryNextPermissions = 0;
167 this.Items.Add(item.inventoryID, item); 162 Items.Add(item.inventoryID, item);
168 163
169 item = new InventoryItemBase(); 164 item = new InventoryItemBase();
170 item.avatarID = libOwner; 165 item.avatarID = libOwner;
@@ -175,10 +170,10 @@ namespace OpenSim.Framework.Communications.Cache
175 item.inventoryName = "Default Skin"; 170 item.inventoryName = "Default Skin";
176 item.assetType = 13; 171 item.assetType = 13;
177 item.invType = 18; 172 item.invType = 18;
178 item.parentFolderID = this.folderID; 173 item.parentFolderID = folderID;
179 item.inventoryCurrentPermissions = 0; 174 item.inventoryCurrentPermissions = 0;
180 item.inventoryNextPermissions = 0; 175 item.inventoryNextPermissions = 0;
181 this.Items.Add(item.inventoryID, item); 176 Items.Add(item.inventoryID, item);
182 177
183 item = new InventoryItemBase(); 178 item = new InventoryItemBase();
184 item.avatarID = libOwner; 179 item.avatarID = libOwner;
@@ -189,10 +184,10 @@ namespace OpenSim.Framework.Communications.Cache
189 item.inventoryName = "Default Shirt"; 184 item.inventoryName = "Default Shirt";
190 item.assetType = 5; 185 item.assetType = 5;
191 item.invType = 18; 186 item.invType = 18;
192 item.parentFolderID = this.folderID; 187 item.parentFolderID = folderID;
193 item.inventoryCurrentPermissions = 0; 188 item.inventoryCurrentPermissions = 0;
194 item.inventoryNextPermissions = 0; 189 item.inventoryNextPermissions = 0;
195 this.Items.Add(item.inventoryID, item); 190 Items.Add(item.inventoryID, item);
196 191
197 item = new InventoryItemBase(); 192 item = new InventoryItemBase();
198 item.avatarID = libOwner; 193 item.avatarID = libOwner;
@@ -203,11 +198,10 @@ namespace OpenSim.Framework.Communications.Cache
203 item.inventoryName = "Default Pants"; 198 item.inventoryName = "Default Pants";
204 item.assetType = 5; 199 item.assetType = 5;
205 item.invType = 18; 200 item.invType = 18;
206 item.parentFolderID = this.folderID; 201 item.parentFolderID = folderID;
207 item.inventoryCurrentPermissions = 0; 202 item.inventoryCurrentPermissions = 0;
208 item.inventoryNextPermissions = 0; 203 item.inventoryNextPermissions = 0;
209 this.Items.Add(item.inventoryID, item); 204 Items.Add(item.inventoryID, item);
210
211 } 205 }
212 206
213 private void ReadItemsFromFile(IConfigSource source) 207 private void ReadItemsFromFile(IConfigSource source)
@@ -217,28 +211,28 @@ namespace OpenSim.Framework.Communications.Cache
217 InventoryItemBase item = new InventoryItemBase(); 211 InventoryItemBase item = new InventoryItemBase();
218 item.avatarID = libOwner; 212 item.avatarID = libOwner;
219 item.creatorsID = libOwner; 213 item.creatorsID = libOwner;
220 item.inventoryID = new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated())); 214 item.inventoryID =
215 new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated()));
221 item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); 216 item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()));
222 item.inventoryDescription = source.Configs[i].GetString("description", ""); 217 item.inventoryDescription = source.Configs[i].GetString("description", "");
223 item.inventoryName = source.Configs[i].GetString("name", ""); 218 item.inventoryName = source.Configs[i].GetString("name", "");
224 item.assetType = source.Configs[i].GetInt("assetType", 0); 219 item.assetType = source.Configs[i].GetInt("assetType", 0);
225 item.invType = source.Configs[i].GetInt("inventoryType", 0); 220 item.invType = source.Configs[i].GetInt("inventoryType", 0);
226 item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); 221 item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF);
227 item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); 222 item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF);
228 item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); 223 item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF);
229 item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); 224 item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF);
230 if (item.assetType == 0) 225 if (item.assetType == 0)
231 { 226 {
232 item.parentFolderID = this.m_textureFolder.folderID; 227 item.parentFolderID = m_textureFolder.folderID;
233 this.m_textureFolder.Items.Add(item.inventoryID, item); 228 m_textureFolder.Items.Add(item.inventoryID, item);
234 } 229 }
235 else 230 else
236 { 231 {
237 item.parentFolderID = this.folderID; 232 item.parentFolderID = folderID;
238 this.Items.Add(item.inventoryID, item); 233 Items.Add(item.inventoryID, item);
239 } 234 }
240 } 235 }
241 } 236 }
242
243 } 237 }
244} \ No newline at end of file 238} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index 0953e19..b4f29db 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -26,14 +26,8 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO;
30using System.Threading;
31using System.Reflection; 29using System.Reflection;
32using libsecondlife;
33using Nini.Config;
34using OpenSim.Framework.Console; 30using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework;
37 31
38namespace OpenSim.Framework.Communications.Cache 32namespace OpenSim.Framework.Communications.Cache
39{ 33{
@@ -62,11 +56,14 @@ namespace OpenSim.Framework.Communications.Cache
62 56
63 if (typeInterface != null) 57 if (typeInterface != null)
64 { 58 {
65 IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 59 IAssetProvider plug =
60 (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
66 m_assetProviderPlugin = plug; 61 m_assetProviderPlugin = plug;
67 m_assetProviderPlugin.Initialise(); 62 m_assetProviderPlugin.Initialise();
68 63
69 MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); 64 MainLog.Instance.Verbose("AssetStorage",
65 "Added " + m_assetProviderPlugin.Name + " " +
66 m_assetProviderPlugin.Version);
70 } 67 }
71 68
72 typeInterface = null; 69 typeInterface = null;
@@ -84,13 +81,13 @@ namespace OpenSim.Framework.Communications.Cache
84 m_assetProviderPlugin.CommitAssets(); 81 m_assetProviderPlugin.CommitAssets();
85 } 82 }
86 83
87 override protected void RunRequests() 84 protected override void RunRequests()
88 { 85 {
89 while (true) 86 while (true)
90 { 87 {
91 ARequest req = this._assetRequests.Dequeue(); 88 ARequest req = _assetRequests.Dequeue();
92 89
93 //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); 90 //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
94 91
95 AssetBase asset = null; 92 AssetBase asset = null;
96 lock (syncLock) 93 lock (syncLock)
@@ -105,9 +102,7 @@ namespace OpenSim.Framework.Communications.Cache
105 { 102 {
106 _receiver.AssetNotFound(req.AssetID); 103 _receiver.AssetNotFound(req.AssetID);
107 } 104 }
108
109 } 105 }
110
111 } 106 }
112 107
113 protected override void StoreAsset(AssetBase asset) 108 protected override void StoreAsset(AssetBase asset)
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
index 8105556..fe943b0 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
@@ -25,16 +25,8 @@
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;
29using System.Collections;
30using System.Collections.Generic; 28using System.Collections.Generic;
31using System.Text;
32using System.IO;
33using libsecondlife; 29using libsecondlife;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework;
37
38 30
39namespace OpenSim.Framework.Communications.Cache 31namespace OpenSim.Framework.Communications.Cache
40{ 32{
@@ -49,7 +41,7 @@ namespace OpenSim.Framework.Communications.Cache
49 // Methods 41 // Methods
50 public UserProfileCache(CommunicationsManager parent) 42 public UserProfileCache(CommunicationsManager parent)
51 { 43 {
52 this.m_parent = parent; 44 m_parent = parent;
53 } 45 }
54 46
55 /// <summary> 47 /// <summary>
@@ -62,14 +54,14 @@ namespace OpenSim.Framework.Communications.Cache
62 // Potential fix - Multithreading issue. 54 // Potential fix - Multithreading issue.
63 lock (UserProfiles) 55 lock (UserProfiles)
64 { 56 {
65 if (!this.UserProfiles.ContainsKey(userID)) 57 if (!UserProfiles.ContainsKey(userID))
66 { 58 {
67 CachedUserInfo userInfo = new CachedUserInfo(this.m_parent); 59 CachedUserInfo userInfo = new CachedUserInfo(m_parent);
68 userInfo.UserProfile = this.RequestUserProfileForUser(userID); 60 userInfo.UserProfile = RequestUserProfileForUser(userID);
69 if (userInfo.UserProfile != null) 61 if (userInfo.UserProfile != null)
70 { 62 {
71 this.RequestInventoryForUser(userID, userInfo); 63 RequestInventoryForUser(userID, userInfo);
72 this.UserProfiles.Add(userID, userInfo); 64 UserProfiles.Add(userID, userInfo);
73 } 65 }
74 else 66 else
75 { 67 {
@@ -91,26 +83,28 @@ namespace OpenSim.Framework.Communications.Cache
91 83
92 public CachedUserInfo GetUserDetails(LLUUID userID) 84 public CachedUserInfo GetUserDetails(LLUUID userID)
93 { 85 {
94 if (this.UserProfiles.ContainsKey(userID)) 86 if (UserProfiles.ContainsKey(userID))
95 { 87 {
96 return this.UserProfiles[userID]; 88 return UserProfiles[userID];
97 } 89 }
98 return null; 90 return null;
99 } 91 }
100 92
101 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) 93 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
94 string folderName, LLUUID parentID)
102 { 95 {
103 if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 96 if (UserProfiles.ContainsKey(remoteClient.AgentId))
104 { 97 {
105 if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) 98 if (UserProfiles[remoteClient.AgentId].RootFolder != null)
106 { 99 {
107 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; 100 CachedUserInfo info = UserProfiles[remoteClient.AgentId];
108 if (info.RootFolder.folderID == parentID) 101 if (info.RootFolder.folderID == parentID)
109 { 102 {
110 InventoryFolderImpl createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); 103 InventoryFolderImpl createdFolder =
104 info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
111 if (createdFolder != null) 105 if (createdFolder != null)
112 { 106 {
113 this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); 107 m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder);
114 } 108 }
115 } 109 }
116 else 110 else
@@ -125,27 +119,30 @@ namespace OpenSim.Framework.Communications.Cache
125 } 119 }
126 } 120 }
127 121
128 public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) 122 public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID,
123 bool fetchFolders, bool fetchItems, int sortOrder)
129 { 124 {
130 InventoryFolderImpl fold = null; 125 InventoryFolderImpl fold = null;
131 if (folderID == libraryRoot.folderID ) 126 if (folderID == libraryRoot.folderID)
132 { 127 {
133 remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); 128 remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID,
129 libraryRoot.RequestListOfItems());
134 } 130 }
135 else if (( fold = libraryRoot.HasSubFolder(folderID)) != null) 131 else if ((fold = libraryRoot.HasSubFolder(folderID)) != null)
136 { 132 {
137 remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); 133 remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems());
138 } 134 }
139 else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 135 else if (UserProfiles.ContainsKey(remoteClient.AgentId))
140 { 136 {
141 if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) 137 if (UserProfiles[remoteClient.AgentId].RootFolder != null)
142 { 138 {
143 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; 139 CachedUserInfo info = UserProfiles[remoteClient.AgentId];
144 if (info.RootFolder.folderID == folderID) 140 if (info.RootFolder.folderID == folderID)
145 { 141 {
146 if (fetchItems) 142 if (fetchItems)
147 { 143 {
148 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); 144 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID,
145 info.RootFolder.RequestListOfItems());
149 } 146 }
150 } 147 }
151 else 148 else
@@ -153,7 +150,8 @@ namespace OpenSim.Framework.Communications.Cache
153 InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID); 150 InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID);
154 if ((folder != null) && fetchItems) 151 if ((folder != null) && fetchItems)
155 { 152 {
156 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); 153 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID,
154 folder.RequestListOfItems());
157 } 155 }
158 } 156 }
159 } 157 }
@@ -166,11 +164,11 @@ namespace OpenSim.Framework.Communications.Cache
166 { 164 {
167 //Console.WriteLine("request info for library item"); 165 //Console.WriteLine("request info for library item");
168 } 166 }
169 else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 167 else if (UserProfiles.ContainsKey(remoteClient.AgentId))
170 { 168 {
171 if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) 169 if (UserProfiles[remoteClient.AgentId].RootFolder != null)
172 { 170 {
173 InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); 171 InventoryItemBase item = UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID);
174 if (item != null) 172 if (item != null)
175 { 173 {
176 remoteClient.SendInventoryItemDetails(ownerID, item); 174 remoteClient.SendInventoryItemDetails(ownerID, item);
@@ -185,7 +183,7 @@ namespace OpenSim.Framework.Communications.Cache
185 /// <param name="userID"></param> 183 /// <param name="userID"></param>
186 private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) 184 private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
187 { 185 {
188 this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); 186 m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
189 } 187 }
190 188
191 /// <summary> 189 /// <summary>
@@ -194,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache
194 /// <param name="userID"></param> 192 /// <param name="userID"></param>
195 private UserProfileData RequestUserProfileForUser(LLUUID userID) 193 private UserProfileData RequestUserProfileForUser(LLUUID userID)
196 { 194 {
197 return this.m_parent.UserService.GetUserProfile(userID); 195 return m_parent.UserService.GetUserProfile(userID);
198 } 196 }
199 197
200 /// <summary> 198 /// <summary>