aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs822
1 files changed, 411 insertions, 411 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 8192be4..555d5f4 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -1,412 +1,412 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.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.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using libsecondlife; 31using libsecondlife;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35 35
36namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction 36namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
37{ 37{
38 /// <summary> 38 /// <summary>
39 /// Manage asset transactions for a single agent. 39 /// Manage asset transactions for a single agent.
40 /// </summary> 40 /// </summary>
41 public class AgentAssetTransactions 41 public class AgentAssetTransactions
42 { 42 {
43 //private static readonly log4net.ILog m_log 43 //private static readonly log4net.ILog m_log
44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 // Fields 46 // Fields
47 private bool m_dumpAssetsToFile; 47 private bool m_dumpAssetsToFile;
48 public AgentAssetTransactionsManager Manager; 48 public AgentAssetTransactionsManager Manager;
49 public LLUUID UserID; 49 public LLUUID UserID;
50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); 50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
51 51
52 // Methods 52 // Methods
53 public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) 53 public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile)
54 { 54 {
55 UserID = agentID; 55 UserID = agentID;
56 Manager = manager; 56 Manager = manager;
57 m_dumpAssetsToFile = dumpAssetsToFile; 57 m_dumpAssetsToFile = dumpAssetsToFile;
58 } 58 }
59 59
60 public AssetXferUploader RequestXferUploader(LLUUID transactionID) 60 public AssetXferUploader RequestXferUploader(LLUUID transactionID)
61 { 61 {
62 if (!XferUploaders.ContainsKey(transactionID)) 62 if (!XferUploaders.ContainsKey(transactionID))
63 { 63 {
64 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); 64 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile);
65 65
66 lock (XferUploaders) 66 lock (XferUploaders)
67 { 67 {
68 XferUploaders.Add(transactionID, uploader); 68 XferUploaders.Add(transactionID, uploader);
69 } 69 }
70 70
71 return uploader; 71 return uploader;
72 } 72 }
73 return null; 73 return null;
74 } 74 }
75 75
76 public void HandleXfer(ulong xferID, uint packetID, byte[] data) 76 public void HandleXfer(ulong xferID, uint packetID, byte[] data)
77 { 77 {
78 // AssetXferUploader uploaderFound = null; 78 // AssetXferUploader uploaderFound = null;
79 79
80 lock (XferUploaders) 80 lock (XferUploaders)
81 { 81 {
82 foreach (AssetXferUploader uploader in XferUploaders.Values) 82 foreach (AssetXferUploader uploader in XferUploaders.Values)
83 { 83 {
84 if (uploader.XferID == xferID) 84 if (uploader.XferID == xferID)
85 { 85 {
86 uploader.HandleXferPacket(xferID, packetID, data); 86 uploader.HandleXferPacket(xferID, packetID, data);
87 break; 87 break;
88 } 88 }
89 } 89 }
90 } 90 }
91 } 91 }
92 92
93 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, 93 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
94 uint callbackID, string description, string name, sbyte invType, 94 uint callbackID, string description, string name, sbyte invType,
95 sbyte type, byte wearableType, uint nextOwnerMask) 95 sbyte type, byte wearableType, uint nextOwnerMask)
96 { 96 {
97 if (XferUploaders.ContainsKey(transactionID)) 97 if (XferUploaders.ContainsKey(transactionID))
98 { 98 {
99 XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, 99 XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID,
100 callbackID, description, name, invType, type, 100 callbackID, description, name, invType, type,
101 wearableType, nextOwnerMask); 101 wearableType, nextOwnerMask);
102 } 102 }
103 } 103 }
104 104
105 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, 105 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
106 InventoryItemBase item) 106 InventoryItemBase item)
107 { 107 {
108 if (XferUploaders.ContainsKey(transactionID)) 108 if (XferUploaders.ContainsKey(transactionID))
109 { 109 {
110 XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); 110 XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item);
111 } 111 }
112 } 112 }
113 113
114 /// <summary> 114 /// <summary>
115 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. 115 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed.
116 /// </summary> 116 /// </summary>
117 /// <param name="transactionID"></param> 117 /// <param name="transactionID"></param>
118 /// <returns>The asset if the upload has completed, null if it has not.</returns> 118 /// <returns>The asset if the upload has completed, null if it has not.</returns>
119 public AssetBase GetTransactionAsset(LLUUID transactionID) 119 public AssetBase GetTransactionAsset(LLUUID transactionID)
120 { 120 {
121 if (XferUploaders.ContainsKey(transactionID)) 121 if (XferUploaders.ContainsKey(transactionID))
122 { 122 {
123 AssetXferUploader uploader = XferUploaders[transactionID]; 123 AssetXferUploader uploader = XferUploaders[transactionID];
124 AssetBase asset = uploader.GetAssetData(); 124 AssetBase asset = uploader.GetAssetData();
125 125
126 lock (XferUploaders) 126 lock (XferUploaders)
127 { 127 {
128 XferUploaders.Remove(transactionID); 128 XferUploaders.Remove(transactionID);
129 } 129 }
130 130
131 return asset; 131 return asset;
132 } 132 }
133 133
134 return null; 134 return null;
135 } 135 }
136 136
137 // Nested Types 137 // Nested Types
138 138
139 #region Nested type: AssetXferUploader 139 #region Nested type: AssetXferUploader
140 140
141 public class AssetXferUploader 141 public class AssetXferUploader
142 { 142 {
143 // Fields 143 // Fields
144 public bool AddToInventory; 144 public bool AddToInventory;
145 public AssetBase Asset; 145 public AssetBase Asset;
146 public LLUUID InventFolder = LLUUID.Zero; 146 public LLUUID InventFolder = LLUUID.Zero;
147 private sbyte invType = 0; 147 private sbyte invType = 0;
148 private bool m_createItem = false; 148 private bool m_createItem = false;
149 private string m_description = String.Empty; 149 private string m_description = String.Empty;
150 private bool m_dumpAssetToFile; 150 private bool m_dumpAssetToFile;
151 private bool m_finished = false; 151 private bool m_finished = false;
152 private string m_name = String.Empty; 152 private string m_name = String.Empty;
153 private bool m_storeLocal; 153 private bool m_storeLocal;
154 private AgentAssetTransactions m_userTransactions; 154 private AgentAssetTransactions m_userTransactions;
155 private uint nextPerm = 0; 155 private uint nextPerm = 0;
156 private IClientAPI ourClient; 156 private IClientAPI ourClient;
157 public LLUUID TransactionID = LLUUID.Zero; 157 public LLUUID TransactionID = LLUUID.Zero;
158 private sbyte type = 0; 158 private sbyte type = 0;
159 public bool UploadComplete; 159 public bool UploadComplete;
160 private byte wearableType = 0; 160 private byte wearableType = 0;
161 public ulong XferID; 161 public ulong XferID;
162 162
163 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 163 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
164 { 164 {
165 m_userTransactions = transactions; 165 m_userTransactions = transactions;
166 m_dumpAssetToFile = dumpAssetToFile; 166 m_dumpAssetToFile = dumpAssetToFile;
167 } 167 }
168 168
169 /// <summary> 169 /// <summary>
170 /// Process transfer data received from the client. 170 /// Process transfer data received from the client.
171 /// </summary> 171 /// </summary>
172 /// <param name="xferID"></param> 172 /// <param name="xferID"></param>
173 /// <param name="packetID"></param> 173 /// <param name="packetID"></param>
174 /// <param name="data"></param> 174 /// <param name="data"></param>
175 /// <returns>True if the transfer is complete, false otherwise or if the xferID was not valid</returns> 175 /// <returns>True if the transfer is complete, false otherwise or if the xferID was not valid</returns>
176 public bool HandleXferPacket(ulong xferID, uint packetID, byte[] data) 176 public bool HandleXferPacket(ulong xferID, uint packetID, byte[] data)
177 { 177 {
178 if (XferID == xferID) 178 if (XferID == xferID)
179 { 179 {
180 if (Asset.Data.Length > 1) 180 if (Asset.Data.Length > 1)
181 { 181 {
182 byte[] destinationArray = new byte[Asset.Data.Length + data.Length]; 182 byte[] destinationArray = new byte[Asset.Data.Length + data.Length];
183 Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length); 183 Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length);
184 Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length); 184 Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length);
185 Asset.Data = destinationArray; 185 Asset.Data = destinationArray;
186 } 186 }
187 else 187 else
188 { 188 {
189 byte[] buffer2 = new byte[data.Length - 4]; 189 byte[] buffer2 = new byte[data.Length - 4];
190 Array.Copy(data, 4, buffer2, 0, data.Length - 4); 190 Array.Copy(data, 4, buffer2, 0, data.Length - 4);
191 Asset.Data = buffer2; 191 Asset.Data = buffer2;
192 } 192 }
193 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); 193 ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
194 newPack.XferID.ID = xferID; 194 newPack.XferID.ID = xferID;
195 newPack.XferID.Packet = packetID; 195 newPack.XferID.Packet = packetID;
196 ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); 196 ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset);
197 if ((packetID & 0x80000000) != 0) 197 if ((packetID & 0x80000000) != 0)
198 { 198 {
199 SendCompleteMessage(); 199 SendCompleteMessage();
200 return true; 200 return true;
201 } 201 }
202 } 202 }
203 203
204 return false; 204 return false;
205 } 205 }
206 206
207 /// <summary> 207 /// <summary>
208 /// Initialise asset transfer from the client 208 /// Initialise asset transfer from the client
209 /// </summary> 209 /// </summary>
210 /// <param name="xferID"></param> 210 /// <param name="xferID"></param>
211 /// <param name="packetID"></param> 211 /// <param name="packetID"></param>
212 /// <param name="data"></param> 212 /// <param name="data"></param>
213 /// <returns>True if the transfer is complete, false otherwise</returns> 213 /// <returns>True if the transfer is complete, false otherwise</returns>
214 public bool Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, 214 public bool Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data,
215 bool storeLocal, bool tempFile) 215 bool storeLocal, bool tempFile)
216 { 216 {
217 ourClient = remoteClient; 217 ourClient = remoteClient;
218 Asset = new AssetBase(); 218 Asset = new AssetBase();
219 Asset.FullID = assetID; 219 Asset.FullID = assetID;
220 Asset.InvType = type; 220 Asset.InvType = type;
221 Asset.Type = type; 221 Asset.Type = type;
222 Asset.Data = data; 222 Asset.Data = data;
223 Asset.Name = "blank"; 223 Asset.Name = "blank";
224 Asset.Description = "empty"; 224 Asset.Description = "empty";
225 Asset.Local = storeLocal; 225 Asset.Local = storeLocal;
226 Asset.Temporary = tempFile; 226 Asset.Temporary = tempFile;
227 227
228 TransactionID = transaction; 228 TransactionID = transaction;
229 m_storeLocal = storeLocal; 229 m_storeLocal = storeLocal;
230 if (Asset.Data.Length > 2) 230 if (Asset.Data.Length > 2)
231 { 231 {
232 SendCompleteMessage(); 232 SendCompleteMessage();
233 return true; 233 return true;
234 } 234 }
235 else 235 else
236 { 236 {
237 RequestStartXfer(); 237 RequestStartXfer();
238 } 238 }
239 239
240 return false; 240 return false;
241 } 241 }
242 242
243 protected void RequestStartXfer() 243 protected void RequestStartXfer()
244 { 244 {
245 UploadComplete = false; 245 UploadComplete = false;
246 XferID = Util.GetNextXferID(); 246 XferID = Util.GetNextXferID();
247 RequestXferPacket newPack = new RequestXferPacket(); 247 RequestXferPacket newPack = new RequestXferPacket();
248 newPack.XferID.ID = XferID; 248 newPack.XferID.ID = XferID;
249 newPack.XferID.VFileType = Asset.Type; 249 newPack.XferID.VFileType = Asset.Type;
250 newPack.XferID.VFileID = Asset.FullID; 250 newPack.XferID.VFileID = Asset.FullID;
251 newPack.XferID.FilePath = 0; 251 newPack.XferID.FilePath = 0;
252 newPack.XferID.Filename = new byte[0]; 252 newPack.XferID.Filename = new byte[0];
253 ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); 253 ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset);
254 } 254 }
255 255
256 protected void SendCompleteMessage() 256 protected void SendCompleteMessage()
257 { 257 {
258 UploadComplete = true; 258 UploadComplete = true;
259 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); 259 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
260 newPack.AssetBlock.Type = Asset.Type; 260 newPack.AssetBlock.Type = Asset.Type;
261 newPack.AssetBlock.Success = true; 261 newPack.AssetBlock.Success = true;
262 newPack.AssetBlock.UUID = Asset.FullID; 262 newPack.AssetBlock.UUID = Asset.FullID;
263 ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); 263 ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset);
264 m_finished = true; 264 m_finished = true;
265 if (m_createItem) 265 if (m_createItem)
266 { 266 {
267 DoCreateItem(); 267 DoCreateItem();
268 } 268 }
269 else if (m_storeLocal) 269 else if (m_storeLocal)
270 { 270 {
271 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 271 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset);
272 } 272 }
273 273
274 // Console.WriteLine("upload complete "+ this.TransactionID); 274 // Console.WriteLine("upload complete "+ this.TransactionID);
275 275
276 if (m_dumpAssetToFile) 276 if (m_dumpAssetToFile)
277 { 277 {
278 DateTime now = DateTime.Now; 278 DateTime now = DateTime.Now;
279 string filename = 279 string filename =
280 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, 280 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day,
281 now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); 281 now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type);
282 SaveAssetToFile(filename, Asset.Data); 282 SaveAssetToFile(filename, Asset.Data);
283 } 283 }
284 } 284 }
285 285
286 ///Left this in and commented in case there are unforseen issues 286 ///Left this in and commented in case there are unforseen issues
287 //private void SaveAssetToFile(string filename, byte[] data) 287 //private void SaveAssetToFile(string filename, byte[] data)
288 //{ 288 //{
289 // FileStream fs = File.Create(filename); 289 // FileStream fs = File.Create(filename);
290 // BinaryWriter bw = new BinaryWriter(fs); 290 // BinaryWriter bw = new BinaryWriter(fs);
291 // bw.Write(data); 291 // bw.Write(data);
292 // bw.Close(); 292 // bw.Close();
293 // fs.Close(); 293 // fs.Close();
294 //} 294 //}
295 private void SaveAssetToFile(string filename, byte[] data) 295 private void SaveAssetToFile(string filename, byte[] data)
296 { 296 {
297 string assetPath = "UserAssets"; 297 string assetPath = "UserAssets";
298 if (!Directory.Exists(assetPath)) 298 if (!Directory.Exists(assetPath))
299 { 299 {
300 Directory.CreateDirectory(assetPath); 300 Directory.CreateDirectory(assetPath);
301 } 301 }
302 FileStream fs = File.Create(Path.Combine(assetPath, filename)); 302 FileStream fs = File.Create(Path.Combine(assetPath, filename));
303 BinaryWriter bw = new BinaryWriter(fs); 303 BinaryWriter bw = new BinaryWriter(fs);
304 bw.Write(data); 304 bw.Write(data);
305 bw.Close(); 305 bw.Close();
306 fs.Close(); 306 fs.Close();
307 } 307 }
308 308
309 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, 309 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
310 uint callbackID, string description, string name, sbyte invType, 310 uint callbackID, string description, string name, sbyte invType,
311 sbyte type, byte wearableType, uint nextOwnerMask) 311 sbyte type, byte wearableType, uint nextOwnerMask)
312 { 312 {
313 if (TransactionID == transactionID) 313 if (TransactionID == transactionID)
314 { 314 {
315 InventFolder = folderID; 315 InventFolder = folderID;
316 m_name = name; 316 m_name = name;
317 m_description = description; 317 m_description = description;
318 this.type = type; 318 this.type = type;
319 this.invType = invType; 319 this.invType = invType;
320 this.wearableType = wearableType; 320 this.wearableType = wearableType;
321 nextPerm = nextOwnerMask; 321 nextPerm = nextOwnerMask;
322 Asset.Name = name; 322 Asset.Name = name;
323 Asset.Description = description; 323 Asset.Description = description;
324 Asset.Type = type; 324 Asset.Type = type;
325 Asset.InvType = invType; 325 Asset.InvType = invType;
326 m_createItem = true; 326 m_createItem = true;
327 if (m_finished) 327 if (m_finished)
328 { 328 {
329 DoCreateItem(); 329 DoCreateItem();
330 } 330 }
331 } 331 }
332 } 332 }
333 333
334 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, 334 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
335 InventoryItemBase item) 335 InventoryItemBase item)
336 { 336 {
337 if (TransactionID == transactionID) 337 if (TransactionID == transactionID)
338 { 338 {
339 CachedUserInfo userInfo = 339 CachedUserInfo userInfo =
340 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( 340 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
341 remoteClient.AgentId); 341 remoteClient.AgentId);
342 342
343 if (userInfo != null) 343 if (userInfo != null)
344 { 344 {
345 LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); 345 LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId);
346 346
347 AssetBase asset 347 AssetBase asset
348 = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset( 348 = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset(
349 assetID, (item.AssetType == (int) AssetType.Texture ? true : false)); 349 assetID, (item.AssetType == (int) AssetType.Texture ? true : false));
350 350
351 if (asset == null) 351 if (asset == null)
352 { 352 {
353 asset = m_userTransactions.GetTransactionAsset(transactionID); 353 asset = m_userTransactions.GetTransactionAsset(transactionID);
354 } 354 }
355 355
356 if (asset != null && asset.FullID == assetID) 356 if (asset != null && asset.FullID == assetID)
357 { 357 {
358 asset.Name = item.Name; 358 asset.Name = item.Name;
359 asset.Description = item.Description; 359 asset.Description = item.Description;
360 asset.InvType = (sbyte) item.InvType; 360 asset.InvType = (sbyte) item.InvType;
361 asset.Type = (sbyte) item.AssetType; 361 asset.Type = (sbyte) item.AssetType;
362 item.AssetID = asset.FullID; 362 item.AssetID = asset.FullID;
363 363
364 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 364 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset);
365 } 365 }
366 366
367 userInfo.UpdateItem(remoteClient.AgentId, item); 367 userInfo.UpdateItem(remoteClient.AgentId, item);
368 } 368 }
369 } 369 }
370 } 370 }
371 371
372 private void DoCreateItem() 372 private void DoCreateItem()
373 { 373 {
374 //really need to fix this call, if lbsa71 saw this he would die. 374 //really need to fix this call, if lbsa71 saw this he would die.
375 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 375 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset);
376 CachedUserInfo userInfo = 376 CachedUserInfo userInfo =
377 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId); 377 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId);
378 if (userInfo != null) 378 if (userInfo != null)
379 { 379 {
380 InventoryItemBase item = new InventoryItemBase(); 380 InventoryItemBase item = new InventoryItemBase();
381 item.Owner = ourClient.AgentId; 381 item.Owner = ourClient.AgentId;
382 item.Creator = ourClient.AgentId; 382 item.Creator = ourClient.AgentId;
383 item.ID = LLUUID.Random(); 383 item.ID = LLUUID.Random();
384 item.AssetID = Asset.FullID; 384 item.AssetID = Asset.FullID;
385 item.Description = m_description; 385 item.Description = m_description;
386 item.Name = m_name; 386 item.Name = m_name;
387 item.AssetType = type; 387 item.AssetType = type;
388 item.InvType = invType; 388 item.InvType = invType;
389 item.Folder = InventFolder; 389 item.Folder = InventFolder;
390 item.BasePermissions = 2147483647; 390 item.BasePermissions = 2147483647;
391 item.CurrentPermissions = 2147483647; 391 item.CurrentPermissions = 2147483647;
392 item.NextPermissions = nextPerm; 392 item.NextPermissions = nextPerm;
393 item.Flags = (uint) wearableType; 393 item.Flags = (uint) wearableType;
394 394
395 userInfo.AddItem(ourClient.AgentId, item); 395 userInfo.AddItem(ourClient.AgentId, item);
396 ourClient.SendInventoryItemCreateUpdate(item); 396 ourClient.SendInventoryItemCreateUpdate(item);
397 } 397 }
398 } 398 }
399 399
400 public AssetBase GetAssetData() 400 public AssetBase GetAssetData()
401 { 401 {
402 if (m_finished) 402 if (m_finished)
403 { 403 {
404 return Asset; 404 return Asset;
405 } 405 }
406 return null; 406 return null;
407 } 407 }
408 } 408 }
409 409
410 #endregion 410 #endregion
411 } 411 }
412} \ No newline at end of file 412} \ No newline at end of file