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.cs580
1 files changed, 290 insertions, 290 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
index b264c8a..fcd0e0c 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -1,291 +1,291 @@
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
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using libsecondlife; 31using libsecondlife;
32using log4net; 32using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37 37
38namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction 38namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
39{ 39{
40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions 40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions
41 { 41 {
42 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 42 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
43 private bool m_dumpAssetsToFile = false; 43 private bool m_dumpAssetsToFile = false;
44 private Scene m_scene = null; 44 private Scene m_scene = null;
45 45
46 private AgentAssetTransactionsManager m_transactionManager; 46 private AgentAssetTransactionsManager m_transactionManager;
47 47
48 public AssetTransactionModule() 48 public AssetTransactionModule()
49 { 49 {
50 // System.Console.WriteLine("creating AgentAssetTransactionModule"); 50 // System.Console.WriteLine("creating AgentAssetTransactionModule");
51 } 51 }
52 52
53 #region IAgentAssetTransactions Members 53 #region IAgentAssetTransactions Members
54 54
55 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, 55 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
56 uint callbackID, string description, string name, sbyte invType, 56 uint callbackID, string description, string name, sbyte invType,
57 sbyte type, byte wearableType, uint nextOwnerMask) 57 sbyte type, byte wearableType, uint nextOwnerMask)
58 { 58 {
59 m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, 59 m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type,
60 wearableType, nextOwnerMask); 60 wearableType, nextOwnerMask);
61 } 61 }
62 62
63 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, 63 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
64 InventoryItemBase item) 64 InventoryItemBase item)
65 { 65 {
66 m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); 66 m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
67 } 67 }
68 68
69 public void RemoveAgentAssetTransactions(LLUUID userID) 69 public void RemoveAgentAssetTransactions(LLUUID userID)
70 { 70 {
71 m_transactionManager.RemoveAgentAssetTransactions(userID); 71 m_transactionManager.RemoveAgentAssetTransactions(userID);
72 } 72 }
73 73
74 #endregion 74 #endregion
75 75
76 #region IRegionModule Members 76 #region IRegionModule Members
77 77
78 public void Initialise(Scene scene, IConfigSource config) 78 public void Initialise(Scene scene, IConfigSource config)
79 { 79 {
80 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 80 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
81 { 81 {
82 // System.Console.WriteLine("initialising AgentAssetTransactionModule"); 82 // System.Console.WriteLine("initialising AgentAssetTransactionModule");
83 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); 83 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
84 scene.RegisterModuleInterface<IAgentAssetTransactions>(this); 84 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
85 85
86 scene.EventManager.OnNewClient += NewClient; 86 scene.EventManager.OnNewClient += NewClient;
87 } 87 }
88 88
89 if (m_scene == null) 89 if (m_scene == null)
90 { 90 {
91 m_scene = scene; 91 m_scene = scene;
92 if (config.Configs["StandAlone"] != null) 92 if (config.Configs["StandAlone"] != null)
93 { 93 {
94 try 94 try
95 { 95 {
96 m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false); 96 m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false);
97 m_transactionManager = new AgentAssetTransactionsManager(m_scene, m_dumpAssetsToFile); 97 m_transactionManager = new AgentAssetTransactionsManager(m_scene, m_dumpAssetsToFile);
98 } 98 }
99 catch (Exception) 99 catch (Exception)
100 { 100 {
101 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); 101 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false);
102 } 102 }
103 } 103 }
104 else 104 else
105 { 105 {
106 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); 106 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false);
107 } 107 }
108 } 108 }
109 } 109 }
110 110
111 public void PostInitialise() 111 public void PostInitialise()
112 { 112 {
113 } 113 }
114 114
115 public void Close() 115 public void Close()
116 { 116 {
117 } 117 }
118 118
119 public string Name 119 public string Name
120 { 120 {
121 get { return "AgentTransactionModule"; } 121 get { return "AgentTransactionModule"; }
122 } 122 }
123 123
124 public bool IsSharedModule 124 public bool IsSharedModule
125 { 125 {
126 get { return true; } 126 get { return true; }
127 } 127 }
128 128
129 #endregion 129 #endregion
130 130
131 public void NewClient(IClientAPI client) 131 public void NewClient(IClientAPI client)
132 { 132 {
133 client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; 133 client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest;
134 client.OnXferReceive += m_transactionManager.HandleXfer; 134 client.OnXferReceive += m_transactionManager.HandleXfer;
135 } 135 }
136 } 136 }
137 137
138 public class AgentAssetTransactionsManager 138 public class AgentAssetTransactionsManager
139 { 139 {
140 private static readonly ILog m_log 140 private static readonly ILog m_log
141 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 141 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
142 142
143 // Fields 143 // Fields
144 144
145 /// <summary> 145 /// <summary>
146 /// Each agent has its own singleton collection of transactions 146 /// Each agent has its own singleton collection of transactions
147 /// </summary> 147 /// </summary>
148 private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = 148 private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
149 new Dictionary<LLUUID, AgentAssetTransactions>(); 149 new Dictionary<LLUUID, AgentAssetTransactions>();
150 150
151 /// <summary> 151 /// <summary>
152 /// Should we dump uploaded assets to the filesystem? 152 /// Should we dump uploaded assets to the filesystem?
153 /// </summary> 153 /// </summary>
154 private bool m_dumpAssetsToFile; 154 private bool m_dumpAssetsToFile;
155 155
156 public Scene MyScene; 156 public Scene MyScene;
157 157
158 public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile) 158 public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile)
159 { 159 {
160 MyScene = scene; 160 MyScene = scene;
161 m_dumpAssetsToFile = dumpAssetsToFile; 161 m_dumpAssetsToFile = dumpAssetsToFile;
162 } 162 }
163 163
164 /// <summary> 164 /// <summary>
165 /// Get the collection of asset transactions for the given user. If one does not already exist, it 165 /// Get the collection of asset transactions for the given user. If one does not already exist, it
166 /// is created. 166 /// is created.
167 /// </summary> 167 /// </summary>
168 /// <param name="userID"></param> 168 /// <param name="userID"></param>
169 /// <returns></returns> 169 /// <returns></returns>
170 private AgentAssetTransactions GetUserTransactions(LLUUID userID) 170 private AgentAssetTransactions GetUserTransactions(LLUUID userID)
171 { 171 {
172 lock (AgentTransactions) 172 lock (AgentTransactions)
173 { 173 {
174 if (!AgentTransactions.ContainsKey(userID)) 174 if (!AgentTransactions.ContainsKey(userID))
175 { 175 {
176 AgentAssetTransactions transactions 176 AgentAssetTransactions transactions
177 = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); 177 = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
178 AgentTransactions.Add(userID, transactions); 178 AgentTransactions.Add(userID, transactions);
179 } 179 }
180 180
181 return AgentTransactions[userID]; 181 return AgentTransactions[userID];
182 } 182 }
183 } 183 }
184 184
185 /// <summary> 185 /// <summary>
186 /// Remove the given agent asset transactions. This should be called when a client is departing 186 /// Remove the given agent asset transactions. This should be called when a client is departing
187 /// from a scene (and hence won't be making any more transactions here). 187 /// from a scene (and hence won't be making any more transactions here).
188 /// </summary> 188 /// </summary>
189 /// <param name="userID"></param> 189 /// <param name="userID"></param>
190 public void RemoveAgentAssetTransactions(LLUUID userID) 190 public void RemoveAgentAssetTransactions(LLUUID userID)
191 { 191 {
192 // m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID); 192 // m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID);
193 193
194 lock (AgentTransactions) 194 lock (AgentTransactions)
195 { 195 {
196 AgentTransactions.Remove(userID); 196 AgentTransactions.Remove(userID);
197 } 197 }
198 } 198 }
199 199
200 /// <summary> 200 /// <summary>
201 /// Create an inventory item from data that has been received through a transaction. 201 /// Create an inventory item from data that has been received through a transaction.
202 /// 202 ///
203 /// This is called when new clothing or body parts are created. It may also be called in other 203 /// This is called when new clothing or body parts are created. It may also be called in other
204 /// situations. 204 /// situations.
205 /// </summary> 205 /// </summary>
206 /// <param name="remoteClient"></param> 206 /// <param name="remoteClient"></param>
207 /// <param name="transactionID"></param> 207 /// <param name="transactionID"></param>
208 /// <param name="folderID"></param> 208 /// <param name="folderID"></param>
209 /// <param name="callbackID"></param> 209 /// <param name="callbackID"></param>
210 /// <param name="description"></param> 210 /// <param name="description"></param>
211 /// <param name="name"></param> 211 /// <param name="name"></param>
212 /// <param name="invType"></param> 212 /// <param name="invType"></param>
213 /// <param name="type"></param> 213 /// <param name="type"></param>
214 /// <param name="wearableType"></param> 214 /// <param name="wearableType"></param>
215 /// <param name="nextOwnerMask"></param> 215 /// <param name="nextOwnerMask"></param>
216 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, 216 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
217 uint callbackID, string description, string name, sbyte invType, 217 uint callbackID, string description, string name, sbyte invType,
218 sbyte type, byte wearableType, uint nextOwnerMask) 218 sbyte type, byte wearableType, uint nextOwnerMask)
219 { 219 {
220 m_log.DebugFormat( 220 m_log.DebugFormat(
221 "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); 221 "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
222 222
223 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 223 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
224 224
225 transactions.RequestCreateInventoryItem( 225 transactions.RequestCreateInventoryItem(
226 remoteClient, transactionID, folderID, callbackID, description, 226 remoteClient, transactionID, folderID, callbackID, description,
227 name, invType, type, wearableType, nextOwnerMask); 227 name, invType, type, wearableType, nextOwnerMask);
228 } 228 }
229 229
230 /// <summary> 230 /// <summary>
231 /// Update an inventory item with data that has been received through a transaction. 231 /// Update an inventory item with data that has been received through a transaction.
232 /// 232 ///
233 /// This is called when clothing or body parts are updated (for instance, with new textures or 233 /// This is called when clothing or body parts are updated (for instance, with new textures or
234 /// colours). It may also be called in other situations. 234 /// colours). It may also be called in other situations.
235 /// </summary> 235 /// </summary>
236 /// <param name="remoteClient"></param> 236 /// <param name="remoteClient"></param>
237 /// <param name="transactionID"></param> 237 /// <param name="transactionID"></param>
238 /// <param name="item"></param> 238 /// <param name="item"></param>
239 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, 239 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
240 InventoryItemBase item) 240 InventoryItemBase item)
241 { 241 {
242 m_log.DebugFormat( 242 m_log.DebugFormat(
243 "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", 243 "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
244 item.Name); 244 item.Name);
245 245
246 AgentAssetTransactions transactions 246 AgentAssetTransactions transactions
247 = GetUserTransactions(remoteClient.AgentId); 247 = GetUserTransactions(remoteClient.AgentId);
248 248
249 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); 249 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
250 } 250 }
251 251
252 /// <summary> 252 /// <summary>
253 /// Request that a client (agent) begin an asset transfer. 253 /// Request that a client (agent) begin an asset transfer.
254 /// </summary> 254 /// </summary>
255 /// <param name="remoteClient"></param> 255 /// <param name="remoteClient"></param>
256 /// <param name="assetID"></param> 256 /// <param name="assetID"></param>
257 /// <param name="transaction"></param> 257 /// <param name="transaction"></param>
258 /// <param name="type"></param> 258 /// <param name="type"></param>
259 /// <param name="data"></param></param> 259 /// <param name="data"></param></param>
260 /// <param name="tempFile"></param> 260 /// <param name="tempFile"></param>
261 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, 261 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
262 byte[] data, bool storeLocal, bool tempFile) 262 byte[] data, bool storeLocal, bool tempFile)
263 { 263 {
264 // Console.WriteLine("asset upload of " + assetID); 264 // Console.WriteLine("asset upload of " + assetID);
265 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 265 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
266 266
267 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); 267 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
268 if (uploader != null) 268 if (uploader != null)
269 { 269 {
270 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) 270 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
271 { 271 {
272 } 272 }
273 } 273 }
274 } 274 }
275 275
276 /// <summary> 276 /// <summary>
277 /// Handle asset transfer data packets received in response to the asset upload request in 277 /// Handle asset transfer data packets received in response to the asset upload request in
278 /// HandleUDPUploadRequest() 278 /// HandleUDPUploadRequest()
279 /// </summary> 279 /// </summary>
280 /// <param name="remoteClient"></param> 280 /// <param name="remoteClient"></param>
281 /// <param name="xferID"></param> 281 /// <param name="xferID"></param>
282 /// <param name="packetID"></param> 282 /// <param name="packetID"></param>
283 /// <param name="data"></param> 283 /// <param name="data"></param>
284 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) 284 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
285 { 285 {
286 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 286 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
287 287
288 transactions.HandleXfer(xferID, packetID, data); 288 transactions.HandleXfer(xferID, packetID, data);
289 } 289 }
290 } 290 }
291} \ No newline at end of file 291} \ No newline at end of file