aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorMW2007-07-25 18:19:38 +0000
committerMW2007-07-25 18:19:38 +0000
commit2b42ea0a429c722bd7c5c67d3815c2ddc8399e78 (patch)
tree0a6338ff52efbdaadaa9a307bee618867460cfb6 /OpenSim/Framework/Communications
parent* Terrain now uses the older slower method again until the fast version can b... (diff)
downloadopensim-SC_OLD-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.zip
opensim-SC_OLD-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.gz
opensim-SC_OLD-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.bz2
opensim-SC_OLD-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.xz
Start of the OpenSim library , for now only contains a few textures.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs1122
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs162
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactions.cs548
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs188
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolder.cs218
-rw-r--r--OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs89
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCache.cs386
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs25
8 files changed, 1440 insertions, 1298 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 3d0fd76..a3480ec 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -1,561 +1,561 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.Reflection; 32using System.Reflection;
33using System.Threading; 33using System.Threading;
34using libsecondlife; 34using libsecondlife;
35using libsecondlife.Packets; 35using libsecondlife.Packets;
36using OpenSim.Framework.Interfaces; 36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Types; 38using OpenSim.Framework.Types;
39using OpenSim.Framework.Utilities; 39using OpenSim.Framework.Utilities;
40 40
41namespace OpenSim.Framework.Communications.Caches 41namespace OpenSim.Framework.Communications.Caches
42{ 42{
43 public delegate void DownloadComplete(AssetCache.TextureSender sender); 43 public delegate void DownloadComplete(AssetCache.TextureSender sender);
44 44
45 public class AssetCache : IAssetReceiver 45 public class AssetCache : IAssetReceiver
46 { 46 {
47 // Fields 47 // Fields
48 private Thread _assetCacheThread; 48 private Thread _assetCacheThread;
49 private IAssetServer _assetServer; 49 private IAssetServer _assetServer;
50 public List<AssetRequest> AssetRequests; 50 public List<AssetRequest> AssetRequests;
51 public Dictionary<LLUUID, AssetInfo> Assets; 51 public Dictionary<LLUUID, AssetInfo> Assets;
52 public Dictionary<LLUUID, AssetRequest> RequestedAssets; 52 public Dictionary<LLUUID, AssetRequest> RequestedAssets;
53 public Dictionary<LLUUID, AssetRequest> RequestedTextures; 53 public Dictionary<LLUUID, AssetRequest> RequestedTextures;
54 public Dictionary<LLUUID, TextureSender> SendingTextures; 54 public Dictionary<LLUUID, TextureSender> SendingTextures;
55 private LLUUID[] textureList; 55 private LLUUID[] textureList;
56 public List<AssetRequest> TextureRequests; 56 public List<AssetRequest> TextureRequests;
57 public Dictionary<LLUUID, TextureImage> Textures; 57 public Dictionary<LLUUID, TextureImage> Textures;
58 58
59 // Methods 59 // Methods
60 public AssetCache(IAssetServer assetServer) 60 public AssetCache(IAssetServer assetServer)
61 { 61 {
62 this.AssetRequests = new List<AssetRequest>(); 62 this.AssetRequests = new List<AssetRequest>();
63 this.TextureRequests = new List<AssetRequest>(); 63 this.TextureRequests = new List<AssetRequest>();
64 this.RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); 64 this.RequestedAssets = new Dictionary<LLUUID, AssetRequest>();
65 this.RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); 65 this.RequestedTextures = new Dictionary<LLUUID, AssetRequest>();
66 this.SendingTextures = new Dictionary<LLUUID, TextureSender>(); 66 this.SendingTextures = new Dictionary<LLUUID, TextureSender>();
67 this.textureList = new LLUUID[5]; 67 this.textureList = new LLUUID[5];
68 Console.WriteLine("Creating Asset cache"); 68 Console.WriteLine("Creating Asset cache");
69 this._assetServer = assetServer; 69 this._assetServer = assetServer;
70 this._assetServer.SetReceiver(this); 70 this._assetServer.SetReceiver(this);
71 this.Assets = new Dictionary<LLUUID, AssetInfo>(); 71 this.Assets = new Dictionary<LLUUID, AssetInfo>();
72 this.Textures = new Dictionary<LLUUID, TextureImage>(); 72 this.Textures = new Dictionary<LLUUID, TextureImage>();
73 this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); 73 this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager));
74 this._assetCacheThread.IsBackground = true; 74 this._assetCacheThread.IsBackground = true;
75 this._assetCacheThread.Start(); 75 this._assetCacheThread.Start();
76 } 76 }
77 77
78 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) 78 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey)
79 { 79 {
80 this.AssetRequests = new List<AssetRequest>(); 80 this.AssetRequests = new List<AssetRequest>();
81 this.TextureRequests = new List<AssetRequest>(); 81 this.TextureRequests = new List<AssetRequest>();
82 this.RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); 82 this.RequestedAssets = new Dictionary<LLUUID, AssetRequest>();
83 this.RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); 83 this.RequestedTextures = new Dictionary<LLUUID, AssetRequest>();
84 this.SendingTextures = new Dictionary<LLUUID, TextureSender>(); 84 this.SendingTextures = new Dictionary<LLUUID, TextureSender>();
85 this.textureList = new LLUUID[5]; 85 this.textureList = new LLUUID[5];
86 Console.WriteLine("Creating Asset cache"); 86 Console.WriteLine("Creating Asset cache");
87 this._assetServer = this.LoadAssetDll(assetServerDLLName); 87 this._assetServer = this.LoadAssetDll(assetServerDLLName);
88 this._assetServer.SetServerInfo(assetServerURL, assetServerKey); 88 this._assetServer.SetServerInfo(assetServerURL, assetServerKey);
89 this._assetServer.SetReceiver(this); 89 this._assetServer.SetReceiver(this);
90 this.Assets = new Dictionary<LLUUID, AssetInfo>(); 90 this.Assets = new Dictionary<LLUUID, AssetInfo>();
91 this.Textures = new Dictionary<LLUUID, TextureImage>(); 91 this.Textures = new Dictionary<LLUUID, TextureImage>();
92 this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); 92 this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager));
93 this._assetCacheThread.IsBackground = true; 93 this._assetCacheThread.IsBackground = true;
94 this._assetCacheThread.Start(); 94 this._assetCacheThread.Start();
95 } 95 }
96 96
97 public void AddAsset(AssetBase asset) 97 public void AddAsset(AssetBase asset)
98 { 98 {
99 if (asset.Type == 0) 99 if (asset.Type == 0)
100 { 100 {
101 if (!this.Textures.ContainsKey(asset.FullID)) 101 if (!this.Textures.ContainsKey(asset.FullID))
102 { 102 {
103 TextureImage image = new TextureImage(asset); 103 TextureImage image = new TextureImage(asset);
104 this.Textures.Add(image.FullID, image); 104 this.Textures.Add(image.FullID, image);
105 this._assetServer.UploadNewAsset(asset); 105 this._assetServer.UploadNewAsset(asset);
106 } 106 }
107 } 107 }
108 else if (!this.Assets.ContainsKey(asset.FullID)) 108 else if (!this.Assets.ContainsKey(asset.FullID))
109 { 109 {
110 AssetInfo info = new AssetInfo(asset); 110 AssetInfo info = new AssetInfo(asset);
111 this.Assets.Add(info.FullID, info); 111 this.Assets.Add(info.FullID, info);
112 this._assetServer.UploadNewAsset(asset); 112 this._assetServer.UploadNewAsset(asset);
113 } 113 }
114 } 114 }
115 115
116 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) 116 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest)
117 { 117 {
118 LLUUID assetID = new LLUUID(transferRequest.TransferInfo.Params, 0); 118 LLUUID assetID = new LLUUID(transferRequest.TransferInfo.Params, 0);
119 if (!this.Assets.ContainsKey(assetID)) 119 if (!this.Assets.ContainsKey(assetID))
120 { 120 {
121 if (!this.RequestedAssets.ContainsKey(assetID)) 121 if (!this.RequestedAssets.ContainsKey(assetID))
122 { 122 {
123 AssetRequest request = new AssetRequest(); 123 AssetRequest request = new AssetRequest();
124 request.RequestUser = userInfo; 124 request.RequestUser = userInfo;
125 request.RequestAssetID = assetID; 125 request.RequestAssetID = assetID;
126 request.TransferRequestID = transferRequest.TransferInfo.TransferID; 126 request.TransferRequestID = transferRequest.TransferInfo.TransferID;
127 this.RequestedAssets.Add(assetID, request); 127 this.RequestedAssets.Add(assetID, request);
128 this._assetServer.RequestAsset(assetID, false); 128 this._assetServer.RequestAsset(assetID, false);
129 } 129 }
130 } 130 }
131 else 131 else
132 { 132 {
133 AssetInfo info = this.Assets[assetID]; 133 AssetInfo info = this.Assets[assetID];
134 AssetRequest request2 = new AssetRequest(); 134 AssetRequest request2 = new AssetRequest();
135 request2.RequestUser = userInfo; 135 request2.RequestUser = userInfo;
136 request2.RequestAssetID = assetID; 136 request2.RequestAssetID = assetID;
137 request2.TransferRequestID = transferRequest.TransferInfo.TransferID; 137 request2.TransferRequestID = transferRequest.TransferInfo.TransferID;
138 request2.AssetInf = info; 138 request2.AssetInf = info;
139 if (info.Data.LongLength > 600) 139 if (info.Data.LongLength > 600)
140 { 140 {
141 request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); 141 request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8);
142 } 142 }
143 else 143 else
144 { 144 {
145 request2.NumPackets = 1; 145 request2.NumPackets = 1;
146 } 146 }
147 this.AssetRequests.Add(request2); 147 this.AssetRequests.Add(request2);
148 } 148 }
149 } 149 }
150 150
151 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) 151 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID)
152 { 152 {
153 if (!this.Textures.ContainsKey(imageID)) 153 if (!this.Textures.ContainsKey(imageID))
154 { 154 {
155 if (!this.RequestedTextures.ContainsKey(imageID)) 155 if (!this.RequestedTextures.ContainsKey(imageID))
156 { 156 {
157 AssetRequest request = new AssetRequest(); 157 AssetRequest request = new AssetRequest();
158 request.RequestUser = userInfo; 158 request.RequestUser = userInfo;
159 request.RequestAssetID = imageID; 159 request.RequestAssetID = imageID;
160 request.IsTextureRequest = true; 160 request.IsTextureRequest = true;
161 this.RequestedTextures.Add(imageID, request); 161 this.RequestedTextures.Add(imageID, request);
162 this._assetServer.RequestAsset(imageID, true); 162 this._assetServer.RequestAsset(imageID, true);
163 } 163 }
164 } 164 }
165 else 165 else
166 { 166 {
167 TextureImage image = this.Textures[imageID]; 167 TextureImage image = this.Textures[imageID];
168 AssetRequest request2 = new AssetRequest(); 168 AssetRequest request2 = new AssetRequest();
169 request2.RequestUser = userInfo; 169 request2.RequestUser = userInfo;
170 request2.RequestAssetID = imageID; 170 request2.RequestAssetID = imageID;
171 request2.IsTextureRequest = true; 171 request2.IsTextureRequest = true;
172 request2.ImageInfo = image; 172 request2.ImageInfo = image;
173 if (image.Data.LongLength > 600) 173 if (image.Data.LongLength > 600)
174 { 174 {
175 request2.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); 175 request2.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8);
176 } 176 }
177 else 177 else
178 { 178 {
179 request2.NumPackets = 1; 179 request2.NumPackets = 1;
180 } 180 }
181 this.TextureRequests.Add(request2); 181 this.TextureRequests.Add(request2);
182 } 182 }
183 } 183 }
184 184
185 public void AssetNotFound(AssetBase asset) 185 public void AssetNotFound(AssetBase asset)
186 { 186 {
187 } 187 }
188 188
189 public void AssetReceived(AssetBase asset, bool IsTexture) 189 public void AssetReceived(AssetBase asset, bool IsTexture)
190 { 190 {
191 if (asset.FullID != LLUUID.Zero) 191 if (asset.FullID != LLUUID.Zero)
192 { 192 {
193 if (IsTexture) 193 if (IsTexture)
194 { 194 {
195 TextureImage image = new TextureImage(asset); 195 TextureImage image = new TextureImage(asset);
196 this.Textures.Add(image.FullID, image); 196 this.Textures.Add(image.FullID, image);
197 if (this.RequestedTextures.ContainsKey(image.FullID)) 197 if (this.RequestedTextures.ContainsKey(image.FullID))
198 { 198 {
199 AssetRequest request = this.RequestedTextures[image.FullID]; 199 AssetRequest request = this.RequestedTextures[image.FullID];
200 request.ImageInfo = image; 200 request.ImageInfo = image;
201 if (image.Data.LongLength > 600) 201 if (image.Data.LongLength > 600)
202 { 202 {
203 request.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); 203 request.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8);
204 } 204 }
205 else 205 else
206 { 206 {
207 request.NumPackets = 1; 207 request.NumPackets = 1;
208 } 208 }
209 this.RequestedTextures.Remove(image.FullID); 209 this.RequestedTextures.Remove(image.FullID);
210 this.TextureRequests.Add(request); 210 this.TextureRequests.Add(request);
211 } 211 }
212 } 212 }
213 else 213 else
214 { 214 {
215 AssetInfo info = new AssetInfo(asset); 215 AssetInfo info = new AssetInfo(asset);
216 this.Assets.Add(info.FullID, info); 216 this.Assets.Add(info.FullID, info);
217 if (this.RequestedAssets.ContainsKey(info.FullID)) 217 if (this.RequestedAssets.ContainsKey(info.FullID))
218 { 218 {
219 AssetRequest request2 = this.RequestedAssets[info.FullID]; 219 AssetRequest request2 = this.RequestedAssets[info.FullID];
220 request2.AssetInf = info; 220 request2.AssetInf = info;
221 if (info.Data.LongLength > 600) 221 if (info.Data.LongLength > 600)
222 { 222 {
223 request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); 223 request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8);
224 } 224 }
225 else 225 else
226 { 226 {
227 request2.NumPackets = 1; 227 request2.NumPackets = 1;
228 } 228 }
229 this.RequestedAssets.Remove(info.FullID); 229 this.RequestedAssets.Remove(info.FullID);
230 this.AssetRequests.Add(request2); 230 this.AssetRequests.Add(request2);
231 } 231 }
232 } 232 }
233 } 233 }
234 } 234 }
235 235
236 public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) 236 public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset)
237 { 237 {
238 AssetInfo info = new AssetInfo(); 238 AssetInfo info = new AssetInfo();
239 info.Data = new byte[sourceAsset.Data.Length]; 239 info.Data = new byte[sourceAsset.Data.Length];
240 Array.Copy(sourceAsset.Data, info.Data, sourceAsset.Data.Length); 240 Array.Copy(sourceAsset.Data, info.Data, sourceAsset.Data.Length);
241 info.FullID = LLUUID.Random(); 241 info.FullID = LLUUID.Random();
242 info.Type = sourceAsset.Type; 242 info.Type = sourceAsset.Type;
243 info.InvType = sourceAsset.InvType; 243 info.InvType = sourceAsset.InvType;
244 return info; 244 return info;
245 } 245 }
246 246
247 public TextureImage CloneImage(LLUUID newOwner, TextureImage source) 247 public TextureImage CloneImage(LLUUID newOwner, TextureImage source)
248 { 248 {
249 TextureImage image = new TextureImage(); 249 TextureImage image = new TextureImage();
250 image.Data = new byte[source.Data.Length]; 250 image.Data = new byte[source.Data.Length];
251 Array.Copy(source.Data, image.Data, source.Data.Length); 251 Array.Copy(source.Data, image.Data, source.Data.Length);
252 image.FullID = LLUUID.Random(); 252 image.FullID = LLUUID.Random();
253 image.Name = source.Name; 253 image.Name = source.Name;
254 return image; 254 return image;
255 } 255 }
256 256
257 public AssetBase[] CreateNewInventorySet(LLUUID agentID) 257 public AssetBase[] CreateNewInventorySet(LLUUID agentID)
258 { 258 {
259 AssetBase[] baseArray = new AssetBase[this.textureList.Length]; 259 AssetBase[] baseArray = new AssetBase[this.textureList.Length];
260 for (int i = 0; i < this.textureList.Length; i++) 260 for (int i = 0; i < this.textureList.Length; i++)
261 { 261 {
262 if (this.Textures.ContainsKey(this.textureList[i])) 262 if (this.Textures.ContainsKey(this.textureList[i]))
263 { 263 {
264 baseArray[i] = this.CloneImage(agentID, this.Textures[this.textureList[i]]); 264 baseArray[i] = this.CloneImage(agentID, this.Textures[this.textureList[i]]);
265 TextureImage asset = new TextureImage(baseArray[i]); 265 TextureImage asset = new TextureImage(baseArray[i]);
266 this.Textures.Add(asset.FullID, asset); 266 this.Textures.Add(asset.FullID, asset);
267 this._assetServer.UploadNewAsset(asset); 267 this._assetServer.UploadNewAsset(asset);
268 } 268 }
269 } 269 }
270 return baseArray; 270 return baseArray;
271 } 271 }
272 272
273 public AssetBase GetAsset(LLUUID assetID) 273 public AssetBase GetAsset(LLUUID assetID)
274 { 274 {
275 AssetBase base2 = null; 275 AssetBase base2 = null;
276 if (this.Textures.ContainsKey(assetID)) 276 if (this.Textures.ContainsKey(assetID))
277 { 277 {
278 return this.Textures[assetID]; 278 return this.Textures[assetID];
279 } 279 }
280 if (this.Assets.ContainsKey(assetID)) 280 if (this.Assets.ContainsKey(assetID))
281 { 281 {
282 base2 = this.Assets[assetID]; 282 base2 = this.Assets[assetID];
283 } 283 }
284 return base2; 284 return base2;
285 } 285 }
286 286
287 private IAssetServer LoadAssetDll(string dllName) 287 private IAssetServer LoadAssetDll(string dllName)
288 { 288 {
289 Assembly assembly = Assembly.LoadFrom(dllName); 289 Assembly assembly = Assembly.LoadFrom(dllName);
290 IAssetServer assetServer = null; 290 IAssetServer assetServer = null;
291 foreach (Type type in assembly.GetTypes()) 291 foreach (Type type in assembly.GetTypes())
292 { 292 {
293 if (type.IsPublic && !type.IsAbstract) 293 if (type.IsPublic && !type.IsAbstract)
294 { 294 {
295 if (type.GetInterface("IAssetPlugin", true) != null) 295 if (type.GetInterface("IAssetPlugin", true) != null)
296 { 296 {
297 assetServer = ((IAssetPlugin)Activator.CreateInstance(assembly.GetType(type.ToString()))).GetAssetServer(); 297 assetServer = ((IAssetPlugin)Activator.CreateInstance(assembly.GetType(type.ToString()))).GetAssetServer();
298 break; 298 break;
299 } 299 }
300 } 300 }
301 } 301 }
302 assembly = null; 302 assembly = null;
303 return assetServer; 303 return assetServer;
304 } 304 }
305 305
306 public void LoadDefaultTextureSet() 306 public void LoadDefaultTextureSet()
307 { 307 {
308 this.textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); 308 this.textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001");
309 this.textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); 309 this.textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002");
310 this.textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); 310 this.textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003");
311 this.textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); 311 this.textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004");
312 this.textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); 312 this.textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005");
313 for (int i = 0; i < this.textureList.Length; i++) 313 for (int i = 0; i < this.textureList.Length; i++)
314 { 314 {
315 this._assetServer.RequestAsset(this.textureList[i], true); 315 this._assetServer.RequestAsset(this.textureList[i], true);
316 } 316 }
317 } 317 }
318 318
319 private void ProcessAssetQueue() 319 private void ProcessAssetQueue()
320 { 320 {
321 if (this.AssetRequests.Count != 0) 321 if (this.AssetRequests.Count != 0)
322 { 322 {
323 int num; 323 int num;
324 if (this.AssetRequests.Count < 5) 324 if (this.AssetRequests.Count < 5)
325 { 325 {
326 num = this.AssetRequests.Count; 326 num = this.AssetRequests.Count;
327 } 327 }
328 else 328 else
329 { 329 {
330 num = 5; 330 num = 5;
331 } 331 }
332 for (int i = 0; i < num; i++) 332 for (int i = 0; i < num; i++)
333 { 333 {
334 AssetRequest request = this.AssetRequests[i]; 334 AssetRequest request = this.AssetRequests[i];
335 TransferInfoPacket newPack = new TransferInfoPacket(); 335 TransferInfoPacket newPack = new TransferInfoPacket();
336 newPack.TransferInfo.ChannelType = 2; 336 newPack.TransferInfo.ChannelType = 2;
337 newPack.TransferInfo.Status = 0; 337 newPack.TransferInfo.Status = 0;
338 newPack.TransferInfo.TargetType = 0; 338 newPack.TransferInfo.TargetType = 0;
339 newPack.TransferInfo.Params = request.RequestAssetID.GetBytes(); 339 newPack.TransferInfo.Params = request.RequestAssetID.GetBytes();
340 newPack.TransferInfo.Size = request.AssetInf.Data.Length; 340 newPack.TransferInfo.Size = request.AssetInf.Data.Length;
341 newPack.TransferInfo.TransferID = request.TransferRequestID; 341 newPack.TransferInfo.TransferID = request.TransferRequestID;
342 request.RequestUser.OutPacket(newPack); 342 request.RequestUser.OutPacket(newPack);
343 if (request.NumPackets == 1) 343 if (request.NumPackets == 1)
344 { 344 {
345 TransferPacketPacket packet2 = new TransferPacketPacket(); 345 TransferPacketPacket packet2 = new TransferPacketPacket();
346 packet2.TransferData.Packet = 0; 346 packet2.TransferData.Packet = 0;
347 packet2.TransferData.ChannelType = 2; 347 packet2.TransferData.ChannelType = 2;
348 packet2.TransferData.TransferID = request.TransferRequestID; 348 packet2.TransferData.TransferID = request.TransferRequestID;
349 packet2.TransferData.Data = request.AssetInf.Data; 349 packet2.TransferData.Data = request.AssetInf.Data;
350 packet2.TransferData.Status = 1; 350 packet2.TransferData.Status = 1;
351 request.RequestUser.OutPacket(packet2); 351 request.RequestUser.OutPacket(packet2);
352 } 352 }
353 else 353 else
354 { 354 {
355 TransferPacketPacket packet3 = new TransferPacketPacket(); 355 TransferPacketPacket packet3 = new TransferPacketPacket();
356 packet3.TransferData.Packet = 0; 356 packet3.TransferData.Packet = 0;
357 packet3.TransferData.ChannelType = 2; 357 packet3.TransferData.ChannelType = 2;
358 packet3.TransferData.TransferID = request.TransferRequestID; 358 packet3.TransferData.TransferID = request.TransferRequestID;
359 byte[] destinationArray = new byte[0x3e8]; 359 byte[] destinationArray = new byte[0x3e8];
360 Array.Copy(request.AssetInf.Data, destinationArray, 0x3e8); 360 Array.Copy(request.AssetInf.Data, destinationArray, 0x3e8);
361 packet3.TransferData.Data = destinationArray; 361 packet3.TransferData.Data = destinationArray;
362 packet3.TransferData.Status = 0; 362 packet3.TransferData.Status = 0;
363 request.RequestUser.OutPacket(packet3); 363 request.RequestUser.OutPacket(packet3);
364 packet3 = new TransferPacketPacket(); 364 packet3 = new TransferPacketPacket();
365 packet3.TransferData.Packet = 1; 365 packet3.TransferData.Packet = 1;
366 packet3.TransferData.ChannelType = 2; 366 packet3.TransferData.ChannelType = 2;
367 packet3.TransferData.TransferID = request.TransferRequestID; 367 packet3.TransferData.TransferID = request.TransferRequestID;
368 byte[] buffer2 = new byte[request.AssetInf.Data.Length - 0x3e8]; 368 byte[] buffer2 = new byte[request.AssetInf.Data.Length - 0x3e8];
369 Array.Copy(request.AssetInf.Data, 0x3e8, buffer2, 0, buffer2.Length); 369 Array.Copy(request.AssetInf.Data, 0x3e8, buffer2, 0, buffer2.Length);
370 packet3.TransferData.Data = buffer2; 370 packet3.TransferData.Data = buffer2;
371 packet3.TransferData.Status = 1; 371 packet3.TransferData.Status = 1;
372 request.RequestUser.OutPacket(packet3); 372 request.RequestUser.OutPacket(packet3);
373 } 373 }
374 } 374 }
375 for (int j = 0; j < num; j++) 375 for (int j = 0; j < num; j++)
376 { 376 {
377 this.AssetRequests.RemoveAt(0); 377 this.AssetRequests.RemoveAt(0);
378 } 378 }
379 } 379 }
380 } 380 }
381 381
382 private void ProcessTextureQueue() 382 private void ProcessTextureQueue()
383 { 383 {
384 if (this.TextureRequests.Count != 0) 384 if (this.TextureRequests.Count != 0)
385 { 385 {
386 int num = this.TextureRequests.Count; 386 int num = this.TextureRequests.Count;
387 for (int i = 0; i < num; i++) 387 for (int i = 0; i < num; i++)
388 { 388 {
389 AssetRequest req = this.TextureRequests[i]; 389 AssetRequest req = this.TextureRequests[i];
390 if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) 390 if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID))
391 { 391 {
392 TextureSender sender = new TextureSender(req); 392 TextureSender sender = new TextureSender(req);
393 sender.OnComplete += new DownloadComplete(this.TextureSent); 393 sender.OnComplete += new DownloadComplete(this.TextureSent);
394 lock (this.SendingTextures) 394 lock (this.SendingTextures)
395 { 395 {
396 this.SendingTextures.Add(req.ImageInfo.FullID, sender); 396 this.SendingTextures.Add(req.ImageInfo.FullID, sender);
397 } 397 }
398 } 398 }
399 } 399 }
400 this.TextureRequests.Clear(); 400 this.TextureRequests.Clear();
401 } 401 }
402 } 402 }
403 403
404 public void RunAssetManager() 404 public void RunAssetManager()
405 { 405 {
406 Label_0000: 406 Label_0000:
407 try 407 try
408 { 408 {
409 this.ProcessAssetQueue(); 409 this.ProcessAssetQueue();
410 this.ProcessTextureQueue(); 410 this.ProcessTextureQueue();
411 Thread.Sleep(500); 411 Thread.Sleep(500);
412 goto Label_0000; 412 goto Label_0000;
413 } 413 }
414 catch (Exception exception) 414 catch (Exception exception)
415 { 415 {
416 Console.WriteLine(exception.Message); 416 Console.WriteLine(exception.Message);
417 goto Label_0000; 417 goto Label_0000;
418 } 418 }
419 } 419 }
420 420
421 public void TextureSent(TextureSender sender) 421 public void TextureSent(TextureSender sender)
422 { 422 {
423 if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) 423 if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
424 { 424 {
425 lock (this.SendingTextures) 425 lock (this.SendingTextures)
426 { 426 {
427 this.SendingTextures.Remove(sender.request.ImageInfo.FullID); 427 this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
428 } 428 }
429 } 429 }
430 } 430 }
431 431
432 // Nested Types 432 // Nested Types
433 public class AssetInfo : AssetBase 433 public class AssetInfo : AssetBase
434 { 434 {
435 // Methods 435 // Methods
436 public AssetInfo() 436 public AssetInfo()
437 { 437 {
438 } 438 }
439 439
440 public AssetInfo(AssetBase aBase) 440 public AssetInfo(AssetBase aBase)
441 { 441 {
442 base.Data = aBase.Data; 442 base.Data = aBase.Data;
443 base.FullID = aBase.FullID; 443 base.FullID = aBase.FullID;
444 base.Type = aBase.Type; 444 base.Type = aBase.Type;
445 base.InvType = aBase.InvType; 445 base.InvType = aBase.InvType;
446 base.Name = aBase.Name; 446 base.Name = aBase.Name;
447 base.Description = aBase.Description; 447 base.Description = aBase.Description;
448 } 448 }
449 } 449 }
450 450
451 public class AssetRequest 451 public class AssetRequest
452 { 452 {
453 // Fields 453 // Fields
454 public AssetCache.AssetInfo AssetInf; 454 public AssetCache.AssetInfo AssetInf;
455 public long DataPointer; 455 public long DataPointer;
456 public AssetCache.TextureImage ImageInfo; 456 public AssetCache.TextureImage ImageInfo;
457 public bool IsTextureRequest; 457 public bool IsTextureRequest;
458 public int NumPackets; 458 public int NumPackets;
459 public int PacketCounter; 459 public int PacketCounter;
460 public LLUUID RequestAssetID; 460 public LLUUID RequestAssetID;
461 public IClientAPI RequestUser; 461 public IClientAPI RequestUser;
462 public LLUUID TransferRequestID; 462 public LLUUID TransferRequestID;
463 } 463 }
464 464
465 public class TextureImage : AssetBase 465 public class TextureImage : AssetBase
466 { 466 {
467 // Methods 467 // Methods
468 public TextureImage() 468 public TextureImage()
469 { 469 {
470 } 470 }
471 471
472 public TextureImage(AssetBase aBase) 472 public TextureImage(AssetBase aBase)
473 { 473 {
474 base.Data = aBase.Data; 474 base.Data = aBase.Data;
475 base.FullID = aBase.FullID; 475 base.FullID = aBase.FullID;
476 base.Type = aBase.Type; 476 base.Type = aBase.Type;
477 base.InvType = aBase.InvType; 477 base.InvType = aBase.InvType;
478 base.Name = aBase.Name; 478 base.Name = aBase.Name;
479 base.Description = aBase.Description; 479 base.Description = aBase.Description;
480 } 480 }
481 } 481 }
482 482
483 public class TextureSender 483 public class TextureSender
484 { 484 {
485 // Fields 485 // Fields
486 private Thread m_thread; 486 private Thread m_thread;
487 public AssetCache.AssetRequest request; 487 public AssetCache.AssetRequest request;
488 488
489 // Events 489 // Events
490 public event DownloadComplete OnComplete; 490 public event DownloadComplete OnComplete;
491 491
492 // Methods 492 // Methods
493 public TextureSender(AssetCache.AssetRequest req) 493 public TextureSender(AssetCache.AssetRequest req)
494 { 494 {
495 this.request = req; 495 this.request = req;
496 this.m_thread = new Thread(new ThreadStart(this.SendTexture)); 496 this.m_thread = new Thread(new ThreadStart(this.SendTexture));
497 this.m_thread.IsBackground = true; 497 this.m_thread.IsBackground = true;
498 this.m_thread.Start(); 498 this.m_thread.Start();
499 } 499 }
500 500
501 public void SendPacket() 501 public void SendPacket()
502 { 502 {
503 AssetCache.AssetRequest request = this.request; 503 AssetCache.AssetRequest request = this.request;
504 if (request.PacketCounter == 0) 504 if (request.PacketCounter == 0)
505 { 505 {
506 if (request.NumPackets == 1) 506 if (request.NumPackets == 1)
507 { 507 {
508 ImageDataPacket newPack = new ImageDataPacket(); 508 ImageDataPacket newPack = new ImageDataPacket();
509 newPack.ImageID.Packets = 1; 509 newPack.ImageID.Packets = 1;
510 newPack.ImageID.ID = request.ImageInfo.FullID; 510 newPack.ImageID.ID = request.ImageInfo.FullID;
511 newPack.ImageID.Size = (uint)request.ImageInfo.Data.Length; 511 newPack.ImageID.Size = (uint)request.ImageInfo.Data.Length;
512 newPack.ImageData.Data = request.ImageInfo.Data; 512 newPack.ImageData.Data = request.ImageInfo.Data;
513 newPack.ImageID.Codec = 2; 513 newPack.ImageID.Codec = 2;
514 request.RequestUser.OutPacket(newPack); 514 request.RequestUser.OutPacket(newPack);
515 request.PacketCounter++; 515 request.PacketCounter++;
516 } 516 }
517 else 517 else
518 { 518 {
519 ImageDataPacket packet2 = new ImageDataPacket(); 519 ImageDataPacket packet2 = new ImageDataPacket();
520 packet2.ImageID.Packets = (ushort)request.NumPackets; 520 packet2.ImageID.Packets = (ushort)request.NumPackets;
521 packet2.ImageID.ID = request.ImageInfo.FullID; 521 packet2.ImageID.ID = request.ImageInfo.FullID;
522 packet2.ImageID.Size = (uint)request.ImageInfo.Data.Length; 522 packet2.ImageID.Size = (uint)request.ImageInfo.Data.Length;
523 packet2.ImageData.Data = new byte[600]; 523 packet2.ImageData.Data = new byte[600];
524 Array.Copy(request.ImageInfo.Data, 0, packet2.ImageData.Data, 0, 600); 524 Array.Copy(request.ImageInfo.Data, 0, packet2.ImageData.Data, 0, 600);
525 packet2.ImageID.Codec = 2; 525 packet2.ImageID.Codec = 2;
526 request.RequestUser.OutPacket(packet2); 526 request.RequestUser.OutPacket(packet2);
527 request.PacketCounter++; 527 request.PacketCounter++;
528 } 528 }
529 } 529 }
530 else 530 else
531 { 531 {
532 ImagePacketPacket packet3 = new ImagePacketPacket(); 532 ImagePacketPacket packet3 = new ImagePacketPacket();
533 packet3.ImageID.Packet = (ushort)request.PacketCounter; 533 packet3.ImageID.Packet = (ushort)request.PacketCounter;
534 packet3.ImageID.ID = request.ImageInfo.FullID; 534 packet3.ImageID.ID = request.ImageInfo.FullID;
535 int length = (request.ImageInfo.Data.Length - 600) - (0x3e8 * (request.PacketCounter - 1)); 535 int length = (request.ImageInfo.Data.Length - 600) - (0x3e8 * (request.PacketCounter - 1));
536 if (length > 0x3e8) 536 if (length > 0x3e8)
537 { 537 {
538 length = 0x3e8; 538 length = 0x3e8;
539 } 539 }
540 packet3.ImageData.Data = new byte[length]; 540 packet3.ImageData.Data = new byte[length];
541 Array.Copy(request.ImageInfo.Data, 600 + (0x3e8 * (request.PacketCounter - 1)), packet3.ImageData.Data, 0, length); 541 Array.Copy(request.ImageInfo.Data, 600 + (0x3e8 * (request.PacketCounter - 1)), packet3.ImageData.Data, 0, length);
542 request.RequestUser.OutPacket(packet3); 542 request.RequestUser.OutPacket(packet3);
543 request.PacketCounter++; 543 request.PacketCounter++;
544 } 544 }
545 } 545 }
546 546
547 public void SendTexture() 547 public void SendTexture()
548 { 548 {
549 while (this.request.PacketCounter != this.request.NumPackets) 549 while (this.request.PacketCounter != this.request.NumPackets)
550 { 550 {
551 this.SendPacket(); 551 this.SendPacket();
552 Thread.Sleep(500); 552 Thread.Sleep(500);
553 } 553 }
554 if (this.OnComplete != null) 554 if (this.OnComplete != null)
555 { 555 {
556 this.OnComplete(this); 556 this.OnComplete(this);
557 } 557 }
558 } 558 }
559 } 559 }
560 } 560 }
561} 561}
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
index 8b485af..f9f814a 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
@@ -1,81 +1,81 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.IO; 32using System.IO;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities; 36using OpenSim.Framework.Utilities;
37using OpenSim.Framework.Data; 37using OpenSim.Framework.Data;
38 38
39namespace OpenSim.Framework.Communications.Caches 39namespace OpenSim.Framework.Communications.Caches
40{ 40{
41 public class AssetTransactionManager 41 public class AssetTransactionManager
42 { 42 {
43 // Fields 43 // Fields
44 public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>(); 44 public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>();
45 45
46 // Methods 46 // Methods
47 public AgentAssetTransactions AddUser(LLUUID userID) 47 public AgentAssetTransactions AddUser(LLUUID userID)
48 { 48 {
49 if (!this.AgentTransactions.ContainsKey(userID)) 49 if (!this.AgentTransactions.ContainsKey(userID))
50 { 50 {
51 AgentAssetTransactions transactions = new AgentAssetTransactions(userID); 51 AgentAssetTransactions transactions = new AgentAssetTransactions(userID);
52 this.AgentTransactions.Add(userID, transactions); 52 this.AgentTransactions.Add(userID, transactions);
53 return transactions; 53 return transactions;
54 } 54 }
55 return null; 55 return null;
56 } 56 }
57 57
58 public AgentAssetTransactions GetUserTransActions(LLUUID userID) 58 public AgentAssetTransactions GetUserTransActions(LLUUID userID)
59 { 59 {
60 if (this.AgentTransactions.ContainsKey(userID)) 60 if (this.AgentTransactions.ContainsKey(userID))
61 { 61 {
62 return this.AgentTransactions[userID]; 62 return this.AgentTransactions[userID];
63 } 63 }
64 return null; 64 return null;
65 } 65 }
66 66
67 public void HandleInventoryFromTransaction() 67 public void HandleInventoryFromTransaction()
68 { 68 {
69 } 69 }
70 70
71 public void HandleUDPUploadRequest() 71 public void HandleUDPUploadRequest()
72 { 72 {
73 } 73 }
74 74
75 public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data) 75 public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data)
76 { 76 {
77 } 77 }
78 } 78 }
79} 79}
80 80
81 81
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
index 6741969..c906b76 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
@@ -1,275 +1,275 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.IO; 32using System.IO;
33using libsecondlife; 33using libsecondlife;
34using libsecondlife.Packets; 34using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38using OpenSim.Region.Capabilities; 38using OpenSim.Region.Capabilities;
39using OpenSim.Framework.Servers; 39using OpenSim.Framework.Servers;
40 40
41namespace OpenSim.Framework.Communications.Caches 41namespace OpenSim.Framework.Communications.Caches
42{ 42{
43 public class AgentAssetTransactions 43 public class AgentAssetTransactions
44 { 44 {
45 // Fields 45 // Fields
46 public List<AssetCapsUploader> CapsUploaders = new List<AssetCapsUploader>(); 46 public List<AssetCapsUploader> CapsUploaders = new List<AssetCapsUploader>();
47 public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>(); 47 public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>();
48 public LLUUID UserID; 48 public LLUUID UserID;
49 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); 49 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
50 50
51 // Methods 51 // Methods
52 public AgentAssetTransactions(LLUUID agentID) 52 public AgentAssetTransactions(LLUUID agentID)
53 { 53 {
54 this.UserID = agentID; 54 this.UserID = agentID;
55 } 55 }
56 56
57 public AssetCapsUploader RequestCapsUploader() 57 public AssetCapsUploader RequestCapsUploader()
58 { 58 {
59 AssetCapsUploader uploader = new AssetCapsUploader(); 59 AssetCapsUploader uploader = new AssetCapsUploader();
60 this.CapsUploaders.Add(uploader); 60 this.CapsUploaders.Add(uploader);
61 return uploader; 61 return uploader;
62 } 62 }
63 63
64 public NoteCardCapsUpdate RequestNoteCardUpdater() 64 public NoteCardCapsUpdate RequestNoteCardUpdater()
65 { 65 {
66 NoteCardCapsUpdate update = new NoteCardCapsUpdate(); 66 NoteCardCapsUpdate update = new NoteCardCapsUpdate();
67 this.NotecardUpdaters.Add(update); 67 this.NotecardUpdaters.Add(update);
68 return update; 68 return update;
69 } 69 }
70 70
71 public AssetXferUploader RequestXferUploader(LLUUID transactionID) 71 public AssetXferUploader RequestXferUploader(LLUUID transactionID)
72 { 72 {
73 AssetXferUploader uploader = new AssetXferUploader(); 73 AssetXferUploader uploader = new AssetXferUploader();
74 this.XferUploaders.Add(transactionID, uploader); 74 this.XferUploaders.Add(transactionID, uploader);
75 return uploader; 75 return uploader;
76 } 76 }
77 77
78 // Nested Types 78 // Nested Types
79 public class AssetCapsUploader 79 public class AssetCapsUploader
80 { 80 {
81 // Fields 81 // Fields
82 private BaseHttpServer httpListener; 82 private BaseHttpServer httpListener;
83 private LLUUID inventoryItemID; 83 private LLUUID inventoryItemID;
84 private string m_assetDescription = ""; 84 private string m_assetDescription = "";
85 private string m_assetName = ""; 85 private string m_assetName = "";
86 private LLUUID m_folderID; 86 private LLUUID m_folderID;
87 private LLUUID newAssetID; 87 private LLUUID newAssetID;
88 private bool SaveImages = false; 88 private bool SaveImages = false;
89 private string uploaderPath = ""; 89 private string uploaderPath = "";
90 90
91 // Events 91 // Events
92 public event UpLoadedTexture OnUpLoad; 92 public event UpLoadedTexture OnUpLoad;
93 93
94 // Methods 94 // Methods
95 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) 95 public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer)
96 { 96 {
97 this.m_assetName = assetName; 97 this.m_assetName = assetName;
98 this.m_assetDescription = assetDescription; 98 this.m_assetDescription = assetDescription;
99 this.m_folderID = folderID; 99 this.m_folderID = folderID;
100 this.newAssetID = assetID; 100 this.newAssetID = assetID;
101 this.inventoryItemID = inventoryItem; 101 this.inventoryItemID = inventoryItem;
102 this.uploaderPath = path; 102 this.uploaderPath = path;
103 this.httpListener = httpServer; 103 this.httpListener = httpServer;
104 } 104 }
105 105
106 private void SaveImageToFile(string filename, byte[] data) 106 private void SaveImageToFile(string filename, byte[] data)
107 { 107 {
108 FileStream output = File.Create(filename); 108 FileStream output = File.Create(filename);
109 BinaryWriter writer = new BinaryWriter(output); 109 BinaryWriter writer = new BinaryWriter(output);
110 writer.Write(data); 110 writer.Write(data);
111 writer.Close(); 111 writer.Close();
112 output.Close(); 112 output.Close();
113 } 113 }
114 114
115 public string uploaderCaps(byte[] data, string path, string param) 115 public string uploaderCaps(byte[] data, string path, string param)
116 { 116 {
117 LLUUID inventoryItemID = this.inventoryItemID; 117 LLUUID inventoryItemID = this.inventoryItemID;
118 string text = ""; 118 string text = "";
119 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); 119 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
120 complete.new_asset = this.newAssetID.ToStringHyphenated(); 120 complete.new_asset = this.newAssetID.ToStringHyphenated();
121 complete.new_inventory_item = inventoryItemID; 121 complete.new_inventory_item = inventoryItemID;
122 complete.state = "complete"; 122 complete.state = "complete";
123 text = LLSDHelpers.SerialiseLLSDReply(complete); 123 text = LLSDHelpers.SerialiseLLSDReply(complete);
124 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); 124 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath);
125 if (this.SaveImages) 125 if (this.SaveImages)
126 { 126 {
127 this.SaveImageToFile(this.m_assetName + ".jp2", data); 127 this.SaveImageToFile(this.m_assetName + ".jp2", data);
128 } 128 }
129 if (this.OnUpLoad != null) 129 if (this.OnUpLoad != null)
130 { 130 {
131 this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); 131 this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data);
132 } 132 }
133 return text; 133 return text;
134 } 134 }
135 } 135 }
136 136
137 public class AssetXferUploader 137 public class AssetXferUploader
138 { 138 {
139 // Fields 139 // Fields
140 public bool AddToInventory; 140 public bool AddToInventory;
141 public AssetBase Asset; 141 public AssetBase Asset;
142 public LLUUID InventFolder = LLUUID.Zero; 142 public LLUUID InventFolder = LLUUID.Zero;
143 private IClientAPI ourClient; 143 private IClientAPI ourClient;
144 public LLUUID TransactionID = LLUUID.Zero; 144 public LLUUID TransactionID = LLUUID.Zero;
145 public bool UploadComplete; 145 public bool UploadComplete;
146 public uint XferID; 146 public uint XferID;
147 147
148 // Methods 148 // Methods
149 public void HandleXferPacket(uint xferID, uint packetID, byte[] data) 149 public void HandleXferPacket(uint xferID, uint packetID, byte[] data)
150 { 150 {
151 if (this.XferID == xferID) 151 if (this.XferID == xferID)
152 { 152 {
153 if (this.Asset.Data.Length > 1) 153 if (this.Asset.Data.Length > 1)
154 { 154 {
155 byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; 155 byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length];
156 Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); 156 Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length);
157 Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); 157 Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length);
158 this.Asset.Data = destinationArray; 158 this.Asset.Data = destinationArray;
159 } 159 }
160 else 160 else
161 { 161 {
162 byte[] buffer2 = new byte[data.Length - 4]; 162 byte[] buffer2 = new byte[data.Length - 4];
163 Array.Copy(data, 4, buffer2, 0, data.Length - 4); 163 Array.Copy(data, 4, buffer2, 0, data.Length - 4);
164 this.Asset.Data = buffer2; 164 this.Asset.Data = buffer2;
165 } 165 }
166 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); 166 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
167 newPack.XferID.ID = xferID; 167 newPack.XferID.ID = xferID;
168 newPack.XferID.Packet = packetID; 168 newPack.XferID.Packet = packetID;
169 this.ourClient.OutPacket(newPack); 169 this.ourClient.OutPacket(newPack);
170 if ((packetID & 0x80000000) != 0) 170 if ((packetID & 0x80000000) != 0)
171 { 171 {
172 this.SendCompleteMessage(); 172 this.SendCompleteMessage();
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) 177 public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
178 { 178 {
179 this.ourClient = remoteClient; 179 this.ourClient = remoteClient;
180 this.Asset = new AssetBase(); 180 this.Asset = new AssetBase();
181 this.Asset.FullID = assetID; 181 this.Asset.FullID = assetID;
182 this.Asset.InvType = type; 182 this.Asset.InvType = type;
183 this.Asset.Type = type; 183 this.Asset.Type = type;
184 this.Asset.Data = data; 184 this.Asset.Data = data;
185 this.Asset.Name = "blank"; 185 this.Asset.Name = "blank";
186 this.Asset.Description = "empty"; 186 this.Asset.Description = "empty";
187 this.TransactionID = transaction; 187 this.TransactionID = transaction;
188 if (this.Asset.Data.Length > 2) 188 if (this.Asset.Data.Length > 2)
189 { 189 {
190 this.SendCompleteMessage(); 190 this.SendCompleteMessage();
191 } 191 }
192 else 192 else
193 { 193 {
194 this.ReqestStartXfer(); 194 this.ReqestStartXfer();
195 } 195 }
196 } 196 }
197 197
198 protected void ReqestStartXfer() 198 protected void ReqestStartXfer()
199 { 199 {
200 this.UploadComplete = false; 200 this.UploadComplete = false;
201 this.XferID = Util.GetNextXferID(); 201 this.XferID = Util.GetNextXferID();
202 RequestXferPacket newPack = new RequestXferPacket(); 202 RequestXferPacket newPack = new RequestXferPacket();
203 newPack.XferID.ID = this.XferID; 203 newPack.XferID.ID = this.XferID;
204 newPack.XferID.VFileType = this.Asset.Type; 204 newPack.XferID.VFileType = this.Asset.Type;
205 newPack.XferID.VFileID = this.Asset.FullID; 205 newPack.XferID.VFileID = this.Asset.FullID;
206 newPack.XferID.FilePath = 0; 206 newPack.XferID.FilePath = 0;
207 newPack.XferID.Filename = new byte[0]; 207 newPack.XferID.Filename = new byte[0];
208 this.ourClient.OutPacket(newPack); 208 this.ourClient.OutPacket(newPack);
209 } 209 }
210 210
211 protected void SendCompleteMessage() 211 protected void SendCompleteMessage()
212 { 212 {
213 this.UploadComplete = true; 213 this.UploadComplete = true;
214 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); 214 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
215 newPack.AssetBlock.Type = this.Asset.Type; 215 newPack.AssetBlock.Type = this.Asset.Type;
216 newPack.AssetBlock.Success = true; 216 newPack.AssetBlock.Success = true;
217 newPack.AssetBlock.UUID = this.Asset.FullID; 217 newPack.AssetBlock.UUID = this.Asset.FullID;
218 this.ourClient.OutPacket(newPack); 218 this.ourClient.OutPacket(newPack);
219 } 219 }
220 } 220 }
221 221
222 public class NoteCardCapsUpdate 222 public class NoteCardCapsUpdate
223 { 223 {
224 // Fields 224 // Fields
225 private BaseHttpServer httpListener; 225 private BaseHttpServer httpListener;
226 private LLUUID inventoryItemID; 226 private LLUUID inventoryItemID;
227 private string m_assetName = ""; 227 private string m_assetName = "";
228 private LLUUID newAssetID; 228 private LLUUID newAssetID;
229 private bool SaveImages = false; 229 private bool SaveImages = false;
230 private string uploaderPath = ""; 230 private string uploaderPath = "";
231 231
232 // Events 232 // Events
233 public event UpLoadedTexture OnUpLoad; 233 public event UpLoadedTexture OnUpLoad;
234 234
235 // Methods 235 // Methods
236 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) 236 public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer)
237 { 237 {
238 this.inventoryItemID = inventoryItem; 238 this.inventoryItemID = inventoryItem;
239 this.uploaderPath = path; 239 this.uploaderPath = path;
240 this.httpListener = httpServer; 240 this.httpListener = httpServer;
241 this.newAssetID = LLUUID.Random(); 241 this.newAssetID = LLUUID.Random();
242 } 242 }
243 243
244 private void SaveImageToFile(string filename, byte[] data) 244 private void SaveImageToFile(string filename, byte[] data)
245 { 245 {
246 FileStream output = File.Create(filename); 246 FileStream output = File.Create(filename);
247 BinaryWriter writer = new BinaryWriter(output); 247 BinaryWriter writer = new BinaryWriter(output);
248 writer.Write(data); 248 writer.Write(data);
249 writer.Close(); 249 writer.Close();
250 output.Close(); 250 output.Close();
251 } 251 }
252 252
253 public string uploaderCaps(byte[] data, string path, string param) 253 public string uploaderCaps(byte[] data, string path, string param)
254 { 254 {
255 LLUUID inventoryItemID = this.inventoryItemID; 255 LLUUID inventoryItemID = this.inventoryItemID;
256 string text = ""; 256 string text = "";
257 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); 257 LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
258 complete.new_asset = this.newAssetID.ToStringHyphenated(); 258 complete.new_asset = this.newAssetID.ToStringHyphenated();
259 complete.new_inventory_item = inventoryItemID; 259 complete.new_inventory_item = inventoryItemID;
260 complete.state = "complete"; 260 complete.state = "complete";
261 text = LLSDHelpers.SerialiseLLSDReply(complete); 261 text = LLSDHelpers.SerialiseLLSDReply(complete);
262 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); 262 this.httpListener.RemoveStreamHandler("POST", this.uploaderPath);
263 if (this.SaveImages) 263 if (this.SaveImages)
264 { 264 {
265 this.SaveImageToFile(this.m_assetName + "notecard.txt", data); 265 this.SaveImageToFile(this.m_assetName + "notecard.txt", data);
266 } 266 }
267 if (this.OnUpLoad != null) 267 if (this.OnUpLoad != null)
268 { 268 {
269 this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); 269 this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data);
270 } 270 }
271 return text; 271 return text;
272 } 272 }
273 } 273 }
274 } 274 }
275} \ No newline at end of file 275} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 2660df3..d850305 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -1,94 +1,94 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.IO; 32using System.IO;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Framework.Data; 36using OpenSim.Framework.Data;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38 38
39namespace OpenSim.Framework.Communications.Caches 39namespace OpenSim.Framework.Communications.Caches
40{ 40{
41 public class CachedUserInfo 41 public class CachedUserInfo
42 { 42 {
43 // Fields 43 // Fields
44 public InventoryFolder RootFolder; 44 public InventoryFolder RootFolder;
45 public UserProfileData UserProfile; 45 public UserProfileData UserProfile;
46 46
47 // Methods 47 // Methods
48 public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) 48 public void FolderReceive(LLUUID userID, InventoryFolder folderInfo)
49 { 49 {
50 if (userID == this.UserProfile.UUID) 50 if (userID == this.UserProfile.UUID)
51 { 51 {
52 if (this.RootFolder == null) 52 if (this.RootFolder == null)
53 { 53 {
54 if (folderInfo.parentID == LLUUID.Zero) 54 if (folderInfo.parentID == LLUUID.Zero)
55 { 55 {
56 this.RootFolder = folderInfo; 56 this.RootFolder = folderInfo;
57 } 57 }
58 } 58 }
59 else if (this.RootFolder.folderID == folderInfo.parentID) 59 else if (this.RootFolder.folderID == folderInfo.parentID)
60 { 60 {
61 this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); 61 this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
62 } 62 }
63 else 63 else
64 { 64 {
65 InventoryFolder folder = this.RootFolder.HasSubFolder(folderInfo.parentID); 65 InventoryFolder folder = this.RootFolder.HasSubFolder(folderInfo.parentID);
66 if (folder != null) 66 if (folder != null)
67 { 67 {
68 folder.SubFolders.Add(folderInfo.folderID, folderInfo); 68 folder.SubFolders.Add(folderInfo.folderID, folderInfo);
69 } 69 }
70 } 70 }
71 } 71 }
72 } 72 }
73 73
74 public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) 74 public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
75 { 75 {
76 if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) 76 if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
77 { 77 {
78 if (itemInfo.parentFolderID == this.RootFolder.folderID) 78 if (itemInfo.parentFolderID == this.RootFolder.folderID)
79 { 79 {
80 this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); 80 this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo);
81 } 81 }
82 else 82 else
83 { 83 {
84 InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); 84 InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID);
85 if (folder != null) 85 if (folder != null)
86 { 86 {
87 folder.Items.Add(itemInfo.inventoryID, itemInfo); 87 folder.Items.Add(itemInfo.inventoryID, itemInfo);
88 } 88 }
89 } 89 }
90 } 90 }
91 } 91 }
92 } 92 }
93} 93}
94 94
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs
index 8670eb0..300a6e3 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs
@@ -1,109 +1,109 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.IO; 32using System.IO;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Data; 35using OpenSim.Framework.Data;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38 38
39namespace OpenSim.Framework.Communications.Caches 39namespace OpenSim.Framework.Communications.Caches
40{ 40{
41 public class InventoryFolder : InventoryFolderBase 41 public class InventoryFolder : InventoryFolderBase
42 { 42 {
43 // Fields 43 // Fields
44 public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>(); 44 public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
45 public Dictionary<LLUUID, InventoryFolder> SubFolders = new Dictionary<LLUUID, InventoryFolder>(); 45 public Dictionary<LLUUID, InventoryFolder> SubFolders = new Dictionary<LLUUID, InventoryFolder>();
46 46
47 // Methods 47 // Methods
48 public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) 48 public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type)
49 { 49 {
50 InventoryFolder subFold = new InventoryFolder(); 50 InventoryFolder subFold = new InventoryFolder();
51 subFold.name = folderName; 51 subFold.name = folderName;
52 subFold.folderID = folderID; 52 subFold.folderID = folderID;
53 subFold.type = type; 53 subFold.type = (short) type;
54 subFold.parentID = this.folderID; 54 subFold.parentID = this.folderID;
55 subFold.agentID = this.agentID; 55 subFold.agentID = this.agentID;
56 this.SubFolders.Add(subFold.folderID, subFold); 56 this.SubFolders.Add(subFold.folderID, subFold);
57 return subFold; 57 return subFold;
58 } 58 }
59 59
60 public InventoryItemBase HasItem(LLUUID itemID) 60 public InventoryItemBase HasItem(LLUUID itemID)
61 { 61 {
62 InventoryItemBase base2 = null; 62 InventoryItemBase base2 = null;
63 if (this.Items.ContainsKey(itemID)) 63 if (this.Items.ContainsKey(itemID))
64 { 64 {
65 return this.Items[itemID]; 65 return this.Items[itemID];
66 } 66 }
67 foreach (InventoryFolder folder in this.SubFolders.Values) 67 foreach (InventoryFolder folder in this.SubFolders.Values)
68 { 68 {
69 base2 = folder.HasItem(itemID); 69 base2 = folder.HasItem(itemID);
70 if (base2 != null) 70 if (base2 != null)
71 { 71 {
72 break; 72 break;
73 } 73 }
74 } 74 }
75 return base2; 75 return base2;
76 } 76 }
77 77
78 public InventoryFolder HasSubFolder(LLUUID folderID) 78 public InventoryFolder HasSubFolder(LLUUID folderID)
79 { 79 {
80 InventoryFolder returnFolder = null; 80 InventoryFolder returnFolder = null;
81 if (this.SubFolders.ContainsKey(folderID)) 81 if (this.SubFolders.ContainsKey(folderID))
82 { 82 {
83 returnFolder = this.SubFolders[folderID]; 83 returnFolder = this.SubFolders[folderID];
84 } 84 }
85 else 85 else
86 { 86 {
87 foreach (InventoryFolder folder in this.SubFolders.Values) 87 foreach (InventoryFolder folder in this.SubFolders.Values)
88 { 88 {
89 returnFolder = folder.HasSubFolder(folderID); 89 returnFolder = folder.HasSubFolder(folderID);
90 if (returnFolder != null) 90 if (returnFolder != null)
91 { 91 {
92 break; 92 break;
93 } 93 }
94 } 94 }
95 } 95 }
96 return returnFolder; 96 return returnFolder;
97 } 97 }
98 98
99 public List<InventoryItemBase> RequestListOfItems() 99 public List<InventoryItemBase> RequestListOfItems()
100 { 100 {
101 List<InventoryItemBase> itemList = new List<InventoryItemBase>(); 101 List<InventoryItemBase> itemList = new List<InventoryItemBase>();
102 foreach (InventoryItemBase item in this.Items.Values) 102 foreach (InventoryItemBase item in this.Items.Values)
103 { 103 {
104 itemList.Add(item); 104 itemList.Add(item);
105 } 105 }
106 return itemList; 106 return itemList;
107 } 107 }
108 } 108 }
109} 109}
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
new file mode 100644
index 0000000..2608145
--- /dev/null
+++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
@@ -0,0 +1,89 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Data;
6
7namespace OpenSim.Framework.Communications.Caches
8{
9 public class LibraryRootFolder : InventoryFolder
10 {
11 private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
12
13 public LibraryRootFolder()
14 {
15 this.agentID = libOwner;
16 this.folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
17 this.name = "OpenSim Library";
18 this.parentID = LLUUID.Zero;
19 this.type = (short)-1;
20 this.version = (ushort) 1;
21
22 InventoryItemBase item = new InventoryItemBase();
23 item.avatarID = libOwner;
24 item.creatorsID = libOwner;
25 item.inventoryID = LLUUID.Random();
26 item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002");
27 item.inventoryDescription = "Plywood texture";
28 item.inventoryName = "Plywood";
29 item.type =0;
30 item.parentFolderID = this.folderID;
31 item.inventoryCurrentPermissions = 2147483647;
32 item.inventoryNextPermissions = 2147483647;
33 this.Items.Add(item.inventoryID, item);
34
35 item = new InventoryItemBase();
36 item.avatarID = libOwner;
37 item.creatorsID = libOwner;
38 item.inventoryID = LLUUID.Random();
39 item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003");
40 item.inventoryDescription = "Rocks texture";
41 item.inventoryName = "Rocks";
42 item.type = 0;
43 item.parentFolderID = this.folderID;
44 item.inventoryCurrentPermissions = 2147483647;
45 item.inventoryNextPermissions = 2147483647;
46 this.Items.Add(item.inventoryID, item);
47
48 item = new InventoryItemBase();
49 item.avatarID = libOwner;
50 item.creatorsID = libOwner;
51 item.inventoryID = LLUUID.Random();
52 item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001");
53 item.inventoryDescription = "Bricks texture";
54 item.inventoryName = "Bricks";
55 item.type = 0;
56 item.parentFolderID = this.folderID;
57 item.inventoryCurrentPermissions = 2147483647;
58 item.inventoryNextPermissions = 2147483647;
59 this.Items.Add(item.inventoryID, item);
60
61 item = new InventoryItemBase();
62 item.avatarID = libOwner;
63 item.creatorsID = libOwner;
64 item.inventoryID = LLUUID.Random();
65 item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004");
66 item.inventoryDescription = "Granite texture";
67 item.inventoryName = "Granite";
68 item.type = 0;
69 item.parentFolderID = this.folderID;
70 item.inventoryCurrentPermissions = 2147483647;
71 item.inventoryNextPermissions = 2147483647;
72 this.Items.Add(item.inventoryID, item);
73
74 item = new InventoryItemBase();
75 item.avatarID = libOwner;
76 item.creatorsID = libOwner;
77 item.inventoryID = LLUUID.Random();
78 item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005");
79 item.inventoryDescription = "Hardwood texture";
80 item.inventoryName = "Hardwood";
81 item.type = 0;
82 item.parentFolderID = this.folderID;
83 item.inventoryCurrentPermissions = 2147483647;
84 item.inventoryNextPermissions = 2147483647;
85 this.Items.Add(item.inventoryID, item);
86 }
87
88 }
89}
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
index 8210702..7b4f6a5 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs
@@ -1,170 +1,216 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.IO; 32using System.IO;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities; 36using OpenSim.Framework.Utilities;
37using OpenSim.Framework.Data; 37using OpenSim.Framework.Data;
38 38
39namespace OpenSim.Framework.Communications.Caches 39namespace OpenSim.Framework.Communications.Caches
40{ 40{
41 41 public class UserProfileCache
42 public class UserProfileCache 42 {
43 { 43 // Fields
44 // Fields 44 private CommunicationsManager m_parent;
45 private CommunicationsManager m_parent; 45 public Dictionary<LLUUID, CachedUserInfo> UserProfiles = new Dictionary<LLUUID, CachedUserInfo>();
46 public Dictionary<LLUUID, CachedUserInfo> UserProfiles = new Dictionary<LLUUID, CachedUserInfo>(); 46
47 47 public LibraryRootFolder libraryRoot = new LibraryRootFolder();
48 // Methods 48
49 public UserProfileCache(CommunicationsManager parent) 49 // Methods
50 { 50 public UserProfileCache(CommunicationsManager parent)
51 this.m_parent = parent; 51 {
52 } 52 this.m_parent = parent;
53 53 }
54 public void AddNewUser(LLUUID userID) 54
55 { 55 /// <summary>
56 if (!this.UserProfiles.ContainsKey(userID)) 56 /// A new user has moved into a region in this instance
57 { 57 /// so get info from servers
58 CachedUserInfo userInfo = new CachedUserInfo(); 58 /// </summary>
59 userInfo.UserProfile = this.RequestUserProfileForUser(userID); 59 /// <param name="userID"></param>
60 if (userInfo.UserProfile != null) 60 public void AddNewUser(LLUUID userID)
61 { 61 {
62 this.RequestInventoryForUser(userID, userInfo); 62 if (!this.UserProfiles.ContainsKey(userID))
63 this.UserProfiles.Add(userID, userInfo); 63 {
64 } 64 CachedUserInfo userInfo = new CachedUserInfo();
65 else 65 userInfo.UserProfile = this.RequestUserProfileForUser(userID);
66 { 66 if (userInfo.UserProfile != null)
67 Console.WriteLine("UserProfileCache.cs: user profile for user not found"); 67 {
68 } 68 this.RequestInventoryForUser(userID, userInfo);
69 } 69 this.UserProfiles.Add(userID, userInfo);
70 } 70 }
71 71 else
72 public void AddNewUser(string firstName, string lastName) 72 {
73 { 73 Console.WriteLine("UserProfileCache.cs: user profile for user not found");
74 } 74 }
75 75 }
76 public CachedUserInfo GetUserDetails(LLUUID userID) 76 }
77 { 77
78 if (this.UserProfiles.ContainsKey(userID)) 78 /// <summary>
79 { 79 /// A new user has moved into a region in this instance
80 return this.UserProfiles[userID]; 80 /// so get info from servers
81 } 81 /// </summary>
82 return null; 82 /// <param name="firstName"></param>
83 } 83 /// <param name="lastName"></param>
84 84 public void AddNewUser(string firstName, string lastName)
85 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) 85 {
86 { 86 }
87 if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 87
88 { 88 public CachedUserInfo GetUserDetails(LLUUID userID)
89 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; 89 {
90 if (info.RootFolder.folderID == parentID) 90 if (this.UserProfiles.ContainsKey(userID))
91 { 91 {
92 info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); 92 return this.UserProfiles[userID];
93 } 93 }
94 else 94 return null;
95 { 95 }
96 InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); 96
97 if (folder != null) 97 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID)
98 { 98 {
99 folder.CreateNewSubFolder(folderID, folderName, folderType); 99 if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
100 } 100 {
101 } 101 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
102 } 102 if (info.RootFolder.folderID == parentID)
103 } 103 {
104 104 info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
105 public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) 105 }
106 { 106 else
107 if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 107 {
108 { 108 InventoryFolder folder = info.RootFolder.HasSubFolder(parentID);
109 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; 109 if (folder != null)
110 if (info.RootFolder.folderID == folderID) 110 {
111 { 111 folder.CreateNewSubFolder(folderID, folderName, folderType);
112 if (fetchItems) 112 }
113 { 113 }
114 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); 114 }
115 } 115 }
116 } 116
117 else 117 public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
118 { 118 {
119 InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); 119 if (folderID == libraryRoot.folderID )
120 if ((folder != null) && fetchItems) 120 {
121 { 121 remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems());
122 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); 122 }
123 } 123 else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
124 } 124 {
125 } 125 CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
126 } 126 if (info.RootFolder.folderID == folderID)
127 127 {
128 public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) 128 if (fetchItems)
129 { 129 {
130 if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) 130 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems());
131 { 131 }
132 InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); 132 }
133 if (item != null) 133 else
134 { 134 {
135 remoteClient.SendInventoryItemDetails(ownerID, item); 135 InventoryFolder folder = info.RootFolder.HasSubFolder(folderID);
136 } 136 if ((folder != null) && fetchItems)
137 } 137 {
138 } 138 remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems());
139 139 }
140 private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) 140 }
141 { 141 }
142 InventoryFolder folderInfo = new InventoryFolder(); 142 }
143 folderInfo.agentID = userID; 143
144 folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; 144 public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
145 folderInfo.name = "My Inventory"; 145 {
146 folderInfo.parentID = LLUUID.Zero; 146 if (ownerID == libraryRoot.agentID)
147 folderInfo.type = 8; 147 {
148 folderInfo.version = 1; 148 //Console.WriteLine("request info for library item");
149 userInfo.FolderReceive(userID, folderInfo); 149 }
150 } 150 else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
151 151 {
152 private UserProfileData RequestUserProfileForUser(LLUUID userID) 152 InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID);
153 { 153 if (item != null)
154 return this.m_parent.UserServer.GetUserProfile(userID); 154 {
155 } 155 remoteClient.SendInventoryItemDetails(ownerID, item);
156 156 }
157 private void UpdateInventoryToServer(LLUUID userID) 157 }
158 { 158 }
159 } 159
160 160 /// <summary>
161 private void UpdateUserProfileToServer(LLUUID userID) 161 /// Request Iventory Info from Inventory server
162 { 162 /// </summary>
163 } 163 /// <param name="userID"></param>
164 164 private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
165 public void UserLogOut(LLUUID userID) 165 {
166 { 166 // this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
167 } 167
168 } 168 //for now we manually create the root folder,
169} 169 // but should be requesting all inventory from inventory server.
170 170 InventoryFolder folderInfo = new InventoryFolder();
171 folderInfo.agentID = userID;
172 folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID;
173 folderInfo.name = "My Inventory";
174 folderInfo.parentID = LLUUID.Zero;
175 folderInfo.type = 8;
176 folderInfo.version = 1;
177 userInfo.FolderReceive(userID, folderInfo);
178 }
179
180 /// <summary>
181 /// Request the user profile from User server
182 /// </summary>
183 /// <param name="userID"></param>
184 private UserProfileData RequestUserProfileForUser(LLUUID userID)
185 {
186 return this.m_parent.UserServer.GetUserProfile(userID);
187 }
188
189 /// <summary>
190 /// Update Inventory data to Inventory server
191 /// </summary>
192 /// <param name="userID"></param>
193 private void UpdateInventoryToServer(LLUUID userID)
194 {
195 }
196
197 /// <summary>
198 /// Make sure UserProfile is updated on user server
199 /// </summary>
200 /// <param name="userID"></param>
201 private void UpdateUserProfileToServer(LLUUID userID)
202 {
203 }
204
205 /// <summary>
206 /// A user has left this instance
207 /// so make sure servers have been updated
208 /// Then remove cached info
209 /// </summary>
210 /// <param name="userID"></param>
211 public void UserLogOut(LLUUID userID)
212 {
213 }
214 }
215}
216
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index e220e17..ac882ba 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications
44 public IGridServices GridServer; 44 public IGridServices GridServer;
45 public IInventoryServices InventoryServer; 45 public IInventoryServices InventoryServer;
46 public IInterRegionCommunications InterRegion; 46 public IInterRegionCommunications InterRegion;
47 public UserProfileCache UserProfilesCache; 47 public UserProfileCache UserProfiles;
48 public AssetCache AssetCache; 48 public AssetCache AssetCache;
49 49
50 public NetworkServersInfo ServersInfo; 50 public NetworkServersInfo ServersInfo;
@@ -52,21 +52,28 @@ namespace OpenSim.Framework.Communications
52 { 52 {
53 ServersInfo = serversInfo; 53 ServersInfo = serversInfo;
54 this.AssetCache = assetCache; 54 this.AssetCache = assetCache;
55 UserProfilesCache = new UserProfileCache(this); 55 UserProfiles = new UserProfileCache(this);
56 } 56 }
57 57
58 #region Packet Handlers 58 #region Packet Handlers
59 public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) 59 public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
60 { 60 {
61 UserProfileData profileData = this.UserServer.GetUserProfile(uuid); 61 if (uuid == UserProfiles.libraryRoot.agentID)
62 if (profileData != null)
63 { 62 {
64 LLUUID profileId = profileData.UUID; 63 remote_client.SendNameReply(uuid , "Mr" , "OpenSim");
65 string firstname = profileData.username; 64 }
66 string lastname = profileData.surname; 65 else
66 {
67 UserProfileData profileData = this.UserServer.GetUserProfile(uuid);
68 if (profileData != null)
69 {
70 LLUUID profileId = profileData.UUID;
71 string firstname = profileData.username;
72 string lastname = profileData.surname;
67 73
68 remote_client.SendNameReply(profileId, firstname, lastname); 74 remote_client.SendNameReply(profileId, firstname, lastname);
69 } 75 }
76 }
70 } 77 }
71 78
72 #endregion 79 #endregion