aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
diff options
context:
space:
mode:
authorSean Dague2007-07-16 15:40:11 +0000
committerSean Dague2007-07-16 15:40:11 +0000
commit2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch)
treee3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
parent*Trunk compiles now (diff)
downloadopensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs714
1 files changed, 357 insertions, 357 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
index 60cd33a..109f7e6 100644
--- a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
+++ b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
@@ -1,357 +1,357 @@
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.Generic; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Assets; 32using OpenSim.Assets;
33using OpenSim.Framework.Interfaces; 33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types; 34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities; 35using OpenSim.Framework.Utilities;
36using OpenSim.Region.Caches; 36using OpenSim.Region.Caches;
37 37
38namespace OpenSim.Region.ClientStack 38namespace OpenSim.Region.ClientStack
39{ 39{
40 partial class ClientView 40 partial class ClientView
41 { 41 {
42 public class AgentAssetUpload 42 public class AgentAssetUpload
43 { 43 {
44 private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>(); 44 private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>();
45 private ClientView ourClient; 45 private ClientView ourClient;
46 private AssetCache m_assetCache; 46 private AssetCache m_assetCache;
47 private InventoryCache m_inventoryCache; 47 private InventoryCache m_inventoryCache;
48 48
49 public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache) 49 public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache)
50 { 50 {
51 this.ourClient = client; 51 this.ourClient = client;
52 m_assetCache = assetCache; 52 m_assetCache = assetCache;
53 m_inventoryCache = inventoryCache; 53 m_inventoryCache = inventoryCache;
54 } 54 }
55 55
56 public void AddUpload(LLUUID transactionID, AssetBase asset) 56 public void AddUpload(LLUUID transactionID, AssetBase asset)
57 { 57 {
58 AssetTransaction upload = new AssetTransaction(); 58 AssetTransaction upload = new AssetTransaction();
59 lock (this.transactions) 59 lock (this.transactions)
60 { 60 {
61 upload.Asset = asset; 61 upload.Asset = asset;
62 upload.TransactionID = transactionID; 62 upload.TransactionID = transactionID;
63 this.transactions.Add(transactionID, upload); 63 this.transactions.Add(transactionID, upload);
64 } 64 }
65 if (upload.Asset.Data.Length > 2) 65 if (upload.Asset.Data.Length > 2)
66 { 66 {
67 //is complete 67 //is complete
68 upload.UploadComplete = true; 68 upload.UploadComplete = true;
69 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 69 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
70 response.AssetBlock.Type = asset.Type; 70 response.AssetBlock.Type = asset.Type;
71 response.AssetBlock.Success = true; 71 response.AssetBlock.Success = true;
72 response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID); 72 response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID);
73 this.ourClient.OutPacket(response); 73 this.ourClient.OutPacket(response);
74 m_assetCache.AddAsset(asset); 74 m_assetCache.AddAsset(asset);
75 } 75 }
76 else 76 else
77 { 77 {
78 upload.UploadComplete = false; 78 upload.UploadComplete = false;
79 upload.XferID = Util.GetNextXferID(); 79 upload.XferID = Util.GetNextXferID();
80 RequestXferPacket xfer = new RequestXferPacket(); 80 RequestXferPacket xfer = new RequestXferPacket();
81 xfer.XferID.ID = upload.XferID; 81 xfer.XferID.ID = upload.XferID;
82 xfer.XferID.VFileType = upload.Asset.Type; 82 xfer.XferID.VFileType = upload.Asset.Type;
83 xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID); 83 xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID);
84 xfer.XferID.FilePath = 0; 84 xfer.XferID.FilePath = 0;
85 xfer.XferID.Filename = new byte[0]; 85 xfer.XferID.Filename = new byte[0];
86 this.ourClient.OutPacket(xfer); 86 this.ourClient.OutPacket(xfer);
87 } 87 }
88 88
89 } 89 }
90 90
91 public AssetBase GetUpload(LLUUID transactionID) 91 public AssetBase GetUpload(LLUUID transactionID)
92 { 92 {
93 if (this.transactions.ContainsKey(transactionID)) 93 if (this.transactions.ContainsKey(transactionID))
94 { 94 {
95 return this.transactions[transactionID].Asset; 95 return this.transactions[transactionID].Asset;
96 } 96 }
97 97
98 return null; 98 return null;
99 } 99 }
100 100
101 public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID) 101 public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID)
102 { 102 {
103 // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString()); 103 // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString());
104 AssetBase asset = null; 104 AssetBase asset = null;
105 if (pack.AssetBlock.Type == 0) 105 if (pack.AssetBlock.Type == 0)
106 { 106 {
107 107
108 //first packet for transaction 108 //first packet for transaction
109 asset = new AssetBase(); 109 asset = new AssetBase();
110 asset.FullID = assetID; 110 asset.FullID = assetID;
111 asset.Type = pack.AssetBlock.Type; 111 asset.Type = pack.AssetBlock.Type;
112 asset.InvType = asset.Type; 112 asset.InvType = asset.Type;
113 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); 113 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
114 asset.Data = pack.AssetBlock.AssetData; 114 asset.Data = pack.AssetBlock.AssetData;
115 115
116 116
117 } 117 }
118 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7) 118 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7)
119 { 119 {
120 120
121 asset = new AssetBase(); 121 asset = new AssetBase();
122 asset.FullID = assetID; 122 asset.FullID = assetID;
123 // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated()); 123 // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated());
124 asset.Type = pack.AssetBlock.Type; 124 asset.Type = pack.AssetBlock.Type;
125 asset.InvType = asset.Type; 125 asset.InvType = asset.Type;
126 asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000"); 126 asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000");
127 asset.Data = pack.AssetBlock.AssetData; 127 asset.Data = pack.AssetBlock.AssetData;
128 128
129 129
130 } 130 }
131 131
132 if (asset != null) 132 if (asset != null)
133 { 133 {
134 this.AddUpload(pack.AssetBlock.TransactionID, asset); 134 this.AddUpload(pack.AssetBlock.TransactionID, asset);
135 } 135 }
136 else 136 else
137 { 137 {
138 138
139 //currently we don't support this asset type 139 //currently we don't support this asset type
140 //so lets just tell the client that the upload is complete 140 //so lets just tell the client that the upload is complete
141 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 141 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
142 response.AssetBlock.Type = pack.AssetBlock.Type; 142 response.AssetBlock.Type = pack.AssetBlock.Type;
143 response.AssetBlock.Success = true; 143 response.AssetBlock.Success = true;
144 response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID); 144 response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID);
145 this.ourClient.OutPacket(response); 145 this.ourClient.OutPacket(response);
146 } 146 }
147 147
148 } 148 }
149 149
150 #region Xfer packet system for larger uploads 150 #region Xfer packet system for larger uploads
151 151
152 public void HandleXferPacket(SendXferPacketPacket xferPacket) 152 public void HandleXferPacket(SendXferPacketPacket xferPacket)
153 { 153 {
154 lock (this.transactions) 154 lock (this.transactions)
155 { 155 {
156 foreach (AssetTransaction trans in this.transactions.Values) 156 foreach (AssetTransaction trans in this.transactions.Values)
157 { 157 {
158 if (trans.XferID == xferPacket.XferID.ID) 158 if (trans.XferID == xferPacket.XferID.ID)
159 { 159 {
160 if (trans.Asset.Data.Length > 1) 160 if (trans.Asset.Data.Length > 1)
161 { 161 {
162 byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length]; 162 byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length];
163 Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length); 163 Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length);
164 Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); 164 Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length);
165 trans.Asset.Data = newArray; 165 trans.Asset.Data = newArray;
166 } 166 }
167 else 167 else
168 { 168 {
169 byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; 169 byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4];
170 Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); 170 Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4);
171 trans.Asset.Data = newArray; 171 trans.Asset.Data = newArray;
172 } 172 }
173 173
174 if ((xferPacket.XferID.Packet & 2147483648) != 0) 174 if ((xferPacket.XferID.Packet & 2147483648) != 0)
175 { 175 {
176 //end of transfer 176 //end of transfer
177 trans.UploadComplete = true; 177 trans.UploadComplete = true;
178 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 178 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
179 response.AssetBlock.Type = trans.Asset.Type; 179 response.AssetBlock.Type = trans.Asset.Type;
180 response.AssetBlock.Success = true; 180 response.AssetBlock.Success = true;
181 response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); 181 response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID);
182 this.ourClient.OutPacket(response); 182 this.ourClient.OutPacket(response);
183 183
184 m_assetCache.AddAsset(trans.Asset); 184 m_assetCache.AddAsset(trans.Asset);
185 //check if we should add it to inventory 185 //check if we should add it to inventory
186 if (trans.AddToInventory) 186 if (trans.AddToInventory)
187 { 187 {
188 // m_assetCache.AddAsset(trans.Asset); 188 // m_assetCache.AddAsset(trans.Asset);
189 m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); 189 m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset);
190 } 190 }
191 191
192 192
193 } 193 }
194 break; 194 break;
195 } 195 }
196 196
197 } 197 }
198 } 198 }
199 199
200 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); 200 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
201 confirmXfer.XferID.ID = xferPacket.XferID.ID; 201 confirmXfer.XferID.ID = xferPacket.XferID.ID;
202 confirmXfer.XferID.Packet = xferPacket.XferID.Packet; 202 confirmXfer.XferID.Packet = xferPacket.XferID.Packet;
203 this.ourClient.OutPacket(confirmXfer); 203 this.ourClient.OutPacket(confirmXfer);
204 } 204 }
205 205
206 #endregion 206 #endregion
207 207
208 public AssetBase AddUploadToAssetCache(LLUUID transactionID) 208 public AssetBase AddUploadToAssetCache(LLUUID transactionID)
209 { 209 {
210 AssetBase asset = null; 210 AssetBase asset = null;
211 if (this.transactions.ContainsKey(transactionID)) 211 if (this.transactions.ContainsKey(transactionID))
212 { 212 {
213 AssetTransaction trans = this.transactions[transactionID]; 213 AssetTransaction trans = this.transactions[transactionID];
214 if (trans.UploadComplete) 214 if (trans.UploadComplete)
215 { 215 {
216 m_assetCache.AddAsset(trans.Asset); 216 m_assetCache.AddAsset(trans.Asset);
217 asset = trans.Asset; 217 asset = trans.Asset;
218 } 218 }
219 } 219 }
220 220
221 return asset; 221 return asset;
222 } 222 }
223 223
224 public void CreateInventoryItem(CreateInventoryItemPacket packet) 224 public void CreateInventoryItem(CreateInventoryItemPacket packet)
225 { 225 {
226 if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) 226 if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID))
227 { 227 {
228 AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID]; 228 AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID];
229 trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description); 229 trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description);
230 trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name); 230 trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name);
231 trans.Asset.Type = packet.InventoryBlock.Type; 231 trans.Asset.Type = packet.InventoryBlock.Type;
232 trans.Asset.InvType = packet.InventoryBlock.InvType; 232 trans.Asset.InvType = packet.InventoryBlock.InvType;
233 if (trans.UploadComplete) 233 if (trans.UploadComplete)
234 { 234 {
235 //already complete so we can add it to the inventory 235 //already complete so we can add it to the inventory
236 //m_assetCache.AddAsset(trans.Asset); 236 //m_assetCache.AddAsset(trans.Asset);
237 m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset); 237 m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset);
238 } 238 }
239 else 239 else
240 { 240 {
241 trans.AddToInventory = true; 241 trans.AddToInventory = true;
242 trans.InventFolder = packet.InventoryBlock.FolderID; 242 trans.InventFolder = packet.InventoryBlock.FolderID;
243 } 243 }
244 } 244 }
245 } 245 }
246 246
247 private class AssetTransaction 247 private class AssetTransaction
248 { 248 {
249 public uint XferID; 249 public uint XferID;
250 public AssetBase Asset; 250 public AssetBase Asset;
251 public bool AddToInventory; 251 public bool AddToInventory;
252 public LLUUID InventFolder = LLUUID.Zero; 252 public LLUUID InventFolder = LLUUID.Zero;
253 public bool UploadComplete = false; 253 public bool UploadComplete = false;
254 public LLUUID TransactionID = LLUUID.Zero; 254 public LLUUID TransactionID = LLUUID.Zero;
255 255
256 public AssetTransaction() 256 public AssetTransaction()
257 { 257 {
258 258
259 } 259 }
260 } 260 }
261 261
262 //new class , not currently used. 262 //new class , not currently used.
263 public class AssetXferUploader 263 public class AssetXferUploader
264 { 264 {
265 private IClientAPI ourClient; 265 private IClientAPI ourClient;
266 266
267 public bool UploadComplete = false; 267 public bool UploadComplete = false;
268 268
269 public bool AddToInventory; 269 public bool AddToInventory;
270 public LLUUID InventFolder = LLUUID.Zero; 270 public LLUUID InventFolder = LLUUID.Zero;
271 271
272 public uint XferID; 272 public uint XferID;
273 public AssetBase Asset; 273 public AssetBase Asset;
274 public LLUUID TransactionID = LLUUID.Zero; 274 public LLUUID TransactionID = LLUUID.Zero;
275 275
276 276
277 public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) 277 public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
278 { 278 {
279 ourClient = remoteClient; 279 ourClient = remoteClient;
280 Asset = new AssetBase(); 280 Asset = new AssetBase();
281 Asset.FullID = assetID; 281 Asset.FullID = assetID;
282 Asset.InvType = type; 282 Asset.InvType = type;
283 Asset.Type = type; 283 Asset.Type = type;
284 Asset.Data = data; 284 Asset.Data = data;
285 Asset.Name = "blank"; 285 Asset.Name = "blank";
286 Asset.Description = "empty"; 286 Asset.Description = "empty";
287 TransactionID = transaction; 287 TransactionID = transaction;
288 288
289 if (Asset.Data.Length > 2) 289 if (Asset.Data.Length > 2)
290 { 290 {
291 //data block should only have data in it, if there is no more data to be uploaded 291 //data block should only have data in it, if there is no more data to be uploaded
292 this.SendCompleteMessage(); 292 this.SendCompleteMessage();
293 } 293 }
294 else 294 else
295 { 295 {
296 this.ReqestStartXfer(); 296 this.ReqestStartXfer();
297 } 297 }
298 } 298 }
299 299
300 protected void SendCompleteMessage() 300 protected void SendCompleteMessage()
301 { 301 {
302 UploadComplete = true; 302 UploadComplete = true;
303 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 303 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
304 response.AssetBlock.Type = Asset.Type; 304 response.AssetBlock.Type = Asset.Type;
305 response.AssetBlock.Success = true; 305 response.AssetBlock.Success = true;
306 response.AssetBlock.UUID = Asset.FullID; 306 response.AssetBlock.UUID = Asset.FullID;
307 this.ourClient.OutPacket(response); 307 this.ourClient.OutPacket(response);
308 308
309 //TODO trigger event 309 //TODO trigger event
310 } 310 }
311 311
312 protected void ReqestStartXfer() 312 protected void ReqestStartXfer()
313 { 313 {
314 UploadComplete = false; 314 UploadComplete = false;
315 XferID = Util.GetNextXferID(); 315 XferID = Util.GetNextXferID();
316 RequestXferPacket xfer = new RequestXferPacket(); 316 RequestXferPacket xfer = new RequestXferPacket();
317 xfer.XferID.ID = XferID; 317 xfer.XferID.ID = XferID;
318 xfer.XferID.VFileType = Asset.Type; 318 xfer.XferID.VFileType = Asset.Type;
319 xfer.XferID.VFileID = Asset.FullID; 319 xfer.XferID.VFileID = Asset.FullID;
320 xfer.XferID.FilePath = 0; 320 xfer.XferID.FilePath = 0;
321 xfer.XferID.Filename = new byte[0]; 321 xfer.XferID.Filename = new byte[0];
322 this.ourClient.OutPacket(xfer); 322 this.ourClient.OutPacket(xfer);
323 } 323 }
324 324
325 public void HandleXferPacket(uint xferID, uint packetID, byte[] data) 325 public void HandleXferPacket(uint xferID, uint packetID, byte[] data)
326 { 326 {
327 if (XferID == xferID) 327 if (XferID == xferID)
328 { 328 {
329 if (Asset.Data.Length > 1) 329 if (Asset.Data.Length > 1)
330 { 330 {
331 byte[] newArray = new byte[Asset.Data.Length + data.Length]; 331 byte[] newArray = new byte[Asset.Data.Length + data.Length];
332 Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length); 332 Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length);
333 Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length); 333 Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length);
334 Asset.Data = newArray; 334 Asset.Data = newArray;
335 } 335 }
336 else 336 else
337 { 337 {
338 byte[] newArray = new byte[data.Length - 4]; 338 byte[] newArray = new byte[data.Length - 4];
339 Array.Copy(data, 4, newArray, 0, data.Length - 4); 339 Array.Copy(data, 4, newArray, 0, data.Length - 4);
340 Asset.Data = newArray; 340 Asset.Data = newArray;
341 } 341 }
342 342
343 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); 343 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
344 confirmXfer.XferID.ID = xferID; 344 confirmXfer.XferID.ID = xferID;
345 confirmXfer.XferID.Packet = packetID; 345 confirmXfer.XferID.Packet = packetID;
346 this.ourClient.OutPacket(confirmXfer); 346 this.ourClient.OutPacket(confirmXfer);
347 347
348 if ((packetID & 2147483648) != 0) 348 if ((packetID & 2147483648) != 0)
349 { 349 {
350 this.SendCompleteMessage(); 350 this.SendCompleteMessage();
351 } 351 }
352 } 352 }
353 } 353 }
354 } 354 }
355 } 355 }
356 } 356 }
357} 357}