aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs166
1 files changed, 88 insertions, 78 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
index ae31050..82558de 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -34,22 +34,19 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using Mono.Addins;
37 38
38namespace OpenSim.Region.CoreModules.Agent.AssetTransaction 39namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
39{ 40{
40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions 41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetTransactionModule")]
42 public class AssetTransactionModule : INonSharedRegionModule,
43 IAgentAssetTransactions
41 { 44 {
42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45// private static readonly ILog m_log = LogManager.GetLogger(
46// MethodBase.GetCurrentMethod().DeclaringType);
43 47
44 private readonly Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); 48 protected Scene m_Scene;
45 private bool m_dumpAssetsToFile = false; 49 private bool m_dumpAssetsToFile = false;
46 private Scene m_scene = null;
47
48 [Obsolete]
49 public Scene MyScene
50 {
51 get{ return m_scene;}
52 }
53 50
54 /// <summary> 51 /// <summary>
55 /// Each agent has its own singleton collection of transactions 52 /// Each agent has its own singleton collection of transactions
@@ -57,33 +54,24 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
57 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions = 54 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions =
58 new Dictionary<UUID, AgentAssetTransactions>(); 55 new Dictionary<UUID, AgentAssetTransactions>();
59 56
57 #region IRegionModule Members
60 58
61 public AssetTransactionModule() 59 public void Initialise(IConfigSource config)
62 { 60 {
63 //m_log.Debug("creating AgentAssetTransactionModule");
64 } 61 }
65 62
66 #region IRegionModule Members 63 public void AddRegion(Scene scene)
67
68 public void Initialise(Scene scene, IConfigSource config)
69 { 64 {
70 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 65 m_Scene = scene;
71 { 66 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
72 // m_log.Debug("initialising AgentAssetTransactionModule"); 67 scene.EventManager.OnNewClient += NewClient;
73 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); 68 }
74 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
75
76 scene.EventManager.OnNewClient += NewClient;
77 }
78 69
79 // EVIL HACK! 70 public void RegionLoaded(Scene scene)
80 // This needs killing! 71 {
81 //
82 if (m_scene == null)
83 m_scene = scene;
84 } 72 }
85 73
86 public void PostInitialise() 74 public void RemoveRegion(Scene scene)
87 { 75 {
88 } 76 }
89 77
@@ -96,9 +84,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
96 get { return "AgentTransactionModule"; } 84 get { return "AgentTransactionModule"; }
97 } 85 }
98 86
99 public bool IsSharedModule 87 public Type ReplaceableInterface
100 { 88 {
101 get { return true; } 89 get { return typeof(IAgentAssetTransactions); }
102 } 90 }
103 91
104 #endregion 92 #endregion
@@ -111,8 +99,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
111 99
112 #region AgentAssetTransactions 100 #region AgentAssetTransactions
113 /// <summary> 101 /// <summary>
114 /// Get the collection of asset transactions for the given user. If one does not already exist, it 102 /// Get the collection of asset transactions for the given user.
115 /// is created. 103 /// If one does not already exist, it is created.
116 /// </summary> 104 /// </summary>
117 /// <param name="userID"></param> 105 /// <param name="userID"></param>
118 /// <returns></returns> 106 /// <returns></returns>
@@ -122,7 +110,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
122 { 110 {
123 if (!AgentTransactions.ContainsKey(userID)) 111 if (!AgentTransactions.ContainsKey(userID))
124 { 112 {
125 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); 113 AgentAssetTransactions transactions =
114 new AgentAssetTransactions(userID, m_Scene,
115 m_dumpAssetsToFile);
116
126 AgentTransactions.Add(userID, transactions); 117 AgentTransactions.Add(userID, transactions);
127 } 118 }
128 119
@@ -131,8 +122,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
131 } 122 }
132 123
133 /// <summary> 124 /// <summary>
134 /// Remove the given agent asset transactions. This should be called when a client is departing 125 /// Remove the given agent asset transactions. This should be called
135 /// from a scene (and hence won't be making any more transactions here). 126 /// when a client is departing from a scene (and hence won't be making
127 /// any more transactions here).
136 /// </summary> 128 /// </summary>
137 /// <param name="userID"></param> 129 /// <param name="userID"></param>
138 public void RemoveAgentAssetTransactions(UUID userID) 130 public void RemoveAgentAssetTransactions(UUID userID)
@@ -146,10 +138,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
146 } 138 }
147 139
148 /// <summary> 140 /// <summary>
149 /// Create an inventory item from data that has been received through a transaction. 141 /// Create an inventory item from data that has been received through
150 /// 142 /// a transaction.
151 /// This is called when new clothing or body parts are created. It may also be called in other 143 /// This is called when new clothing or body parts are created.
152 /// situations. 144 /// It may also be called in other situations.
153 /// </summary> 145 /// </summary>
154 /// <param name="remoteClient"></param> 146 /// <param name="remoteClient"></param>
155 /// <param name="transactionID"></param> 147 /// <param name="transactionID"></param>
@@ -161,61 +153,72 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
161 /// <param name="type"></param> 153 /// <param name="type"></param>
162 /// <param name="wearableType"></param> 154 /// <param name="wearableType"></param>
163 /// <param name="nextOwnerMask"></param> 155 /// <param name="nextOwnerMask"></param>
164 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, 156 public void HandleItemCreationFromTransaction(IClientAPI remoteClient,
165 uint callbackID, string description, string name, sbyte invType, 157 UUID transactionID, UUID folderID, uint callbackID,
166 sbyte type, byte wearableType, uint nextOwnerMask) 158 string description, string name, sbyte invType,
159 sbyte type, byte wearableType, uint nextOwnerMask)
167 { 160 {
168 // m_log.DebugFormat( 161// m_log.DebugFormat(
169 // "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); 162// "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
170 163
171 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 164 AgentAssetTransactions transactions =
165 GetUserTransactions(remoteClient.AgentId);
172 166
173 transactions.RequestCreateInventoryItem( 167 transactions.RequestCreateInventoryItem(remoteClient, transactionID,
174 remoteClient, transactionID, folderID, callbackID, description, 168 folderID, callbackID, description, name, invType, type,
175 name, invType, type, wearableType, nextOwnerMask); 169 wearableType, nextOwnerMask);
176 } 170 }
177 171
178 /// <summary> 172 /// <summary>
179 /// Update an inventory item with data that has been received through a transaction. 173 /// Update an inventory item with data that has been received through a
174 /// transaction.
180 /// 175 ///
181 /// This is called when clothing or body parts are updated (for instance, with new textures or 176 /// This is called when clothing or body parts are updated (for
182 /// colours). It may also be called in other situations. 177 /// instance, with new textures or colours). It may also be called in
178 /// other situations.
183 /// </summary> 179 /// </summary>
184 /// <param name="remoteClient"></param> 180 /// <param name="remoteClient"></param>
185 /// <param name="transactionID"></param> 181 /// <param name="transactionID"></param>
186 /// <param name="item"></param> 182 /// <param name="item"></param>
187 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, 183 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient,
188 InventoryItemBase item) 184 UUID transactionID, InventoryItemBase item)
189 { 185 {
190 // m_log.DebugFormat( 186// m_log.DebugFormat(
191 // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", 187// "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
192 // item.Name); 188// item.Name);
193 189
194 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 190 AgentAssetTransactions transactions =
191 GetUserTransactions(remoteClient.AgentId);
195 192
196 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); 193 transactions.RequestUpdateInventoryItem(remoteClient,
194 transactionID, item);
197 } 195 }
198 196
199 /// <summary> 197 /// <summary>
200 /// Update a task inventory item with data that has been received through a transaction. 198 /// Update a task inventory item with data that has been received
199 /// through a transaction.
201 /// 200 ///
202 /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent 201 /// This is currently called when, for instance, a notecard in a prim
203 /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction 202 /// is saved. The data is sent up through a single AssetUploadRequest.
203 /// A subsequent UpdateTaskInventory then references the transaction
204 /// and comes through this method. 204 /// and comes through this method.
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="item"></param> 208 /// <param name="item"></param>
209 public void HandleTaskItemUpdateFromTransaction( 209 public void HandleTaskItemUpdateFromTransaction(IClientAPI remoteClient,
210 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) 210 SceneObjectPart part, UUID transactionID,
211 TaskInventoryItem item)
211 { 212 {
212 // m_log.DebugFormat( 213// m_log.DebugFormat(
213 // "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", 214// "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}",
214 // item.Name); 215// item.Name);
215 216
216 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 217 AgentAssetTransactions transactions =
218 GetUserTransactions(remoteClient.AgentId);
217 219
218 transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); 220 transactions.RequestUpdateTaskInventoryItem(remoteClient, part,
221 transactionID, item);
219 } 222 }
220 223
221 /// <summary> 224 /// <summary>
@@ -227,8 +230,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
227 /// <param name="type"></param> 230 /// <param name="type"></param>
228 /// <param name="data"></param></param> 231 /// <param name="data"></param></param>
229 /// <param name="tempFile"></param> 232 /// <param name="tempFile"></param>
230 public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, 233 public void HandleUDPUploadRequest(IClientAPI remoteClient,
231 byte[] data, bool storeLocal, bool tempFile) 234 UUID assetID, UUID transaction, sbyte type, byte[] data,
235 bool storeLocal, bool tempFile)
232 { 236 {
233// m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); 237// m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile);
234 238
@@ -251,27 +255,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
251 } 255 }
252 } 256 }
253 257
254 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 258 AgentAssetTransactions transactions =
259 GetUserTransactions(remoteClient.AgentId);
260
261 AssetXferUploader uploader =
262 transactions.RequestXferUploader(transaction);
255 263
256 AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
257 if (uploader != null) 264 if (uploader != null)
258 { 265 {
259 uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); 266 uploader.Initialise(remoteClient, assetID, transaction, type,
267 data, storeLocal, tempFile);
260 } 268 }
261 } 269 }
262 270
263 /// <summary> 271 /// <summary>
264 /// 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
265 /// HandleUDPUploadRequest() 273 /// asset upload request in HandleUDPUploadRequest()
266 /// </summary> 274 /// </summary>
267 /// <param name="remoteClient"></param> 275 /// <param name="remoteClient"></param>
268 /// <param name="xferID"></param> 276 /// <param name="xferID"></param>
269 /// <param name="packetID"></param> 277 /// <param name="packetID"></param>
270 /// <param name="data"></param> 278 /// <param name="data"></param>
271 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) 279 public void HandleXfer(IClientAPI remoteClient, ulong xferID,
280 uint packetID, byte[] data)
272 { 281 {
273 //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); 282 //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!");
274 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 283 AgentAssetTransactions transactions =
284 GetUserTransactions(remoteClient.AgentId);
275 285
276 transactions.HandleXfer(xferID, packetID, data); 286 transactions.HandleXfer(xferID, packetID, data);
277 } 287 }