diff options
author | Adam Frisby | 2008-04-30 21:16:36 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-30 21:16:36 +0000 |
commit | f5c312bc3c2567449c7268a54a08a54119f58d53 (patch) | |
tree | 424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/Agent/AssetTransaction | |
parent | * Adds the AuthbuyerID field to sqlite and makes use of it. (diff) | |
download | opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.zip opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2 opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.xz |
* Refactored Environment/Modules directory - modules now reside in their own directory with any associated module-specific classes.
* Each module directory is currently inside one of the following category folders: Agent (Anything relating to do with Client<->Server communications.), Avatar (Anything to do with the avatar or presence inworld), Framework (Classes modules can use), Grid (Grid traffic, new OGS2 grid comms), Scripting (Scripting functions, etc), World (The enrivonment/scene, IE Sun/Tree modules.)
* This should be moved into a seperate project file.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs (renamed from OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs) | 815 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs (renamed from OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs) | 572 |
2 files changed, 693 insertions, 694 deletions
diff --git a/OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 9fa173d..74bb247 100644 --- a/OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -1,408 +1,407 @@ | |||
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using libsecondlife.Packets; | 32 | using libsecondlife.Packets; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications.Cache; | 34 | using OpenSim.Framework.Communications.Cache; |
35 | 35 | ||
36 | namespace OpenSim.Region.Environment.Modules | 36 | namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction |
37 | { | 37 | { |
38 | 38 | /// <summary> | |
39 | /// <summary> | 39 | /// Manage asset transactions for a single agent. |
40 | /// Manage asset transactions for a single agent. | 40 | /// </summary> |
41 | /// </summary> | 41 | public class AgentAssetTransactions |
42 | public class AgentAssetTransactions | 42 | { |
43 | { | 43 | //private static readonly log4net.ILog m_log |
44 | //private static readonly log4net.ILog m_log | 44 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
45 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 45 | |
46 | 46 | // Fields | |
47 | // Fields | 47 | public LLUUID UserID; |
48 | public LLUUID UserID; | 48 | public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); |
49 | public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); | 49 | public AgentAssetTransactionsManager Manager; |
50 | public AgentAssetTransactionsManager Manager; | 50 | private bool m_dumpAssetsToFile; |
51 | private bool m_dumpAssetsToFile; | 51 | |
52 | 52 | // Methods | |
53 | // Methods | 53 | public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) |
54 | public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) | 54 | { |
55 | { | 55 | UserID = agentID; |
56 | UserID = agentID; | 56 | Manager = manager; |
57 | Manager = manager; | 57 | m_dumpAssetsToFile = dumpAssetsToFile; |
58 | m_dumpAssetsToFile = dumpAssetsToFile; | 58 | } |
59 | } | 59 | |
60 | 60 | public AssetXferUploader RequestXferUploader(LLUUID transactionID) | |
61 | public AssetXferUploader RequestXferUploader(LLUUID transactionID) | 61 | { |
62 | { | 62 | if (!XferUploaders.ContainsKey(transactionID)) |
63 | if (!XferUploaders.ContainsKey(transactionID)) | 63 | { |
64 | { | 64 | AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); |
65 | AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); | 65 | |
66 | 66 | lock (XferUploaders) | |
67 | lock (XferUploaders) | 67 | { |
68 | { | 68 | XferUploaders.Add(transactionID, uploader); |
69 | XferUploaders.Add(transactionID, uploader); | 69 | } |
70 | } | 70 | |
71 | 71 | return uploader; | |
72 | return uploader; | 72 | } |
73 | } | 73 | return null; |
74 | return null; | 74 | } |
75 | } | 75 | |
76 | 76 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | |
77 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | 77 | { |
78 | { | 78 | // AssetXferUploader uploaderFound = null; |
79 | // AssetXferUploader uploaderFound = null; | 79 | |
80 | 80 | lock (XferUploaders) | |
81 | lock (XferUploaders) | 81 | { |
82 | { | 82 | foreach (AssetXferUploader uploader in XferUploaders.Values) |
83 | foreach (AssetXferUploader uploader in XferUploaders.Values) | 83 | { |
84 | { | 84 | if (uploader.XferID == xferID) |
85 | if (uploader.XferID == xferID) | 85 | { |
86 | { | 86 | uploader.HandleXferPacket(xferID, packetID, data); |
87 | uploader.HandleXferPacket(xferID, packetID, data); | 87 | break; |
88 | break; | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |
92 | } | 92 | |
93 | 93 | public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | |
94 | public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | 94 | uint callbackID, string description, string name, sbyte invType, |
95 | uint callbackID, string description, string name, sbyte invType, | 95 | sbyte type, byte wearableType, uint nextOwnerMask) |
96 | sbyte type, byte wearableType, uint nextOwnerMask) | 96 | { |
97 | { | 97 | if (XferUploaders.ContainsKey(transactionID)) |
98 | if (XferUploaders.ContainsKey(transactionID)) | 98 | { |
99 | { | 99 | XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, |
100 | XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, | 100 | callbackID, description, name, invType, type, |
101 | callbackID, description, name, invType, type, | 101 | wearableType, nextOwnerMask); |
102 | wearableType, nextOwnerMask); | 102 | } |
103 | } | 103 | } |
104 | } | 104 | |
105 | 105 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, | |
106 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, | 106 | InventoryItemBase item) |
107 | InventoryItemBase item) | 107 | { |
108 | { | 108 | if (XferUploaders.ContainsKey(transactionID)) |
109 | if (XferUploaders.ContainsKey(transactionID)) | 109 | { |
110 | { | 110 | XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); |
111 | XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); | 111 | } |
112 | } | 112 | } |
113 | } | 113 | |
114 | 114 | /// <summary> | |
115 | /// <summary> | 115 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. |
116 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. | 116 | /// </summary> |
117 | /// </summary> | 117 | /// <param name="transactionID"></param> |
118 | /// <param name="transactionID"></param> | 118 | /// <returns>The asset if the upload has completed, null if it has not.</returns> |
119 | /// <returns>The asset if the upload has completed, null if it has not.</returns> | 119 | public AssetBase GetTransactionAsset(LLUUID transactionID) |
120 | public AssetBase GetTransactionAsset(LLUUID transactionID) | 120 | { |
121 | { | 121 | if (XferUploaders.ContainsKey(transactionID)) |
122 | if (XferUploaders.ContainsKey(transactionID)) | 122 | { |
123 | { | 123 | AssetXferUploader uploader = XferUploaders[transactionID]; |
124 | AssetXferUploader uploader = XferUploaders[transactionID]; | 124 | AssetBase asset = uploader.GetAssetData(); |
125 | AssetBase asset = uploader.GetAssetData(); | 125 | |
126 | 126 | lock (XferUploaders) | |
127 | lock (XferUploaders) | 127 | { |
128 | { | 128 | XferUploaders.Remove(transactionID); |
129 | XferUploaders.Remove(transactionID); | 129 | } |
130 | } | 130 | |
131 | 131 | return asset; | |
132 | return asset; | 132 | } |
133 | } | 133 | |
134 | 134 | return null; | |
135 | return null; | 135 | } |
136 | } | 136 | |
137 | 137 | // Nested Types | |
138 | // Nested Types | 138 | public class AssetXferUploader |
139 | public class AssetXferUploader | 139 | { |
140 | { | 140 | // Fields |
141 | // Fields | 141 | public bool AddToInventory; |
142 | public bool AddToInventory; | 142 | public AssetBase Asset; |
143 | public AssetBase Asset; | 143 | public LLUUID InventFolder = LLUUID.Zero; |
144 | public LLUUID InventFolder = LLUUID.Zero; | 144 | private IClientAPI ourClient; |
145 | private IClientAPI ourClient; | 145 | public LLUUID TransactionID = LLUUID.Zero; |
146 | public LLUUID TransactionID = LLUUID.Zero; | 146 | public bool UploadComplete; |
147 | public bool UploadComplete; | 147 | public ulong XferID; |
148 | public ulong XferID; | 148 | private string m_name = String.Empty; |
149 | private string m_name = String.Empty; | 149 | private string m_description = String.Empty; |
150 | private string m_description = String.Empty; | 150 | private sbyte type = 0; |
151 | private sbyte type = 0; | 151 | private sbyte invType = 0; |
152 | private sbyte invType = 0; | 152 | private byte wearableType = 0; |
153 | private byte wearableType = 0; | 153 | private uint nextPerm = 0; |
154 | private uint nextPerm = 0; | 154 | private bool m_finished = false; |
155 | private bool m_finished = false; | 155 | private bool m_createItem = false; |
156 | private bool m_createItem = false; | 156 | private AgentAssetTransactions m_userTransactions; |
157 | private AgentAssetTransactions m_userTransactions; | 157 | private bool m_storeLocal; |
158 | private bool m_storeLocal; | 158 | private bool m_dumpAssetToFile; |
159 | private bool m_dumpAssetToFile; | 159 | |
160 | 160 | public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) | |
161 | public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) | 161 | { |
162 | { | 162 | m_userTransactions = transactions; |
163 | m_userTransactions = transactions; | 163 | m_dumpAssetToFile = dumpAssetToFile; |
164 | m_dumpAssetToFile = dumpAssetToFile; | 164 | } |
165 | } | 165 | |
166 | 166 | /// <summary> | |
167 | /// <summary> | 167 | /// Process transfer data received from the client. |
168 | /// Process transfer data received from the client. | 168 | /// </summary> |
169 | /// </summary> | 169 | /// <param name="xferID"></param> |
170 | /// <param name="xferID"></param> | 170 | /// <param name="packetID"></param> |
171 | /// <param name="packetID"></param> | 171 | /// <param name="data"></param> |
172 | /// <param name="data"></param> | 172 | /// <returns>True if the transfer is complete, false otherwise or if the xferID was not valid</returns> |
173 | /// <returns>True if the transfer is complete, false otherwise or if the xferID was not valid</returns> | 173 | public bool HandleXferPacket(ulong xferID, uint packetID, byte[] data) |
174 | public bool HandleXferPacket(ulong xferID, uint packetID, byte[] data) | 174 | { |
175 | { | 175 | if (XferID == xferID) |
176 | if (XferID == xferID) | 176 | { |
177 | { | 177 | if (Asset.Data.Length > 1) |
178 | if (Asset.Data.Length > 1) | 178 | { |
179 | { | 179 | byte[] destinationArray = new byte[Asset.Data.Length + data.Length]; |
180 | byte[] destinationArray = new byte[Asset.Data.Length + data.Length]; | 180 | Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length); |
181 | Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length); | 181 | Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length); |
182 | Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length); | 182 | Asset.Data = destinationArray; |
183 | Asset.Data = destinationArray; | 183 | } |
184 | } | 184 | else |
185 | else | 185 | { |
186 | { | 186 | byte[] buffer2 = new byte[data.Length - 4]; |
187 | byte[] buffer2 = new byte[data.Length - 4]; | 187 | Array.Copy(data, 4, buffer2, 0, data.Length - 4); |
188 | Array.Copy(data, 4, buffer2, 0, data.Length - 4); | 188 | Asset.Data = buffer2; |
189 | Asset.Data = buffer2; | 189 | } |
190 | } | 190 | ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); |
191 | ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); | 191 | newPack.XferID.ID = xferID; |
192 | newPack.XferID.ID = xferID; | 192 | newPack.XferID.Packet = packetID; |
193 | newPack.XferID.Packet = packetID; | 193 | ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); |
194 | ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); | 194 | if ((packetID & 0x80000000) != 0) |
195 | if ((packetID & 0x80000000) != 0) | 195 | { |
196 | { | 196 | SendCompleteMessage(); |
197 | SendCompleteMessage(); | 197 | return true; |
198 | return true; | 198 | } |
199 | } | 199 | } |
200 | } | 200 | |
201 | 201 | return false; | |
202 | return false; | 202 | } |
203 | } | 203 | |
204 | 204 | /// <summary> | |
205 | /// <summary> | 205 | /// Initialise asset transfer from the client |
206 | /// Initialise asset transfer from the client | 206 | /// </summary> |
207 | /// </summary> | 207 | /// <param name="xferID"></param> |
208 | /// <param name="xferID"></param> | 208 | /// <param name="packetID"></param> |
209 | /// <param name="packetID"></param> | 209 | /// <param name="data"></param> |
210 | /// <param name="data"></param> | 210 | /// <returns>True if the transfer is complete, false otherwise</returns> |
211 | /// <returns>True if the transfer is complete, false otherwise</returns> | 211 | public bool Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, |
212 | public bool Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, | 212 | bool storeLocal, bool tempFile) |
213 | bool storeLocal, bool tempFile) | 213 | { |
214 | { | 214 | ourClient = remoteClient; |
215 | ourClient = remoteClient; | 215 | Asset = new AssetBase(); |
216 | Asset = new AssetBase(); | 216 | Asset.FullID = assetID; |
217 | Asset.FullID = assetID; | 217 | Asset.InvType = type; |
218 | Asset.InvType = type; | 218 | Asset.Type = type; |
219 | Asset.Type = type; | 219 | Asset.Data = data; |
220 | Asset.Data = data; | 220 | Asset.Name = "blank"; |
221 | Asset.Name = "blank"; | 221 | Asset.Description = "empty"; |
222 | Asset.Description = "empty"; | 222 | Asset.Local = storeLocal; |
223 | Asset.Local = storeLocal; | 223 | Asset.Temporary = tempFile; |
224 | Asset.Temporary = tempFile; | 224 | |
225 | 225 | TransactionID = transaction; | |
226 | TransactionID = transaction; | 226 | m_storeLocal = storeLocal; |
227 | m_storeLocal = storeLocal; | 227 | if (Asset.Data.Length > 2) |
228 | if (Asset.Data.Length > 2) | 228 | { |
229 | { | 229 | SendCompleteMessage(); |
230 | SendCompleteMessage(); | 230 | return true; |
231 | return true; | 231 | } |
232 | } | 232 | else |
233 | else | 233 | { |
234 | { | 234 | RequestStartXfer(); |
235 | RequestStartXfer(); | 235 | } |
236 | } | 236 | |
237 | 237 | return false; | |
238 | return false; | 238 | } |
239 | } | 239 | |
240 | 240 | protected void RequestStartXfer() | |
241 | protected void RequestStartXfer() | 241 | { |
242 | { | 242 | UploadComplete = false; |
243 | UploadComplete = false; | 243 | XferID = Util.GetNextXferID(); |
244 | XferID = Util.GetNextXferID(); | 244 | RequestXferPacket newPack = new RequestXferPacket(); |
245 | RequestXferPacket newPack = new RequestXferPacket(); | 245 | newPack.XferID.ID = XferID; |
246 | newPack.XferID.ID = XferID; | 246 | newPack.XferID.VFileType = Asset.Type; |
247 | newPack.XferID.VFileType = Asset.Type; | 247 | newPack.XferID.VFileID = Asset.FullID; |
248 | newPack.XferID.VFileID = Asset.FullID; | 248 | newPack.XferID.FilePath = 0; |
249 | newPack.XferID.FilePath = 0; | 249 | newPack.XferID.Filename = new byte[0]; |
250 | newPack.XferID.Filename = new byte[0]; | 250 | ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); |
251 | ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); | 251 | } |
252 | } | 252 | |
253 | 253 | protected void SendCompleteMessage() | |
254 | protected void SendCompleteMessage() | 254 | { |
255 | { | 255 | UploadComplete = true; |
256 | UploadComplete = true; | 256 | AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); |
257 | AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); | 257 | newPack.AssetBlock.Type = Asset.Type; |
258 | newPack.AssetBlock.Type = Asset.Type; | 258 | newPack.AssetBlock.Success = true; |
259 | newPack.AssetBlock.Success = true; | 259 | newPack.AssetBlock.UUID = Asset.FullID; |
260 | newPack.AssetBlock.UUID = Asset.FullID; | 260 | ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); |
261 | ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); | 261 | m_finished = true; |
262 | m_finished = true; | 262 | if (m_createItem) |
263 | if (m_createItem) | 263 | { |
264 | { | 264 | DoCreateItem(); |
265 | DoCreateItem(); | 265 | } |
266 | } | 266 | else if (m_storeLocal) |
267 | else if (m_storeLocal) | 267 | { |
268 | { | 268 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); |
269 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); | 269 | } |
270 | } | 270 | |
271 | 271 | // Console.WriteLine("upload complete "+ this.TransactionID); | |
272 | // Console.WriteLine("upload complete "+ this.TransactionID); | 272 | |
273 | 273 | if (m_dumpAssetToFile) | |
274 | if (m_dumpAssetToFile) | 274 | { |
275 | { | 275 | DateTime now = DateTime.Now; |
276 | DateTime now = DateTime.Now; | 276 | string filename = |
277 | string filename = | 277 | String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, |
278 | String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, | 278 | now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); |
279 | now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); | 279 | SaveAssetToFile(filename, Asset.Data); |
280 | SaveAssetToFile(filename, Asset.Data); | 280 | } |
281 | } | 281 | } |
282 | } | 282 | |
283 | 283 | ///Left this in and commented in case there are unforseen issues | |
284 | ///Left this in and commented in case there are unforseen issues | 284 | //private void SaveAssetToFile(string filename, byte[] data) |
285 | //private void SaveAssetToFile(string filename, byte[] data) | 285 | //{ |
286 | //{ | 286 | // FileStream fs = File.Create(filename); |
287 | // FileStream fs = File.Create(filename); | 287 | // BinaryWriter bw = new BinaryWriter(fs); |
288 | // BinaryWriter bw = new BinaryWriter(fs); | 288 | // bw.Write(data); |
289 | // bw.Write(data); | 289 | // bw.Close(); |
290 | // bw.Close(); | 290 | // fs.Close(); |
291 | // fs.Close(); | 291 | //} |
292 | //} | 292 | private void SaveAssetToFile(string filename, byte[] data) |
293 | private void SaveAssetToFile(string filename, byte[] data) | 293 | { |
294 | { | 294 | string assetPath = "UserAssets"; |
295 | string assetPath = "UserAssets"; | 295 | if (!Directory.Exists(assetPath)) |
296 | if (!Directory.Exists(assetPath)) | 296 | { |
297 | { | 297 | Directory.CreateDirectory(assetPath); |
298 | Directory.CreateDirectory(assetPath); | 298 | } |
299 | } | 299 | FileStream fs = File.Create(Path.Combine(assetPath, filename)); |
300 | FileStream fs = File.Create(Path.Combine(assetPath, filename)); | 300 | BinaryWriter bw = new BinaryWriter(fs); |
301 | BinaryWriter bw = new BinaryWriter(fs); | 301 | bw.Write(data); |
302 | bw.Write(data); | 302 | bw.Close(); |
303 | bw.Close(); | 303 | fs.Close(); |
304 | fs.Close(); | 304 | } |
305 | } | 305 | |
306 | 306 | public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | |
307 | public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | 307 | uint callbackID, string description, string name, sbyte invType, |
308 | uint callbackID, string description, string name, sbyte invType, | 308 | sbyte type, byte wearableType, uint nextOwnerMask) |
309 | sbyte type, byte wearableType, uint nextOwnerMask) | 309 | { |
310 | { | 310 | if (TransactionID == transactionID) |
311 | if (TransactionID == transactionID) | 311 | { |
312 | { | 312 | InventFolder = folderID; |
313 | InventFolder = folderID; | 313 | m_name = name; |
314 | m_name = name; | 314 | m_description = description; |
315 | m_description = description; | 315 | this.type = type; |
316 | this.type = type; | 316 | this.invType = invType; |
317 | this.invType = invType; | 317 | this.wearableType = wearableType; |
318 | this.wearableType = wearableType; | 318 | nextPerm = nextOwnerMask; |
319 | nextPerm = nextOwnerMask; | 319 | Asset.Name = name; |
320 | Asset.Name = name; | 320 | Asset.Description = description; |
321 | Asset.Description = description; | 321 | Asset.Type = type; |
322 | Asset.Type = type; | 322 | Asset.InvType = invType; |
323 | Asset.InvType = invType; | 323 | m_createItem = true; |
324 | m_createItem = true; | 324 | if (m_finished) |
325 | if (m_finished) | 325 | { |
326 | { | 326 | DoCreateItem(); |
327 | DoCreateItem(); | 327 | } |
328 | } | 328 | } |
329 | } | 329 | } |
330 | } | 330 | |
331 | 331 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, | |
332 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, | 332 | InventoryItemBase item) |
333 | InventoryItemBase item) | 333 | { |
334 | { | 334 | if (TransactionID == transactionID) |
335 | if (TransactionID == transactionID) | 335 | { |
336 | { | 336 | CachedUserInfo userInfo = |
337 | CachedUserInfo userInfo = | 337 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( |
338 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( | 338 | remoteClient.AgentId); |
339 | remoteClient.AgentId); | 339 | |
340 | 340 | if (userInfo != null) | |
341 | if (userInfo != null) | 341 | { |
342 | { | 342 | LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); |
343 | LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); | 343 | |
344 | 344 | AssetBase asset | |
345 | AssetBase asset | 345 | = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset( |
346 | = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset( | 346 | assetID, (item.AssetType == (int) AssetType.Texture ? true : false)); |
347 | assetID, (item.AssetType == (int) AssetType.Texture ? true : false)); | 347 | |
348 | 348 | if (asset == null) | |
349 | if (asset == null) | 349 | { |
350 | { | 350 | asset = m_userTransactions.GetTransactionAsset(transactionID); |
351 | asset = m_userTransactions.GetTransactionAsset(transactionID); | 351 | } |
352 | } | 352 | |
353 | 353 | if (asset != null && asset.FullID == assetID) | |
354 | if (asset != null && asset.FullID == assetID) | 354 | { |
355 | { | 355 | asset.Name = item.Name; |
356 | asset.Name = item.Name; | 356 | asset.Description = item.Description; |
357 | asset.Description = item.Description; | 357 | asset.InvType = (sbyte) item.InvType; |
358 | asset.InvType = (sbyte) item.InvType; | 358 | asset.Type = (sbyte) item.AssetType; |
359 | asset.Type = (sbyte) item.AssetType; | 359 | item.AssetID = asset.FullID; |
360 | item.AssetID = asset.FullID; | 360 | |
361 | 361 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); | |
362 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); | 362 | } |
363 | } | 363 | |
364 | 364 | userInfo.UpdateItem(remoteClient.AgentId, item); | |
365 | userInfo.UpdateItem(remoteClient.AgentId, item); | 365 | } |
366 | } | 366 | } |
367 | } | 367 | } |
368 | } | 368 | |
369 | 369 | private void DoCreateItem() | |
370 | private void DoCreateItem() | 370 | { |
371 | { | 371 | //really need to fix this call, if lbsa71 saw this he would die. |
372 | //really need to fix this call, if lbsa71 saw this he would die. | 372 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); |
373 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); | 373 | CachedUserInfo userInfo = |
374 | CachedUserInfo userInfo = | 374 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId); |
375 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId); | 375 | if (userInfo != null) |
376 | if (userInfo != null) | 376 | { |
377 | { | 377 | InventoryItemBase item = new InventoryItemBase(); |
378 | InventoryItemBase item = new InventoryItemBase(); | 378 | item.Owner = ourClient.AgentId; |
379 | item.Owner = ourClient.AgentId; | 379 | item.Creator = ourClient.AgentId; |
380 | item.Creator = ourClient.AgentId; | 380 | item.ID = LLUUID.Random(); |
381 | item.ID = LLUUID.Random(); | 381 | item.AssetID = Asset.FullID; |
382 | item.AssetID = Asset.FullID; | 382 | item.Description = m_description; |
383 | item.Description = m_description; | 383 | item.Name = m_name; |
384 | item.Name = m_name; | 384 | item.AssetType = type; |
385 | item.AssetType = type; | 385 | item.InvType = invType; |
386 | item.InvType = invType; | 386 | item.Folder = InventFolder; |
387 | item.Folder = InventFolder; | 387 | item.BasePermissions = 2147483647; |
388 | item.BasePermissions = 2147483647; | 388 | item.CurrentPermissions = 2147483647; |
389 | item.CurrentPermissions = 2147483647; | 389 | item.NextPermissions = nextPerm; |
390 | item.NextPermissions = nextPerm; | 390 | item.Flags = (uint)wearableType; |
391 | item.Flags = (uint)wearableType; | 391 | |
392 | 392 | userInfo.AddItem(ourClient.AgentId, item); | |
393 | userInfo.AddItem(ourClient.AgentId, item); | 393 | ourClient.SendInventoryItemCreateUpdate(item); |
394 | ourClient.SendInventoryItemCreateUpdate(item); | 394 | } |
395 | } | 395 | } |
396 | } | 396 | |
397 | 397 | public AssetBase GetAssetData() | |
398 | public AssetBase GetAssetData() | 398 | { |
399 | { | 399 | if (m_finished) |
400 | if (m_finished) | 400 | { |
401 | { | 401 | return Asset; |
402 | return Asset; | 402 | } |
403 | } | 403 | return null; |
404 | return null; | 404 | } |
405 | } | 405 | } |
406 | } | 406 | } |
407 | } | 407 | } \ No newline at end of file |
408 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs index cec7192..ef81625 100644 --- a/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -1,286 +1,286 @@ | |||
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using log4net; | 32 | using log4net; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Environment.Interfaces; | 35 | using OpenSim.Region.Environment.Interfaces; |
36 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Modules.Agent.AssetTransaction; |
37 | 37 | using OpenSim.Region.Environment.Scenes; | |
38 | namespace OpenSim.Region.Environment.Modules | 38 | |
39 | { | 39 | namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction |
40 | public class AgentAssetTransactionModule : IRegionModule, IAgentAssetTransactions | 40 | { |
41 | { | 41 | public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions |
42 | private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); | 42 | { |
43 | private Scene m_scene = null; | 43 | private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); |
44 | private bool m_dumpAssetsToFile = false; | 44 | private Scene m_scene = null; |
45 | 45 | private bool m_dumpAssetsToFile = false; | |
46 | private AgentAssetTransactionsManager m_transactionManager; | 46 | |
47 | 47 | private AgentAssetTransactionsManager m_transactionManager; | |
48 | public AgentAssetTransactionModule() | 48 | |
49 | { | 49 | public AssetTransactionModule() |
50 | // System.Console.WriteLine("creating AgentAssetTransactionModule"); | 50 | { |
51 | } | 51 | // System.Console.WriteLine("creating AgentAssetTransactionModule"); |
52 | 52 | } | |
53 | public void Initialise(Scene scene, IConfigSource config) | 53 | |
54 | { | 54 | public void Initialise(Scene scene, IConfigSource config) |
55 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 55 | { |
56 | { | 56 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
57 | // System.Console.WriteLine("initialising AgentAssetTransactionModule"); | 57 | { |
58 | RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); | 58 | // System.Console.WriteLine("initialising AgentAssetTransactionModule"); |
59 | scene.RegisterModuleInterface<IAgentAssetTransactions>(this); | 59 | RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); |
60 | 60 | scene.RegisterModuleInterface<IAgentAssetTransactions>(this); | |
61 | scene.EventManager.OnNewClient += NewClient; | 61 | |
62 | } | 62 | scene.EventManager.OnNewClient += NewClient; |
63 | 63 | } | |
64 | if (m_scene == null) | 64 | |
65 | { | 65 | if (m_scene == null) |
66 | m_scene = scene; | 66 | { |
67 | if (config.Configs["StandAlone"] != null) | 67 | m_scene = scene; |
68 | { | 68 | if (config.Configs["StandAlone"] != null) |
69 | try | 69 | { |
70 | { | 70 | try |
71 | m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false); | 71 | { |
72 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, m_dumpAssetsToFile); | 72 | m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false); |
73 | } | 73 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, m_dumpAssetsToFile); |
74 | catch (Exception) | 74 | } |
75 | { | 75 | catch (Exception) |
76 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); | 76 | { |
77 | } | 77 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); |
78 | } | 78 | } |
79 | else | 79 | } |
80 | { | 80 | else |
81 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); | 81 | { |
82 | } | 82 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); |
83 | 83 | } | |
84 | } | 84 | |
85 | } | 85 | } |
86 | 86 | } | |
87 | public void PostInitialise() | 87 | |
88 | { | 88 | public void PostInitialise() |
89 | 89 | { | |
90 | } | 90 | |
91 | 91 | } | |
92 | public void Close() | 92 | |
93 | { | 93 | public void Close() |
94 | } | 94 | { |
95 | 95 | } | |
96 | public string Name | 96 | |
97 | { | 97 | public string Name |
98 | get { return "AgentTransactionModule"; } | 98 | { |
99 | } | 99 | get { return "AgentTransactionModule"; } |
100 | 100 | } | |
101 | public bool IsSharedModule | 101 | |
102 | { | 102 | public bool IsSharedModule |
103 | get { return true; } | 103 | { |
104 | } | 104 | get { return true; } |
105 | 105 | } | |
106 | public void NewClient(IClientAPI client) | 106 | |
107 | { | 107 | public void NewClient(IClientAPI client) |
108 | client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; | 108 | { |
109 | client.OnXferReceive += m_transactionManager.HandleXfer; | 109 | client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; |
110 | } | 110 | client.OnXferReceive += m_transactionManager.HandleXfer; |
111 | 111 | } | |
112 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | 112 | |
113 | uint callbackID, string description, string name, sbyte invType, | 113 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, |
114 | sbyte type, byte wearableType, uint nextOwnerMask) | 114 | uint callbackID, string description, string name, sbyte invType, |
115 | { | 115 | sbyte type, byte wearableType, uint nextOwnerMask) |
116 | m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); | 116 | { |
117 | } | 117 | m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); |
118 | 118 | } | |
119 | public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, | 119 | |
120 | InventoryItemBase item) | 120 | public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, |
121 | { | 121 | InventoryItemBase item) |
122 | m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); | 122 | { |
123 | } | 123 | m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); |
124 | 124 | } | |
125 | public void RemoveAgentAssetTransactions(LLUUID userID) | 125 | |
126 | { | 126 | public void RemoveAgentAssetTransactions(LLUUID userID) |
127 | m_transactionManager.RemoveAgentAssetTransactions(userID); | 127 | { |
128 | } | 128 | m_transactionManager.RemoveAgentAssetTransactions(userID); |
129 | } | 129 | } |
130 | 130 | } | |
131 | //should merge this classes and clean up | 131 | |
132 | public class AgentAssetTransactionsManager | 132 | public class AgentAssetTransactionsManager |
133 | { | 133 | { |
134 | private static readonly ILog m_log | 134 | private static readonly ILog m_log |
135 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 135 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
136 | 136 | ||
137 | // Fields | 137 | // Fields |
138 | public Scene MyScene; | 138 | public Scene MyScene; |
139 | 139 | ||
140 | /// <summary> | 140 | /// <summary> |
141 | /// Each agent has its own singleton collection of transactions | 141 | /// Each agent has its own singleton collection of transactions |
142 | /// </summary> | 142 | /// </summary> |
143 | private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = | 143 | private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = |
144 | new Dictionary<LLUUID, AgentAssetTransactions>(); | 144 | new Dictionary<LLUUID, AgentAssetTransactions>(); |
145 | 145 | ||
146 | /// <summary> | 146 | /// <summary> |
147 | /// Should we dump uploaded assets to the filesystem? | 147 | /// Should we dump uploaded assets to the filesystem? |
148 | /// </summary> | 148 | /// </summary> |
149 | private bool m_dumpAssetsToFile; | 149 | private bool m_dumpAssetsToFile; |
150 | 150 | ||
151 | public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile) | 151 | public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile) |
152 | { | 152 | { |
153 | MyScene = scene; | 153 | MyScene = scene; |
154 | m_dumpAssetsToFile = dumpAssetsToFile; | 154 | m_dumpAssetsToFile = dumpAssetsToFile; |
155 | } | 155 | } |
156 | 156 | ||
157 | /// <summary> | 157 | /// <summary> |
158 | /// Get the collection of asset transactions for the given user. If one does not already exist, it | 158 | /// Get the collection of asset transactions for the given user. If one does not already exist, it |
159 | /// is created. | 159 | /// is created. |
160 | /// </summary> | 160 | /// </summary> |
161 | /// <param name="userID"></param> | 161 | /// <param name="userID"></param> |
162 | /// <returns></returns> | 162 | /// <returns></returns> |
163 | private AgentAssetTransactions GetUserTransactions(LLUUID userID) | 163 | private AgentAssetTransactions GetUserTransactions(LLUUID userID) |
164 | { | 164 | { |
165 | lock (AgentTransactions) | 165 | lock (AgentTransactions) |
166 | { | 166 | { |
167 | if (!AgentTransactions.ContainsKey(userID)) | 167 | if (!AgentTransactions.ContainsKey(userID)) |
168 | { | 168 | { |
169 | AgentAssetTransactions transactions | 169 | AgentAssetTransactions transactions |
170 | = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); | 170 | = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); |
171 | AgentTransactions.Add(userID, transactions); | 171 | AgentTransactions.Add(userID, transactions); |
172 | } | 172 | } |
173 | 173 | ||
174 | return AgentTransactions[userID]; | 174 | return AgentTransactions[userID]; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | /// <summary> | 178 | /// <summary> |
179 | /// Remove the given agent asset transactions. This should be called when a client is departing | 179 | /// Remove the given agent asset transactions. This should be called when a client is departing |
180 | /// from a scene (and hence won't be making any more transactions here). | 180 | /// from a scene (and hence won't be making any more transactions here). |
181 | /// </summary> | 181 | /// </summary> |
182 | /// <param name="userID"></param> | 182 | /// <param name="userID"></param> |
183 | public void RemoveAgentAssetTransactions(LLUUID userID) | 183 | public void RemoveAgentAssetTransactions(LLUUID userID) |
184 | { | 184 | { |
185 | // m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID); | 185 | // m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID); |
186 | 186 | ||
187 | lock (AgentTransactions) | 187 | lock (AgentTransactions) |
188 | { | 188 | { |
189 | AgentTransactions.Remove(userID); | 189 | AgentTransactions.Remove(userID); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | /// <summary> | 193 | /// <summary> |
194 | /// Create an inventory item from data that has been received through a transaction. | 194 | /// Create an inventory item from data that has been received through a transaction. |
195 | /// | 195 | /// |
196 | /// This is called when new clothing or body parts are created. It may also be called in other | 196 | /// This is called when new clothing or body parts are created. It may also be called in other |
197 | /// situations. | 197 | /// situations. |
198 | /// </summary> | 198 | /// </summary> |
199 | /// <param name="remoteClient"></param> | 199 | /// <param name="remoteClient"></param> |
200 | /// <param name="transactionID"></param> | 200 | /// <param name="transactionID"></param> |
201 | /// <param name="folderID"></param> | 201 | /// <param name="folderID"></param> |
202 | /// <param name="callbackID"></param> | 202 | /// <param name="callbackID"></param> |
203 | /// <param name="description"></param> | 203 | /// <param name="description"></param> |
204 | /// <param name="name"></param> | 204 | /// <param name="name"></param> |
205 | /// <param name="invType"></param> | 205 | /// <param name="invType"></param> |
206 | /// <param name="type"></param> | 206 | /// <param name="type"></param> |
207 | /// <param name="wearableType"></param> | 207 | /// <param name="wearableType"></param> |
208 | /// <param name="nextOwnerMask"></param> | 208 | /// <param name="nextOwnerMask"></param> |
209 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | 209 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, |
210 | uint callbackID, string description, string name, sbyte invType, | 210 | uint callbackID, string description, string name, sbyte invType, |
211 | sbyte type, byte wearableType, uint nextOwnerMask) | 211 | sbyte type, byte wearableType, uint nextOwnerMask) |
212 | { | 212 | { |
213 | m_log.DebugFormat( | 213 | m_log.DebugFormat( |
214 | "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); | 214 | "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); |
215 | 215 | ||
216 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); | 216 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); |
217 | 217 | ||
218 | transactions.RequestCreateInventoryItem( | 218 | transactions.RequestCreateInventoryItem( |
219 | remoteClient, transactionID, folderID, callbackID, description, | 219 | remoteClient, transactionID, folderID, callbackID, description, |
220 | name, invType, type, wearableType, nextOwnerMask); | 220 | name, invType, type, wearableType, nextOwnerMask); |
221 | } | 221 | } |
222 | 222 | ||
223 | /// <summary> | 223 | /// <summary> |
224 | /// Update an inventory item with data that has been received through a transaction. | 224 | /// Update an inventory item with data that has been received through a transaction. |
225 | /// | 225 | /// |
226 | /// This is called when clothing or body parts are updated (for instance, with new textures or | 226 | /// This is called when clothing or body parts are updated (for instance, with new textures or |
227 | /// colours). It may also be called in other situations. | 227 | /// colours). It may also be called in other situations. |
228 | /// </summary> | 228 | /// </summary> |
229 | /// <param name="remoteClient"></param> | 229 | /// <param name="remoteClient"></param> |
230 | /// <param name="transactionID"></param> | 230 | /// <param name="transactionID"></param> |
231 | /// <param name="item"></param> | 231 | /// <param name="item"></param> |
232 | public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, | 232 | public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, |
233 | InventoryItemBase item) | 233 | InventoryItemBase item) |
234 | { | 234 | { |
235 | m_log.DebugFormat( | 235 | m_log.DebugFormat( |
236 | "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", | 236 | "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", |
237 | item.Name); | 237 | item.Name); |
238 | 238 | ||
239 | AgentAssetTransactions transactions | 239 | AgentAssetTransactions transactions |
240 | = GetUserTransactions(remoteClient.AgentId); | 240 | = GetUserTransactions(remoteClient.AgentId); |
241 | 241 | ||
242 | transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); | 242 | transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); |
243 | } | 243 | } |
244 | 244 | ||
245 | /// <summary> | 245 | /// <summary> |
246 | /// Request that a client (agent) begin an asset transfer. | 246 | /// Request that a client (agent) begin an asset transfer. |
247 | /// </summary> | 247 | /// </summary> |
248 | /// <param name="remoteClient"></param> | 248 | /// <param name="remoteClient"></param> |
249 | /// <param name="assetID"></param> | 249 | /// <param name="assetID"></param> |
250 | /// <param name="transaction"></param> | 250 | /// <param name="transaction"></param> |
251 | /// <param name="type"></param> | 251 | /// <param name="type"></param> |
252 | /// <param name="data"></param></param> | 252 | /// <param name="data"></param></param> |
253 | /// <param name="tempFile"></param> | 253 | /// <param name="tempFile"></param> |
254 | public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, | 254 | public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, |
255 | byte[] data, bool storeLocal, bool tempFile) | 255 | byte[] data, bool storeLocal, bool tempFile) |
256 | { | 256 | { |
257 | // Console.WriteLine("asset upload of " + assetID); | 257 | // Console.WriteLine("asset upload of " + assetID); |
258 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); | 258 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); |
259 | 259 | ||
260 | AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); | 260 | AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); |
261 | if (uploader != null) | 261 | if (uploader != null) |
262 | { | 262 | { |
263 | 263 | ||
264 | if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) | 264 | if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) |
265 | { | 265 | { |
266 | 266 | ||
267 | } | 267 | } |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | /// <summary> | 271 | /// <summary> |
272 | /// Handle asset transfer data packets received in response to the asset upload request in | 272 | /// Handle asset transfer data packets received in response to the asset upload request in |
273 | /// HandleUDPUploadRequest() | 273 | /// HandleUDPUploadRequest() |
274 | /// </summary> | 274 | /// </summary> |
275 | /// <param name="remoteClient"></param> | 275 | /// <param name="remoteClient"></param> |
276 | /// <param name="xferID"></param> | 276 | /// <param name="xferID"></param> |
277 | /// <param name="packetID"></param> | 277 | /// <param name="packetID"></param> |
278 | /// <param name="data"></param> | 278 | /// <param name="data"></param> |
279 | public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) | 279 | public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) |
280 | { | 280 | { |
281 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); | 281 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); |
282 | 282 | ||
283 | transactions.HandleXfer(xferID, packetID, data); | 283 | transactions.HandleXfer(xferID, packetID, data); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } \ No newline at end of file |