diff options
Deleted a few old files that are no longer used.
Deleted the GridInterfaces projects, and for now moved the old local asset server into Framework.Communications, as we prepare to rewrite the asset cache and asset server.
Deleted Framework.manager as I am sure this is no longer in use.
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs | 357 |
1 files changed, 0 insertions, 357 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs deleted file mode 100644 index 6a05ba2..0000000 --- a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs +++ /dev/null | |||
@@ -1,357 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using libsecondlife.Packets; | ||
32 | using OpenSim.Framework.Interfaces; | ||
33 | using OpenSim.Framework.Types; | ||
34 | using OpenSim.Framework.Utilities; | ||
35 | using OpenSim.Framework.Communications.Caches; | ||
36 | |||
37 | |||
38 | namespace OpenSim.Region.ClientStack | ||
39 | { | ||
40 | partial class ClientView | ||
41 | { | ||
42 | public class AgentAssetUpload | ||
43 | { | ||
44 | private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>(); | ||
45 | private ClientView ourClient; | ||
46 | private AssetCache m_assetCache; | ||
47 | // private InventoryCache m_inventoryCache; | ||
48 | |||
49 | public AgentAssetUpload(ClientView client, AssetCache assetCache ) | ||
50 | { | ||
51 | this.ourClient = client; | ||
52 | m_assetCache = assetCache; | ||
53 | // m_inventoryCache = inventoryCache; | ||
54 | } | ||
55 | |||
56 | public void AddUpload(LLUUID transactionID, AssetBase asset) | ||
57 | { | ||
58 | AssetTransaction upload = new AssetTransaction(); | ||
59 | lock (this.transactions) | ||
60 | { | ||
61 | upload.Asset = asset; | ||
62 | upload.TransactionID = transactionID; | ||
63 | this.transactions.Add(transactionID, upload); | ||
64 | } | ||
65 | if (upload.Asset.Data.Length > 2) | ||
66 | { | ||
67 | //is complete | ||
68 | upload.UploadComplete = true; | ||
69 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | ||
70 | response.AssetBlock.Type = asset.Type; | ||
71 | response.AssetBlock.Success = true; | ||
72 | response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID); | ||
73 | this.ourClient.OutPacket(response); | ||
74 | m_assetCache.AddAsset(asset); | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | upload.UploadComplete = false; | ||
79 | upload.XferID = Util.GetNextXferID(); | ||
80 | RequestXferPacket xfer = new RequestXferPacket(); | ||
81 | xfer.XferID.ID = upload.XferID; | ||
82 | xfer.XferID.VFileType = upload.Asset.Type; | ||
83 | xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID); | ||
84 | xfer.XferID.FilePath = 0; | ||
85 | xfer.XferID.Filename = new byte[0]; | ||
86 | this.ourClient.OutPacket(xfer); | ||
87 | } | ||
88 | |||
89 | } | ||
90 | |||
91 | public AssetBase GetUpload(LLUUID transactionID) | ||
92 | { | ||
93 | if (this.transactions.ContainsKey(transactionID)) | ||
94 | { | ||
95 | return this.transactions[transactionID].Asset; | ||
96 | } | ||
97 | |||
98 | return null; | ||
99 | } | ||
100 | |||
101 | public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID) | ||
102 | { | ||
103 | // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString()); | ||
104 | AssetBase asset = null; | ||
105 | if (pack.AssetBlock.Type == 0) | ||
106 | { | ||
107 | |||
108 | //first packet for transaction | ||
109 | asset = new AssetBase(); | ||
110 | asset.FullID = assetID; | ||
111 | asset.Type = pack.AssetBlock.Type; | ||
112 | asset.InvType = asset.Type; | ||
113 | asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); | ||
114 | asset.Data = pack.AssetBlock.AssetData; | ||
115 | |||
116 | |||
117 | } | ||
118 | else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7) | ||
119 | { | ||
120 | |||
121 | asset = new AssetBase(); | ||
122 | asset.FullID = assetID; | ||
123 | // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated()); | ||
124 | asset.Type = pack.AssetBlock.Type; | ||
125 | asset.InvType = asset.Type; | ||
126 | asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000"); | ||
127 | asset.Data = pack.AssetBlock.AssetData; | ||
128 | |||
129 | |||
130 | } | ||
131 | |||
132 | if (asset != null) | ||
133 | { | ||
134 | this.AddUpload(pack.AssetBlock.TransactionID, asset); | ||
135 | } | ||
136 | else | ||
137 | { | ||
138 | |||
139 | //currently we don't support this asset type | ||
140 | //so lets just tell the client that the upload is complete | ||
141 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | ||
142 | response.AssetBlock.Type = pack.AssetBlock.Type; | ||
143 | response.AssetBlock.Success = true; | ||
144 | response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID); | ||
145 | this.ourClient.OutPacket(response); | ||
146 | } | ||
147 | |||
148 | } | ||
149 | |||
150 | #region Xfer packet system for larger uploads | ||
151 | |||
152 | public void HandleXferPacket(SendXferPacketPacket xferPacket) | ||
153 | { | ||
154 | lock (this.transactions) | ||
155 | { | ||
156 | foreach (AssetTransaction trans in this.transactions.Values) | ||
157 | { | ||
158 | if (trans.XferID == xferPacket.XferID.ID) | ||
159 | { | ||
160 | if (trans.Asset.Data.Length > 1) | ||
161 | { | ||
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); | ||
164 | Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); | ||
165 | trans.Asset.Data = newArray; | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; | ||
170 | Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); | ||
171 | trans.Asset.Data = newArray; | ||
172 | } | ||
173 | |||
174 | if ((xferPacket.XferID.Packet & 2147483648) != 0) | ||
175 | { | ||
176 | //end of transfer | ||
177 | trans.UploadComplete = true; | ||
178 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | ||
179 | response.AssetBlock.Type = trans.Asset.Type; | ||
180 | response.AssetBlock.Success = true; | ||
181 | response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); | ||
182 | this.ourClient.OutPacket(response); | ||
183 | |||
184 | m_assetCache.AddAsset(trans.Asset); | ||
185 | //check if we should add it to inventory | ||
186 | if (trans.AddToInventory) | ||
187 | { | ||
188 | // m_assetCache.AddAsset(trans.Asset); | ||
189 | //m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); | ||
190 | } | ||
191 | |||
192 | |||
193 | } | ||
194 | break; | ||
195 | } | ||
196 | |||
197 | } | ||
198 | } | ||
199 | |||
200 | ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); | ||
201 | confirmXfer.XferID.ID = xferPacket.XferID.ID; | ||
202 | confirmXfer.XferID.Packet = xferPacket.XferID.Packet; | ||
203 | this.ourClient.OutPacket(confirmXfer); | ||
204 | } | ||
205 | |||
206 | #endregion | ||
207 | |||
208 | public AssetBase AddUploadToAssetCache(LLUUID transactionID) | ||
209 | { | ||
210 | AssetBase asset = null; | ||
211 | if (this.transactions.ContainsKey(transactionID)) | ||
212 | { | ||
213 | AssetTransaction trans = this.transactions[transactionID]; | ||
214 | if (trans.UploadComplete) | ||
215 | { | ||
216 | m_assetCache.AddAsset(trans.Asset); | ||
217 | asset = trans.Asset; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | return asset; | ||
222 | } | ||
223 | |||
224 | public void CreateInventoryItem(CreateInventoryItemPacket packet) | ||
225 | { | ||
226 | if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) | ||
227 | { | ||
228 | AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID]; | ||
229 | trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description); | ||
230 | trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name); | ||
231 | trans.Asset.Type = packet.InventoryBlock.Type; | ||
232 | trans.Asset.InvType = packet.InventoryBlock.InvType; | ||
233 | if (trans.UploadComplete) | ||
234 | { | ||
235 | //already complete so we can add it to the inventory | ||
236 | //m_assetCache.AddAsset(trans.Asset); | ||
237 | // m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset); | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | trans.AddToInventory = true; | ||
242 | trans.InventFolder = packet.InventoryBlock.FolderID; | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | |||
247 | private class AssetTransaction | ||
248 | { | ||
249 | public uint XferID; | ||
250 | public AssetBase Asset; | ||
251 | public bool AddToInventory; | ||
252 | public LLUUID InventFolder = LLUUID.Zero; | ||
253 | public bool UploadComplete = false; | ||
254 | public LLUUID TransactionID = LLUUID.Zero; | ||
255 | |||
256 | public AssetTransaction() | ||
257 | { | ||
258 | |||
259 | } | ||
260 | } | ||
261 | |||
262 | //new class , not currently used. | ||
263 | public class AssetXferUploader | ||
264 | { | ||
265 | private IClientAPI ourClient; | ||
266 | |||
267 | public bool UploadComplete = false; | ||
268 | |||
269 | public bool AddToInventory; | ||
270 | public LLUUID InventFolder = LLUUID.Zero; | ||
271 | |||
272 | public uint XferID; | ||
273 | public AssetBase Asset; | ||
274 | public LLUUID TransactionID = LLUUID.Zero; | ||
275 | |||
276 | |||
277 | public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) | ||
278 | { | ||
279 | ourClient = remoteClient; | ||
280 | Asset = new AssetBase(); | ||
281 | Asset.FullID = assetID; | ||
282 | Asset.InvType = type; | ||
283 | Asset.Type = type; | ||
284 | Asset.Data = data; | ||
285 | Asset.Name = "blank"; | ||
286 | Asset.Description = "empty"; | ||
287 | TransactionID = transaction; | ||
288 | |||
289 | if (Asset.Data.Length > 2) | ||
290 | { | ||
291 | //data block should only have data in it, if there is no more data to be uploaded | ||
292 | this.SendCompleteMessage(); | ||
293 | } | ||
294 | else | ||
295 | { | ||
296 | this.ReqestStartXfer(); | ||
297 | } | ||
298 | } | ||
299 | |||
300 | protected void SendCompleteMessage() | ||
301 | { | ||
302 | UploadComplete = true; | ||
303 | AssetUploadCompletePacket response = new AssetUploadCompletePacket(); | ||
304 | response.AssetBlock.Type = Asset.Type; | ||
305 | response.AssetBlock.Success = true; | ||
306 | response.AssetBlock.UUID = Asset.FullID; | ||
307 | this.ourClient.OutPacket(response); | ||
308 | |||
309 | //TODO trigger event | ||
310 | } | ||
311 | |||
312 | protected void ReqestStartXfer() | ||
313 | { | ||
314 | UploadComplete = false; | ||
315 | XferID = Util.GetNextXferID(); | ||
316 | RequestXferPacket xfer = new RequestXferPacket(); | ||
317 | xfer.XferID.ID = XferID; | ||
318 | xfer.XferID.VFileType = Asset.Type; | ||
319 | xfer.XferID.VFileID = Asset.FullID; | ||
320 | xfer.XferID.FilePath = 0; | ||
321 | xfer.XferID.Filename = new byte[0]; | ||
322 | this.ourClient.OutPacket(xfer); | ||
323 | } | ||
324 | |||
325 | public void HandleXferPacket(uint xferID, uint packetID, byte[] data) | ||
326 | { | ||
327 | if (XferID == xferID) | ||
328 | { | ||
329 | if (Asset.Data.Length > 1) | ||
330 | { | ||
331 | byte[] newArray = new byte[Asset.Data.Length + data.Length]; | ||
332 | Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length); | ||
333 | Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length); | ||
334 | Asset.Data = newArray; | ||
335 | } | ||
336 | else | ||
337 | { | ||
338 | byte[] newArray = new byte[data.Length - 4]; | ||
339 | Array.Copy(data, 4, newArray, 0, data.Length - 4); | ||
340 | Asset.Data = newArray; | ||
341 | } | ||
342 | |||
343 | ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); | ||
344 | confirmXfer.XferID.ID = xferID; | ||
345 | confirmXfer.XferID.Packet = packetID; | ||
346 | this.ourClient.OutPacket(confirmXfer); | ||
347 | |||
348 | if ((packetID & 2147483648) != 0) | ||
349 | { | ||
350 | this.SendCompleteMessage(); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | } | ||