aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs (renamed from OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs)572
1 files changed, 286 insertions, 286 deletions
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
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.Modules.Agent.AssetTransaction;
37 37using OpenSim.Region.Environment.Scenes;
38namespace OpenSim.Region.Environment.Modules 38
39{ 39namespace 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