aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorMelanie2010-10-16 02:27:51 +0100
committerMelanie2010-10-16 02:27:51 +0100
commit455a2ba7ded01ffce92bf54cb3e11e73ae086e22 (patch)
tree9d695e2b8108b3b626ade78c3e65b654076e2074 /OpenSim/Region/CoreModules/Avatar
parentAdd a setter to OldItemID so it can be deserialized (diff)
parentAdding projected light filters to prim propeties (diff)
downloadopensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.zip
opensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.tar.gz
opensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.tar.bz2
opensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs202
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs266
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs12
3 files changed, 480 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs
new file mode 100644
index 0000000..36aaab3
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs
@@ -0,0 +1,202 @@
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;
46
47namespace OpenSim.Region.CoreModules.Avatar.Assets
48{
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
50 public class GetMeshModule : INonSharedRegionModule
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 private Scene m_scene;
55 private IAssetService m_assetService;
56
57 #region IRegionModuleBase Members
58
59
60 public Type ReplaceableInterface
61 {
62 get { return null; }
63 }
64
65 public void Initialise(IConfigSource source)
66 {
67
68 }
69
70 public void AddRegion(Scene pScene)
71 {
72 m_scene = pScene;
73 }
74
75 public void RemoveRegion(Scene scene)
76 {
77
78 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
79 m_scene = null;
80 }
81
82 public void RegionLoaded(Scene scene)
83 {
84
85 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
86 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
87 }
88
89 #endregion
90
91
92 #region IRegionModule Members
93
94
95
96 public void Close() { }
97
98 public string Name { get { return "GetMeshModule"; } }
99
100
101 public void RegisterCaps(UUID agentID, Caps caps)
102 {
103 UUID capID = UUID.Random();
104
105 m_log.Info("[GETMESH]: /CAPS/" + capID);
106 caps.RegisterHandler("GetMesh",
107 new RestHTTPHandler("GET", "/CAPS/" + capID,
108 delegate(Hashtable m_dhttpMethod)
109 {
110 return ProcessGetMesh(m_dhttpMethod, agentID, caps);
111 }));
112
113 }
114
115 #endregion
116
117 public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap)
118 {
119
120 Hashtable responsedata = new Hashtable();
121 responsedata["int_response_code"] = 400; //501; //410; //404;
122 responsedata["content_type"] = "text/plain";
123 responsedata["keepalive"] = false;
124 responsedata["str_response_string"] = "Request wasn't what was expected";
125
126 string meshStr = string.Empty;
127
128 if (request.ContainsKey("mesh_id"))
129 meshStr = request["mesh_id"].ToString();
130
131
132 UUID meshID = UUID.Zero;
133 if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID))
134 {
135 if (m_assetService == null)
136 {
137 responsedata["int_response_code"] = 404; //501; //410; //404;
138 responsedata["content_type"] = "text/plain";
139 responsedata["keepalive"] = false;
140 responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh.";
141 return responsedata;
142 }
143
144 AssetBase mesh;
145 // Only try to fetch locally cached textures. Misses are redirected
146 mesh = m_assetService.GetCached(meshID.ToString());
147 if (mesh != null)
148 {
149 if (mesh.Type == (SByte)AssetType.Mesh)
150 {
151 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
152 responsedata["content_type"] = "application/vnd.ll.mesh";
153 responsedata["int_response_code"] = 200;
154 }
155 // Optionally add additional mesh types here
156 else
157 {
158 responsedata["int_response_code"] = 404; //501; //410; //404;
159 responsedata["content_type"] = "text/plain";
160 responsedata["keepalive"] = false;
161 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
162 return responsedata;
163 }
164 }
165 else
166 {
167 mesh = m_assetService.Get(meshID.ToString());
168 if (mesh != null)
169 {
170 if (mesh.Type == (SByte)AssetType.Mesh)
171 {
172 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
173 responsedata["content_type"] = "application/vnd.ll.mesh";
174 responsedata["int_response_code"] = 200;
175 }
176 // Optionally add additional mesh types here
177 else
178 {
179 responsedata["int_response_code"] = 404; //501; //410; //404;
180 responsedata["content_type"] = "text/plain";
181 responsedata["keepalive"] = false;
182 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
183 return responsedata;
184 }
185 }
186
187 else
188 {
189 responsedata["int_response_code"] = 404; //501; //410; //404;
190 responsedata["content_type"] = "text/plain";
191 responsedata["keepalive"] = false;
192 responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
193 return responsedata;
194 }
195 }
196
197 }
198
199 return responsedata;
200 }
201 }
202}
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
new file mode 100644
index 0000000..af26b2b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
@@ -0,0 +1,266 @@
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.CoreModules.Avatar.Assets
49{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule
52 {
53 private static readonly ILog m_log =
54 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private Scene m_scene;
56 private IAssetService m_assetService;
57 private bool m_dumpAssetsToFile = false;
58
59 #region IRegionModuleBase Members
60
61
62 public Type ReplaceableInterface
63 {
64 get { return null; }
65 }
66
67 public void Initialise(IConfigSource source)
68 {
69
70 }
71
72 public void AddRegion(Scene pScene)
73 {
74 m_scene = pScene;
75 }
76
77 public void RemoveRegion(Scene scene)
78 {
79
80 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
81 m_scene = null;
82 }
83
84 public void RegionLoaded(Scene scene)
85 {
86
87 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
88 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
89 }
90
91 #endregion
92
93
94 #region IRegionModule Members
95
96
97
98 public void Close() { }
99
100 public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } }
101
102
103 public void RegisterCaps(UUID agentID, Caps caps)
104 {
105 UUID capID = UUID.Random();
106
107 m_log.Info("[GETMESH]: /CAPS/" + capID);
108 caps.RegisterHandler("NewFileAgentInventoryVariablePrice",
109
110 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDNewFileAngentInventoryVariablePriceReplyResponse>("POST",
111 "/CAPS/" + capID.ToString(),
112 delegate(LLSDAssetUploadRequest req)
113 {
114 return NewAgentInventoryRequest(req,agentID);
115 }));
116
117 }
118
119 #endregion
120
121 public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID)
122 {
123
124 //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit
125 // You need to be aware of this and
126
127
128 //if (llsdRequest.asset_type == "texture" ||
129 // llsdRequest.asset_type == "animation" ||
130 // llsdRequest.asset_type == "sound")
131 // {
132 IClientAPI client = null;
133
134
135 IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>();
136
137 if (mm != null)
138 {
139 if (m_scene.TryGetClient(agentID, out client))
140 {
141 if (!mm.UploadCovered(client, mm.UploadCharge))
142 {
143 if (client != null)
144 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
145
146 LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
147 errorResponse.rsvp = "";
148 errorResponse.state = "error";
149 return errorResponse;
150 }
151 }
152 }
153 // }
154
155
156
157 string assetName = llsdRequest.name;
158 string assetDes = llsdRequest.description;
159 string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/";
160 UUID newAsset = UUID.Random();
161 UUID newInvItem = UUID.Random();
162 UUID parentFolder = llsdRequest.folder_id;
163 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/";
164
165 Caps.AssetUploader uploader =
166 new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
167 llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile);
168 MainServer.Instance.AddStreamHandler(
169 new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
170
171 string protocol = "http://";
172
173 if (MainServer.Instance.UseSSL)
174 protocol = "https://";
175
176 string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase +
177 uploaderPath;
178
179
180 LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
181
182
183 uploadResponse.rsvp = uploaderURL;
184 uploadResponse.state = "upload";
185 uploadResponse.resource_cost = 0;
186 uploadResponse.upload_price = 0;
187
188 uploader.OnUpLoad += //UploadCompleteHandler;
189
190 delegate(
191 string passetName, string passetDescription, UUID passetID,
192 UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType,
193 string passetType)
194 {
195 UploadCompleteHandler(passetName, passetDescription, passetID,
196 pinventoryItem, pparentFolder, pdata, pinventoryType,
197 passetType,agentID);
198 };
199 return uploadResponse;
200 }
201
202
203 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
204 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
205 string assetType,UUID AgentID)
206 {
207
208 sbyte assType = 0;
209 sbyte inType = 0;
210
211 if (inventoryType == "sound")
212 {
213 inType = 1;
214 assType = 1;
215 }
216 else if (inventoryType == "animation")
217 {
218 inType = 19;
219 assType = 20;
220 }
221 else if (inventoryType == "wearable")
222 {
223 inType = 18;
224 switch (assetType)
225 {
226 case "bodypart":
227 assType = 13;
228 break;
229 case "clothing":
230 assType = 5;
231 break;
232 }
233 }
234 else if (inventoryType == "mesh")
235 {
236 inType = (sbyte)InventoryType.Mesh;
237 assType = (sbyte)AssetType.Mesh;
238 }
239
240 AssetBase asset;
241 asset = new AssetBase(assetID, assetName, assType, AgentID.ToString());
242 asset.Data = data;
243
244 if (m_scene.AssetService != null)
245 m_scene.AssetService.Store(asset);
246
247 InventoryItemBase item = new InventoryItemBase();
248 item.Owner = AgentID;
249 item.CreatorId = AgentID.ToString();
250 item.ID = inventoryItem;
251 item.AssetID = asset.FullID;
252 item.Description = assetDescription;
253 item.Name = assetName;
254 item.AssetType = assType;
255 item.InvType = inType;
256 item.Folder = parentFolder;
257 item.CurrentPermissions = (uint)PermissionMask.All;
258 item.BasePermissions = (uint)PermissionMask.All;
259 item.EveryOnePermissions = 0;
260 item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
261 item.CreationDate = Util.UnixTimeSinceEpoch();
262 m_scene.AddInventoryItem(item);
263
264 }
265 }
266}
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 6ff0ffc..bf71c07 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -114,6 +114,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
114 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 114 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
115 return; 115 return;
116 116
117 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
118 // be removed when that functionality is implemented in opensim
119 AttachmentPt &= 0x7f;
120
117 // Calls attach with a Zero position 121 // Calls attach with a Zero position
118 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) 122 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
119 { 123 {
@@ -143,6 +147,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
143 147
144 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) 148 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
145 { 149 {
150 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
151 // be removed when that functionality is implemented in opensim
152 AttachmentPt &= 0x7f;
153
146 // If the attachment point isn't the same as the one previously used 154 // If the attachment point isn't the same as the one previously used
147 // set it's offset position = 0 so that it appears on the attachment point 155 // set it's offset position = 0 so that it appears on the attachment point
148 // and not in a weird location somewhere unknown. 156 // and not in a weird location somewhere unknown.
@@ -231,6 +239,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
231 public UUID RezSingleAttachmentFromInventory( 239 public UUID RezSingleAttachmentFromInventory(
232 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) 240 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
233 { 241 {
242 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
243 // be removed when that functionality is implemented in opensim
244 AttachmentPt &= 0x7f;
245
234 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc); 246 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc);
235 247
236 if (updateInventoryStatus) 248 if (updateInventoryStatus)