aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-09-11 17:58:46 +0200
committerMelanie2012-09-11 17:58:46 +0200
commit19b00a5b3ce27d3160648c6bc49699b09dc4f283 (patch)
tree34d9f57049f224141c60b11bef32e2dd533f0522 /OpenSim
parentRe-add the module and fix a typo (diff)
downloadopensim-SC-19b00a5b3ce27d3160648c6bc49699b09dc4f283.zip
opensim-SC-19b00a5b3ce27d3160648c6bc49699b09dc4f283.tar.gz
opensim-SC-19b00a5b3ce27d3160648c6bc49699b09dc4f283.tar.bz2
opensim-SC-19b00a5b3ce27d3160648c6bc49699b09dc4f283.tar.xz
Removing the variable prica handler again. It's never called, was misnamed and
probably never worked past the mesh beta.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs332
1 files changed, 0 insertions, 332 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs
deleted file mode 100644
index 423ad58..0000000
--- a/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs
+++ /dev/null
@@ -1,332 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Specialized;
31using System.Reflection;
32using System.IO;
33using System.Web;
34using Mono.Addins;
35using log4net;
36using Nini.Config;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Services.Interfaces;
45using Caps = OpenSim.Framework.Capabilities.Caps;
46using OpenSim.Framework.Capabilities;
47
48namespace OpenSim.Region.ClientStack.Linden
49{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class NewAgentInventoryVariablePriceModule : INonSharedRegionModule
52 {
53// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54
55 private Scene m_scene;
56// private IAssetService m_assetService;
57 private bool m_dumpAssetsToFile = false;
58 private bool m_enabled = true;
59 private int m_levelUpload = 0;
60
61 #region IRegionModuleBase Members
62
63
64 public Type ReplaceableInterface
65 {
66 get { return null; }
67 }
68
69 public void Initialise(IConfigSource source)
70 {
71 IConfig meshConfig = source.Configs["Mesh"];
72 if (meshConfig == null)
73 return;
74
75 m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true);
76 m_levelUpload = meshConfig.GetInt("LevelUpload", 0);
77 }
78
79 public void AddRegion(Scene pScene)
80 {
81 m_scene = pScene;
82 }
83
84 public void RemoveRegion(Scene scene)
85 {
86
87 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
88 m_scene = null;
89 }
90
91 public void RegionLoaded(Scene scene)
92 {
93
94// m_assetService = m_scene.RequestModuleInterface<IAssetService>();
95 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
96 }
97
98 #endregion
99
100
101 #region IRegionModule Members
102
103
104
105 public void Close() { }
106
107 public string Name { get { return "NewAgentInventoryVariablePriceModule"; } }
108
109
110 public void RegisterCaps(UUID agentID, Caps caps)
111 {
112 if(!m_enabled)
113 return;
114
115 UUID capID = UUID.Random();
116
117// m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID);
118 caps.RegisterHandler(
119 "NewAgentInventoryVariablePrice",
120 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDNewFileAngentInventoryVariablePriceReplyResponse>(
121 "POST",
122 "/CAPS/" + capID.ToString(),
123 req => NewAgentInventoryRequest(req, agentID),
124 "NewAgentInventoryVariablePrice",
125 agentID.ToString()));
126 }
127
128 #endregion
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
161 public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID)
162 {
163 //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit
164 // you need to be aware of this
165
166 //if (llsdRequest.asset_type == "texture" ||
167 // llsdRequest.asset_type == "animation" ||
168 // llsdRequest.asset_type == "sound")
169 // {
170 // check user level
171
172 uint cost = 0;
173
174 ScenePresence avatar = null;
175 IClientAPI client = null;
176 m_scene.TryGetScenePresence(agentID, out avatar);
177
178 if (avatar != null)
179 {
180 client = avatar.ControllingClient;
181
182 if (avatar.UserLevel < m_levelUpload)
183 {
184 if (client != null)
185 client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false);
186
187 LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
188 errorResponse.rsvp = "";
189 errorResponse.state = "error";
190 return errorResponse;
191 }
192 }
193
194 // check funds
195 IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>();
196
197 if (mm != null)
198 {
199 // XPTO: Calculate cost here
200 cost = (uint)mm.UploadCharge;
201
202 if (!mm.UploadCovered(agentID, (int)cost))
203 {
204 if (client != null)
205 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
206
207 LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
208 errorResponse.rsvp = "";
209 errorResponse.state = "error";
210 return errorResponse;
211 }
212 }
213
214 // }
215
216 string assetName = llsdRequest.name;
217 string assetDes = llsdRequest.description;
218 string capsBase = "/CAPS/NewAgentInventoryVariablePrice/";
219 UUID newAsset = UUID.Random();
220 UUID newInvItem = UUID.Random();
221 UUID parentFolder = llsdRequest.folder_id;
222 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/";
223
224 AssetUploaderWithCost uploader =
225 new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
226 llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile, cost);
227
228 MainServer.Instance.AddStreamHandler(
229 new BinaryStreamHandler(
230 "POST",
231 capsBase + uploaderPath,
232 uploader.uploaderCaps,
233 "NewAgentInventoryVariablePrice",
234 agentID.ToString()));
235
236 string protocol = "http://";
237
238 if (MainServer.Instance.UseSSL)
239 protocol = "https://";
240
241 string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase +
242 uploaderPath;
243
244
245 LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
246
247 uploadResponse.rsvp = uploaderURL;
248 uploadResponse.state = "upload";
249 uploadResponse.resource_cost = 0;
250 uploadResponse.upload_price = 0;
251
252 uploader.OnUpLoad += //UploadCompleteHandler;
253
254 delegate(
255 string passetName, string passetDescription, UUID passetID,
256 UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType,
257 string passetType, uint pcost)
258 {
259 UploadCompleteHandler(passetName, passetDescription, passetID,
260 pinventoryItem, pparentFolder, pdata, pinventoryType,
261 passetType,agentID, pcost);
262 };
263
264 return uploadResponse;
265 }
266
267 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
268 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
269 string assetType,UUID AgentID, uint cost)
270 {
271// m_log.DebugFormat(
272// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem);
273
274 sbyte assType = 0;
275 sbyte inType = 0;
276
277 if (inventoryType == "sound")
278 {
279 inType = 1;
280 assType = 1;
281 }
282 else if (inventoryType == "animation")
283 {
284 inType = 19;
285 assType = 20;
286 }
287 else if (inventoryType == "wearable")
288 {
289 inType = 18;
290 switch (assetType)
291 {
292 case "bodypart":
293 assType = 13;
294 break;
295 case "clothing":
296 assType = 5;
297 break;
298 }
299 }
300 else if (inventoryType == "mesh")
301 {
302 inType = (sbyte)InventoryType.Mesh;
303 assType = (sbyte)AssetType.Mesh;
304 }
305
306 AssetBase asset;
307 asset = new AssetBase(assetID, assetName, assType, AgentID.ToString());
308 asset.Data = data;
309
310 if (m_scene.AssetService != null)
311 m_scene.AssetService.Store(asset);
312
313 InventoryItemBase item = new InventoryItemBase();
314 item.Owner = AgentID;
315 item.CreatorId = AgentID.ToString();
316 item.ID = inventoryItem;
317 item.AssetID = asset.FullID;
318 item.Description = assetDescription;
319 item.Name = assetName;
320 item.AssetType = assType;
321 item.InvType = inType;
322 item.Folder = parentFolder;
323 item.CurrentPermissions
324 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
325 item.BasePermissions = (uint)PermissionMask.All;
326 item.EveryOnePermissions = 0;
327 item.NextPermissions = (uint)PermissionMask.All;
328 item.CreationDate = Util.UnixTimeSinceEpoch();
329 m_scene.AddUploadedInventoryItem(AgentID, item, cost);
330 }
331 }
332}