aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs192
1 files changed, 0 insertions, 192 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
index 56ca1a1..09c9aef 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -27,9 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
31using OpenMetaverse; 30using OpenMetaverse;
32using log4net;
33using Nini.Config; 31using Nini.Config;
34using OpenSim.Framework; 32using OpenSim.Framework;
35using OpenSim.Region.Interfaces; 33using OpenSim.Region.Interfaces;
@@ -140,194 +138,4 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
140 client.OnXferReceive += m_transactionManager.HandleXfer; 138 client.OnXferReceive += m_transactionManager.HandleXfer;
141 } 139 }
142 } 140 }
143
144 public class AgentAssetTransactionsManager
145 {
146 private static readonly ILog m_log
147 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
148
149 /// <summary>
150 /// Each agent has its own singleton collection of transactions
151 /// </summary>
152 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions =
153 new Dictionary<UUID, AgentAssetTransactions>();
154
155 /// <summary>
156 /// Should we dump uploaded assets to the filesystem?
157 /// </summary>
158 private bool m_dumpAssetsToFile;
159
160 public Scene MyScene;
161
162 public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile)
163 {
164 MyScene = scene;
165 m_dumpAssetsToFile = dumpAssetsToFile;
166 }
167
168 /// <summary>
169 /// Get the collection of asset transactions for the given user. If one does not already exist, it
170 /// is created.
171 /// </summary>
172 /// <param name="userID"></param>
173 /// <returns></returns>
174 private AgentAssetTransactions GetUserTransactions(UUID userID)
175 {
176 lock (AgentTransactions)
177 {
178 if (!AgentTransactions.ContainsKey(userID))
179 {
180 AgentAssetTransactions transactions
181 = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
182 AgentTransactions.Add(userID, transactions);
183 }
184
185 return AgentTransactions[userID];
186 }
187 }
188
189 /// <summary>
190 /// Remove the given agent asset transactions. This should be called when a client is departing
191 /// from a scene (and hence won't be making any more transactions here).
192 /// </summary>
193 /// <param name="userID"></param>
194 public void RemoveAgentAssetTransactions(UUID userID)
195 {
196 // m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID);
197
198 lock (AgentTransactions)
199 {
200 AgentTransactions.Remove(userID);
201 }
202 }
203
204 /// <summary>
205 /// Create an inventory item from data that has been received through a transaction.
206 ///
207 /// This is called when new clothing or body parts are created. It may also be called in other
208 /// situations.
209 /// </summary>
210 /// <param name="remoteClient"></param>
211 /// <param name="transactionID"></param>
212 /// <param name="folderID"></param>
213 /// <param name="callbackID"></param>
214 /// <param name="description"></param>
215 /// <param name="name"></param>
216 /// <param name="invType"></param>
217 /// <param name="type"></param>
218 /// <param name="wearableType"></param>
219 /// <param name="nextOwnerMask"></param>
220 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID,
221 uint callbackID, string description, string name, sbyte invType,
222 sbyte type, byte wearableType, uint nextOwnerMask)
223 {
224// m_log.DebugFormat(
225// "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
226
227 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
228
229 transactions.RequestCreateInventoryItem(
230 remoteClient, transactionID, folderID, callbackID, description,
231 name, invType, type, wearableType, nextOwnerMask);
232 }
233
234 /// <summary>
235 /// Update an inventory item with data that has been received through a transaction.
236 ///
237 /// This is called when clothing or body parts are updated (for instance, with new textures or
238 /// colours). It may also be called in other situations.
239 /// </summary>
240 /// <param name="remoteClient"></param>
241 /// <param name="transactionID"></param>
242 /// <param name="item"></param>
243 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID,
244 InventoryItemBase item)
245 {
246// m_log.DebugFormat(
247// "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
248// item.Name);
249
250 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
251
252 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
253 }
254
255 /// <summary>
256 /// Update a task inventory item with data that has been received through a transaction.
257 ///
258 /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent
259 /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction
260 /// and comes through this method.
261 /// </summary>
262 /// <param name="remoteClient"></param>
263 /// <param name="transactionID"></param>
264 /// <param name="item"></param>
265 public void HandleTaskItemUpdateFromTransaction(
266 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
267 {
268// m_log.DebugFormat(
269// "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}",
270// item.Name);
271
272 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
273
274 transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
275 }
276
277 /// <summary>
278 /// Request that a client (agent) begin an asset transfer.
279 /// </summary>
280 /// <param name="remoteClient"></param>
281 /// <param name="assetID"></param>
282 /// <param name="transaction"></param>
283 /// <param name="type"></param>
284 /// <param name="data"></param></param>
285 /// <param name="tempFile"></param>
286 public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type,
287 byte[] data, bool storeLocal, bool tempFile)
288 {
289 if (((AssetType)type == AssetType.Texture ||
290 (AssetType)type == AssetType.Sound ||
291 (AssetType)type == AssetType.TextureTGA ||
292 (AssetType)type == AssetType.Animation) &&
293 tempFile == false)
294 {
295 Scene scene = (Scene)remoteClient.Scene;
296 IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
297
298 if (mm != null)
299 {
300 if (!mm.UploadCovered(remoteClient))
301 {
302 remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
303 return;
304 }
305 }
306 }
307
308 //Console.WriteLine("asset upload of " + assetID);
309 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
310
311 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
312 if (uploader != null)
313 {
314 uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
315 }
316 }
317
318 /// <summary>
319 /// Handle asset transfer data packets received in response to the asset upload request in
320 /// HandleUDPUploadRequest()
321 /// </summary>
322 /// <param name="remoteClient"></param>
323 /// <param name="xferID"></param>
324 /// <param name="packetID"></param>
325 /// <param name="data"></param>
326 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
327 {
328 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
329
330 transactions.HandleXfer(xferID, packetID, data);
331 }
332 }
333} 141}