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.cs219
1 files changed, 180 insertions, 39 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
index 19d7066..d98d07d 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -42,48 +42,23 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
42 private bool m_dumpAssetsToFile = false; 42 private bool m_dumpAssetsToFile = false;
43 private Scene m_scene = null; 43 private Scene m_scene = null;
44 44
45 private AgentAssetTransactionsManager m_transactionManager; 45 public Scene MyScene
46
47
48 public AssetTransactionModule()
49 {
50 // System.Console.WriteLine("creating AgentAssetTransactionModule");
51 }
52
53 #region IAgentAssetTransactions Members
54
55 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID,
56 uint callbackID, string description, string name, sbyte invType,
57 sbyte type, byte wearableType, uint nextOwnerMask)
58 { 46 {
59 m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, 47 get{ return m_scene;}
60 wearableType, nextOwnerMask);
61 } 48 }
62 49
63 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item) 50 /// <summary>
64 { 51 /// Each agent has its own singleton collection of transactions
65 m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); 52 /// </summary>
66 } 53 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions =
54 new Dictionary<UUID, AgentAssetTransactions>();
67 55
68 public void HandleTaskItemUpdateFromTransaction(
69 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
70 {
71 m_transactionManager.HandleTaskItemUpdateFromTransaction(remoteClient, part, transactionID, item);
72 }
73
74 public void RequestXferFromClient(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type,
75 byte[] data, bool storeLocal, bool tempFile)
76 {
77 m_transactionManager.HandleUDPUploadRequest(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
78 }
79 56
80 public void RemoveAgentAssetTransactions(UUID userID) 57 public AssetTransactionModule()
81 { 58 {
82 m_transactionManager.RemoveAgentAssetTransactions(userID); 59 // System.Console.WriteLine("creating AgentAssetTransactionModule");
83 } 60 }
84 61
85 #endregion
86
87 #region IRegionModule Members 62 #region IRegionModule Members
88 63
89 public void Initialise(Scene scene, IConfigSource config) 64 public void Initialise(Scene scene, IConfigSource config)
@@ -105,16 +80,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
105 try 80 try
106 { 81 {
107 m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false); 82 m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false);
108 m_transactionManager = new AgentAssetTransactionsManager(m_scene, m_dumpAssetsToFile);
109 } 83 }
110 catch (Exception) 84 catch (Exception)
111 { 85 {
112 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false);
113 } 86 }
114 } 87 }
115 else 88 else
116 { 89 {
117 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false);
118 } 90 }
119 } 91 }
120 } 92 }
@@ -141,8 +113,177 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
141 113
142 public void NewClient(IClientAPI client) 114 public void NewClient(IClientAPI client)
143 { 115 {
144 client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; 116 client.OnAssetUploadRequest += HandleUDPUploadRequest;
145 client.OnXferReceive += m_transactionManager.HandleXfer; 117 client.OnXferReceive += HandleXfer;
118 }
119
120 #region AgentAssetTransactions
121 /// <summary>
122 /// Get the collection of asset transactions for the given user. If one does not already exist, it
123 /// is created.
124 /// </summary>
125 /// <param name="userID"></param>
126 /// <returns></returns>
127 private AgentAssetTransactions GetUserTransactions(UUID userID)
128 {
129 lock (AgentTransactions)
130 {
131 if (!AgentTransactions.ContainsKey(userID))
132 {
133 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
134 AgentTransactions.Add(userID, transactions);
135 }
136
137 return AgentTransactions[userID];
138 }
139 }
140
141 /// <summary>
142 /// Remove the given agent asset transactions. This should be called when a client is departing
143 /// from a scene (and hence won't be making any more transactions here).
144 /// </summary>
145 /// <param name="userID"></param>
146 public void RemoveAgentAssetTransactions(UUID userID)
147 {
148 // m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID);
149
150 lock (AgentTransactions)
151 {
152 AgentTransactions.Remove(userID);
153 }
154 }
155
156 /// <summary>
157 /// Create an inventory item from data that has been received through a transaction.
158 ///
159 /// This is called when new clothing or body parts are created. It may also be called in other
160 /// situations.
161 /// </summary>
162 /// <param name="remoteClient"></param>
163 /// <param name="transactionID"></param>
164 /// <param name="folderID"></param>
165 /// <param name="callbackID"></param>
166 /// <param name="description"></param>
167 /// <param name="name"></param>
168 /// <param name="invType"></param>
169 /// <param name="type"></param>
170 /// <param name="wearableType"></param>
171 /// <param name="nextOwnerMask"></param>
172 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID,
173 uint callbackID, string description, string name, sbyte invType,
174 sbyte type, byte wearableType, uint nextOwnerMask)
175 {
176 // m_log.DebugFormat(
177 // "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
178
179 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
180
181 transactions.RequestCreateInventoryItem(
182 remoteClient, transactionID, folderID, callbackID, description,
183 name, invType, type, wearableType, nextOwnerMask);
146 } 184 }
185
186 /// <summary>
187 /// Update an inventory item with data that has been received through a transaction.
188 ///
189 /// This is called when clothing or body parts are updated (for instance, with new textures or
190 /// colours). It may also be called in other situations.
191 /// </summary>
192 /// <param name="remoteClient"></param>
193 /// <param name="transactionID"></param>
194 /// <param name="item"></param>
195 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID,
196 InventoryItemBase item)
197 {
198 // m_log.DebugFormat(
199 // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
200 // item.Name);
201
202 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
203
204 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
205 }
206
207 /// <summary>
208 /// Update a task inventory item with data that has been received through a transaction.
209 ///
210 /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent
211 /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction
212 /// and comes through this method.
213 /// </summary>
214 /// <param name="remoteClient"></param>
215 /// <param name="transactionID"></param>
216 /// <param name="item"></param>
217 public void HandleTaskItemUpdateFromTransaction(
218 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
219 {
220 // m_log.DebugFormat(
221 // "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}",
222 // item.Name);
223
224 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
225
226 transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
227 }
228
229 /// <summary>
230 /// Request that a client (agent) begin an asset transfer.
231 /// </summary>
232 /// <param name="remoteClient"></param>
233 /// <param name="assetID"></param>
234 /// <param name="transaction"></param>
235 /// <param name="type"></param>
236 /// <param name="data"></param></param>
237 /// <param name="tempFile"></param>
238 public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type,
239 byte[] data, bool storeLocal, bool tempFile)
240 {
241 //System.Console.WriteLine("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile);
242 if (((AssetType)type == AssetType.Texture ||
243 (AssetType)type == AssetType.Sound ||
244 (AssetType)type == AssetType.TextureTGA ||
245 (AssetType)type == AssetType.Animation) &&
246 tempFile == false)
247 {
248 Scene scene = (Scene)remoteClient.Scene;
249 IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
250
251 if (mm != null)
252 {
253 if (!mm.UploadCovered(remoteClient))
254 {
255 remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
256 return;
257 }
258 }
259 }
260
261 //Console.WriteLine("asset upload of " + assetID);
262 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
263
264 AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
265 if (uploader != null)
266 {
267 uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
268 }
269 }
270
271 /// <summary>
272 /// Handle asset transfer data packets received in response to the asset upload request in
273 /// HandleUDPUploadRequest()
274 /// </summary>
275 /// <param name="remoteClient"></param>
276 /// <param name="xferID"></param>
277 /// <param name="packetID"></param>
278 /// <param name="data"></param>
279 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
280 {
281 //System.Console.WriteLine("xferID: " + xferID + " packetID: " + packetID + " data!");
282 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
283
284 transactions.HandleXfer(xferID, packetID, data);
285 }
286
287 #endregion
147 } 288 }
148} 289}