aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs
diff options
context:
space:
mode:
authorMW2008-02-16 13:13:40 +0000
committerMW2008-02-16 13:13:40 +0000
commit5cc0bbd4196b9467645189c251b1fc63867ca9a8 (patch)
treeca11d6d11aa72a0df26f4cd2930b2c47bb846c29 /OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs
parentMoved the AgentAssetTransactionsManager (and AgentAssetTransactions) out of C... (diff)
downloadopensim-SC_OLD-5cc0bbd4196b9467645189c251b1fc63867ca9a8.zip
opensim-SC_OLD-5cc0bbd4196b9467645189c251b1fc63867ca9a8.tar.gz
opensim-SC_OLD-5cc0bbd4196b9467645189c251b1fc63867ca9a8.tar.bz2
opensim-SC_OLD-5cc0bbd4196b9467645189c251b1fc63867ca9a8.tar.xz
Renamed AgentAgentTransactionModule to the correct name of AgentAssetTransactionModule
Diffstat (limited to 'OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs244
1 files changed, 244 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs
new file mode 100644
index 0000000..f19ba32
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs
@@ -0,0 +1,244 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using Nini.Config;
6using OpenSim.Framework;
7using OpenSim.Region.Environment.Interfaces;
8using OpenSim.Region.Environment.Scenes;
9
10namespace OpenSim.Region.Environment.Modules
11{
12 public class AgentAssetTransactionModule : IRegionModule, IAgentAssetTransactions
13 {
14 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
15 private Scene m_scene = null;
16 private bool m_dumpAssetsToFile = false;
17
18 private AgentAssetTransactionsManager m_transactionManager;
19
20 public void Initialise(Scene scene, IConfigSource config)
21 {
22 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
23 {
24 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
25 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
26
27 scene.EventManager.OnNewClient += NewClient;
28
29 try
30 {
31 m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false);
32 }
33 catch (Exception)
34 {
35 }
36 }
37
38 if (m_scene == null)
39 {
40 m_scene = scene;
41 m_transactionManager = new AgentAssetTransactionsManager(m_scene, m_dumpAssetsToFile);
42 }
43 }
44
45 public void PostInitialise()
46 {
47
48 }
49
50 public void Close()
51 {
52 }
53
54 public string Name
55 {
56 get { return "AgentTransactionModule"; }
57 }
58
59 public bool IsSharedModule
60 {
61 get { return true; }
62 }
63
64 public void NewClient(IClientAPI client)
65 {
66 client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest;
67 client.OnXferReceive += m_transactionManager.HandleXfer;
68 }
69
70 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
71 uint callbackID, string description, string name, sbyte invType,
72 sbyte type, byte wearableType, uint nextOwnerMask)
73 {
74 m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
75 }
76
77 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
78 InventoryItemBase item)
79 {
80 m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
81 }
82
83 public void RemoveAgentAssetTransactions(LLUUID userID)
84 {
85 m_transactionManager.RemoveAgentAssetTransactions(userID);
86 }
87 }
88
89 //should merge this classes and clean up
90 public class AgentAssetTransactionsManager
91 {
92 private static readonly log4net.ILog m_log
93 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
94
95 // Fields
96 public Scene MyScene;
97
98 /// <summary>
99 /// Each agent has its own singleton collection of transactions
100 /// </summary>
101 private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
102 new Dictionary<LLUUID, AgentAssetTransactions>();
103
104 /// <summary>
105 /// Should we dump uploaded assets to the filesystem?
106 /// </summary>
107 private bool m_dumpAssetsToFile;
108
109 public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile)
110 {
111 MyScene = scene;
112 m_dumpAssetsToFile = dumpAssetsToFile;
113 }
114
115 /// <summary>
116 /// Get the collection of asset transactions for the given user. If one does not already exist, it
117 /// is created.
118 /// </summary>
119 /// <param name="userID"></param>
120 /// <returns></returns>
121 private AgentAssetTransactions GetUserTransactions(LLUUID userID)
122 {
123 lock (AgentTransactions)
124 {
125 if (!AgentTransactions.ContainsKey(userID))
126 {
127 AgentAssetTransactions transactions
128 = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
129 AgentTransactions.Add(userID, transactions);
130 }
131
132 return AgentTransactions[userID];
133 }
134 }
135
136 /// <summary>
137 /// Remove the given agent asset transactions. This should be called when a client is departing
138 /// from a scene (and hence won't be making any more transactions here).
139 /// </summary>
140 /// <param name="userID"></param>
141 public void RemoveAgentAssetTransactions(LLUUID userID)
142 {
143 // m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID);
144
145 lock (AgentTransactions)
146 {
147 AgentTransactions.Remove(userID);
148 }
149 }
150
151 /// <summary>
152 /// Create an inventory item from data that has been received through a transaction.
153 ///
154 /// This is called when new clothing or body parts are created. It may also be called in other
155 /// situations.
156 /// </summary>
157 /// <param name="remoteClient"></param>
158 /// <param name="transactionID"></param>
159 /// <param name="folderID"></param>
160 /// <param name="callbackID"></param>
161 /// <param name="description"></param>
162 /// <param name="name"></param>
163 /// <param name="invType"></param>
164 /// <param name="type"></param>
165 /// <param name="wearableType"></param>
166 /// <param name="nextOwnerMask"></param>
167 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
168 uint callbackID, string description, string name, sbyte invType,
169 sbyte type, byte wearableType, uint nextOwnerMask)
170 {
171 m_log.DebugFormat(
172 "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
173
174 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
175
176 transactions.RequestCreateInventoryItem(
177 remoteClient, transactionID, folderID, callbackID, description,
178 name, invType, type, wearableType, nextOwnerMask);
179 }
180
181 /// <summary>
182 /// Update an inventory item with data that has been received through a transaction.
183 ///
184 /// This is called when clothing or body parts are updated (for instance, with new textures or
185 /// colours). It may also be called in other situations.
186 /// </summary>
187 /// <param name="remoteClient"></param>
188 /// <param name="transactionID"></param>
189 /// <param name="item"></param>
190 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
191 InventoryItemBase item)
192 {
193 m_log.DebugFormat(
194 "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
195 item.inventoryName);
196
197 AgentAssetTransactions transactions
198 = GetUserTransactions(remoteClient.AgentId);
199
200 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
201 }
202
203 /// <summary>
204 /// Request that a client (agent) begin an asset transfer.
205 /// </summary>
206 /// <param name="remoteClient"></param>
207 /// <param name="assetID"></param>
208 /// <param name="transaction"></param>
209 /// <param name="type"></param>
210 /// <param name="data"></param></param>
211 /// <param name="tempFile"></param>
212 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
213 byte[] data, bool storeLocal, bool tempFile)
214 {
215 // Console.WriteLine("asset upload of " + assetID);
216 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
217
218 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
219 if (uploader != null)
220 {
221
222 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
223 {
224
225 }
226 }
227 }
228
229 /// <summary>
230 /// Handle asset transfer data packets received in response to the asset upload request in
231 /// HandleUDPUploadRequest()
232 /// </summary>
233 /// <param name="remoteClient"></param>
234 /// <param name="xferID"></param>
235 /// <param name="packetID"></param>
236 /// <param name="data"></param>
237 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
238 {
239 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
240
241 transactions.HandleXfer(xferID, packetID, data);
242 }
243 }
244}