aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorJonathan Freedman2010-10-17 18:45:25 -0400
committerJonathan Freedman2010-10-17 18:45:25 -0400
commit4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65 (patch)
tree79142f2364b658f52b63e3ae688a5521290e2a4f /OpenSim/Region/CoreModules/Avatar
parent* more url / hg cleanup (diff)
parentMerge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.zip
opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.gz
opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.bz2
opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.xz
Merge branch 'master' of git://opensimulator.org/git/opensim
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 457e0bb..2a0c0b1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -113,6 +113,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
113 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 113 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
114 return; 114 return;
115 115
116 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
117 // be removed when that functionality is implemented in opensim
118 AttachmentPt &= 0x7f;
119
116 // Calls attach with a Zero position 120 // Calls attach with a Zero position
117 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) 121 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
118 { 122 {
@@ -142,6 +146,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
142 146
143 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) 147 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
144 { 148 {
149 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
150 // be removed when that functionality is implemented in opensim
151 AttachmentPt &= 0x7f;
152
145 // If the attachment point isn't the same as the one previously used 153 // If the attachment point isn't the same as the one previously used
146 // set it's offset position = 0 so that it appears on the attachment point 154 // set it's offset position = 0 so that it appears on the attachment point
147 // and not in a weird location somewhere unknown. 155 // and not in a weird location somewhere unknown.
@@ -228,6 +236,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
228 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", 236 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
229 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); 237 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
230 238
239 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
240 // be removed when that functionality is implemented in opensim
241 AttachmentPt &= 0x7f;
242
231 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); 243 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt);
232 244
233 if (updateInventoryStatus) 245 if (updateInventoryStatus)