aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2012-09-11 17:50:55 +0200
committerMelanie2012-09-11 17:51:20 +0200
commita6928a479eb84b14e949c5f589b9ce753edf457a (patch)
treee6abc094d3ec28f9ae3a0f3a2c5e9867ea49d0e0
parentRevert "Remove the unused NewFileAgentInventoryVariablePrice module." (diff)
downloadopensim-SC_OLD-a6928a479eb84b14e949c5f589b9ce753edf457a.zip
opensim-SC_OLD-a6928a479eb84b14e949c5f589b9ce753edf457a.tar.gz
opensim-SC_OLD-a6928a479eb84b14e949c5f589b9ce753edf457a.tar.bz2
opensim-SC_OLD-a6928a479eb84b14e949c5f589b9ce753edf457a.tar.xz
Add cost calculation suppor tto the VariablePrice one as well
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs1
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs52
2 files changed, 44 insertions, 9 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 097e224..328dc75 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -417,7 +417,6 @@ namespace OpenSim.Region.ClientStack.Linden
417 } 417 }
418 } 418 }
419 419
420
421 /// <summary> 420 /// <summary>
422 /// 421 ///
423 /// </summary> 422 /// </summary>
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
index 52c4f44..6e2b52d 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
@@ -127,6 +127,37 @@ namespace OpenSim.Region.ClientStack.Linden
127 127
128 #endregion 128 #endregion
129 129
130 private delegate void UploadWithCostCompleteDelegate(string assetName,
131 string assetDescription, UUID assetID, UUID inventoryItem,
132 UUID parentFolder, byte[] data, string inventoryType,
133 string assetType, uint cost);
134
135 private class AssetUploaderWithCost : AssetUploader
136 {
137 private uint m_cost;
138
139 public event UploadWithCostCompleteDelegate OnUpLoad;
140
141 public AssetUploaderWithCost(string assetName, string description, UUID assetID,
142 UUID inventoryItem, UUID parentFolderID, string invType, string assetType,
143 string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) :
144 base(assetName, description, assetID, inventoryItem, parentFolderID,
145 invType, assetType, path, httpServer, dumpAssetsToFile)
146 {
147 m_cost = cost;
148
149 base.OnUpLoad += UploadCompleteHandler;
150 }
151
152 private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
153 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
154 string assetType)
155 {
156 OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder,
157 data, inventoryType, assetType, m_cost);
158 }
159 }
160
130 public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) 161 public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID)
131 { 162 {
132 //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit 163 //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit
@@ -138,6 +169,8 @@ namespace OpenSim.Region.ClientStack.Linden
138 // { 169 // {
139 // check user level 170 // check user level
140 171
172 uint cost = 0;
173
141 ScenePresence avatar = null; 174 ScenePresence avatar = null;
142 IClientAPI client = null; 175 IClientAPI client = null;
143 m_scene.TryGetScenePresence(agentID, out avatar); 176 m_scene.TryGetScenePresence(agentID, out avatar);
@@ -163,7 +196,10 @@ namespace OpenSim.Region.ClientStack.Linden
163 196
164 if (mm != null) 197 if (mm != null)
165 { 198 {
166 if (!mm.UploadCovered(agentID, mm.UploadCharge)) 199 // XPTO: Calculate cost here
200 cost = (uint)mm.UploadCharge;
201
202 if (!mm.UploadCovered(agentID, (int)cost))
167 { 203 {
168 if (client != null) 204 if (client != null)
169 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); 205 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
@@ -185,9 +221,9 @@ namespace OpenSim.Region.ClientStack.Linden
185 UUID parentFolder = llsdRequest.folder_id; 221 UUID parentFolder = llsdRequest.folder_id;
186 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; 222 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/";
187 223
188 AssetUploader uploader = 224 AssetUploaderWithCost uploader =
189 new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, 225 new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
190 llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); 226 llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile, cost);
191 227
192 MainServer.Instance.AddStreamHandler( 228 MainServer.Instance.AddStreamHandler(
193 new BinaryStreamHandler( 229 new BinaryStreamHandler(
@@ -218,11 +254,11 @@ namespace OpenSim.Region.ClientStack.Linden
218 delegate( 254 delegate(
219 string passetName, string passetDescription, UUID passetID, 255 string passetName, string passetDescription, UUID passetID,
220 UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, 256 UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType,
221 string passetType) 257 string passetType, uint cost)
222 { 258 {
223 UploadCompleteHandler(passetName, passetDescription, passetID, 259 UploadCompleteHandler(passetName, passetDescription, passetID,
224 pinventoryItem, pparentFolder, pdata, pinventoryType, 260 pinventoryItem, pparentFolder, pdata, pinventoryType,
225 passetType,agentID); 261 passetType,agentID, cost);
226 }; 262 };
227 263
228 return uploadResponse; 264 return uploadResponse;
@@ -230,7 +266,7 @@ namespace OpenSim.Region.ClientStack.Linden
230 266
231 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, 267 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
232 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, 268 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
233 string assetType,UUID AgentID) 269 string assetType,UUID AgentID, uint cost)
234 { 270 {
235// m_log.DebugFormat( 271// m_log.DebugFormat(
236// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem); 272// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem);
@@ -290,7 +326,7 @@ namespace OpenSim.Region.ClientStack.Linden
290 item.EveryOnePermissions = 0; 326 item.EveryOnePermissions = 0;
291 item.NextPermissions = (uint)PermissionMask.All; 327 item.NextPermissions = (uint)PermissionMask.All;
292 item.CreationDate = Util.UnixTimeSinceEpoch(); 328 item.CreationDate = Util.UnixTimeSinceEpoch();
293 m_scene.AddInventoryItem(item); 329 m_scene.AddUploadedInventoryItem(AgentID, item, cost);
294 } 330 }
295 } 331 }
296} 332}