aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-02-12 18:15:54 +0000
committerJustin Clarke Casey2008-02-12 18:15:54 +0000
commit6a3455a98cb3b7c910dd2d8d09f69d1c3acf7d2d (patch)
treefc05f0a0f1bc94ff4330358aab81f4c49fbdb0f6 /OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs
parent* This fixes the object edit box's flipping checkboxes when you modify one of... (diff)
downloadopensim-SC_OLD-6a3455a98cb3b7c910dd2d8d09f69d1c3acf7d2d.zip
opensim-SC_OLD-6a3455a98cb3b7c910dd2d8d09f69d1c3acf7d2d.tar.gz
opensim-SC_OLD-6a3455a98cb3b7c910dd2d8d09f69d1c3acf7d2d.tar.bz2
opensim-SC_OLD-6a3455a98cb3b7c910dd2d8d09f69d1c3acf7d2d.tar.xz
* Refactoring: Rename AssetTransactions.cs and AssetTransactionsManager and align classes with file names
* Small amount of ndoc * This will probably require a prebuild and nant clean
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs143
1 files changed, 143 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs
new file mode 100644
index 0000000..70471cc
--- /dev/null
+++ b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs
@@ -0,0 +1,143 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.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
29using System;
30using System.Collections.Generic;
31
32using libsecondlife;
33
34namespace OpenSim.Framework.Communications.Cache
35{
36 /// <summary>
37 /// Manage the collection of agent asset transaction collections. Each agent has its own transaction collection
38 /// </summary>
39 public class AgentAssetTransactionsManager
40 {
41 private static readonly log4net.ILog m_log
42 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
43
44 // Fields
45 public CommunicationsManager CommsManager;
46
47 /// <summary>
48 /// Each agent has its own singleton collection of transactions
49 /// </summary>
50 private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
51 new Dictionary<LLUUID, AgentAssetTransactions>();
52
53 /// <summary>
54 /// Should we dump uploaded assets to the filesystem?
55 /// </summary>
56 private bool m_dumpAssetsToFile;
57
58 public AgentAssetTransactionsManager(CommunicationsManager commsManager, bool dumpAssetsToFile)
59 {
60 CommsManager = commsManager;
61 m_dumpAssetsToFile = dumpAssetsToFile;
62 }
63
64 /// <summary>
65 /// Add a collection of asset transactions for the given user
66 /// </summary>
67 /// <param name="userID"></param>
68 public void AddUser(LLUUID userID)
69 {
70 lock (AgentTransactions)
71 {
72 if (!AgentTransactions.ContainsKey(userID))
73 {
74 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
75 AgentTransactions.Add(userID, transactions);
76 }
77 }
78 }
79
80 /// <summary>
81 /// Get the collection of asset transactions for the given user.
82 /// </summary>
83 /// <param name="userID"></param>
84 /// <returns></returns>
85 public AgentAssetTransactions GetUserTransactions(LLUUID userID)
86 {
87 if (AgentTransactions.ContainsKey(userID))
88 {
89 return AgentTransactions[userID];
90 }
91 return null;
92 }
93
94 public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
95 uint callbackID, string description, string name, sbyte invType,
96 sbyte type, byte wearableType, uint nextOwnerMask)
97 {
98 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
99 if (transactions != null)
100 {
101 transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description,
102 name, invType, type, wearableType, nextOwnerMask);
103 }
104 }
105
106 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
107 byte[] data, bool storeLocal, bool tempFile)
108 {
109 // Console.WriteLine("asset upload of " + assetID);
110 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
111 if (transactions != null)
112 {
113 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
114 if (uploader != null)
115 {
116 // Upload has already compelted uploading...
117
118 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
119 {
120 //[commenting out as this removal breaks uploads]
121 /*lock (transactions.XferUploaders)
122 {
123
124 // XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary
125 transactions.XferUploaders.Remove(uploader.TransactionID);
126
127 //m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count);
128 }*/
129 }
130 }
131 }
132 }
133
134 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
135 {
136 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
137 if (transactions != null)
138 {
139 transactions.HandleXfer(xferID, packetID, data);
140 }
141 }
142 }
143}