diff options
Diffstat (limited to 'OpenSim/Region')
39 files changed, 1648 insertions, 687 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs new file mode 100644 index 0000000..7945d5e --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -0,0 +1,1213 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.IO; | ||
5 | using System.Reflection; | ||
6 | |||
7 | using OpenMetaverse; | ||
8 | using Nini.Config; | ||
9 | using log4net; | ||
10 | |||
11 | using OpenSim.Framework; | ||
12 | using OpenSim.Framework.Capabilities; | ||
13 | using OpenSim.Region.Framework; | ||
14 | using OpenSim.Region.Framework.Scenes; | ||
15 | using OpenSim.Framework.Servers; | ||
16 | using OpenSim.Framework.Servers.HttpServer; | ||
17 | using OpenSim.Services.Interfaces; | ||
18 | |||
19 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
20 | |||
21 | namespace OpenSim.Region.ClientStack.Linden | ||
22 | { | ||
23 | public delegate void UpLoadedAsset( | ||
24 | string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, | ||
25 | byte[] data, string inventoryType, string assetType); | ||
26 | |||
27 | public delegate void UploadedBakedTexture(UUID assetID, byte[] data); | ||
28 | |||
29 | public delegate UUID UpdateItem(UUID itemID, byte[] data); | ||
30 | |||
31 | public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors); | ||
32 | |||
33 | public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); | ||
34 | |||
35 | public delegate void NewAsset(AssetBase asset); | ||
36 | |||
37 | public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data); | ||
38 | |||
39 | public delegate ArrayList TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, | ||
40 | bool isScriptRunning, byte[] data); | ||
41 | |||
42 | public delegate InventoryCollection FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, | ||
43 | bool fetchFolders, bool fetchItems, int sortOrder, out int version); | ||
44 | |||
45 | /// <summary> | ||
46 | /// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that | ||
47 | /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want | ||
48 | /// to just pass the whole Scene into CAPS. | ||
49 | /// </summary> | ||
50 | public delegate IClientAPI GetClientDelegate(UUID agentID); | ||
51 | |||
52 | public class BunchOfCaps | ||
53 | { | ||
54 | private static readonly ILog m_log = | ||
55 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | |||
57 | private Scene m_Scene; | ||
58 | private Caps m_HostCapsObj; | ||
59 | |||
60 | private static readonly string m_requestPath = "0000/"; | ||
61 | // private static readonly string m_mapLayerPath = "0001/"; | ||
62 | private static readonly string m_newInventory = "0002/"; | ||
63 | //private static readonly string m_requestTexture = "0003/"; | ||
64 | private static readonly string m_notecardUpdatePath = "0004/"; | ||
65 | private static readonly string m_notecardTaskUpdatePath = "0005/"; | ||
66 | // private static readonly string m_fetchInventoryPath = "0006/"; | ||
67 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. | ||
68 | private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule. | ||
69 | |||
70 | |||
71 | // These are callbacks which will be setup by the scene so that we can update scene data when we | ||
72 | // receive capability calls | ||
73 | public NewInventoryItem AddNewInventoryItem = null; | ||
74 | public NewAsset AddNewAsset = null; | ||
75 | public ItemUpdatedCallback ItemUpdatedCall = null; | ||
76 | public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; | ||
77 | public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; | ||
78 | public GetClientDelegate GetClient = null; | ||
79 | |||
80 | private bool m_persistBakedTextures = false; | ||
81 | private IAssetService m_assetService; | ||
82 | private bool m_dumpAssetsToFile; | ||
83 | private string m_regionName; | ||
84 | private object m_fetchLock = new Object(); | ||
85 | |||
86 | public BunchOfCaps(Scene scene, Caps caps) | ||
87 | { | ||
88 | m_Scene = scene; | ||
89 | m_HostCapsObj = caps; | ||
90 | IConfigSource config = m_Scene.Config; | ||
91 | if (config != null) | ||
92 | { | ||
93 | IConfig sconfig = config.Configs["Startup"]; | ||
94 | if (sconfig != null) | ||
95 | m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); | ||
96 | } | ||
97 | |||
98 | m_assetService = m_Scene.AssetService; | ||
99 | m_regionName = m_Scene.RegionInfo.RegionName; | ||
100 | |||
101 | RegisterHandlers(); | ||
102 | |||
103 | AddNewInventoryItem = m_Scene.AddUploadedInventoryItem; | ||
104 | ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset; | ||
105 | TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset; | ||
106 | CAPSFetchInventoryDescendents = m_Scene.HandleFetchInventoryDescendentsCAPS; | ||
107 | GetClient = m_Scene.SceneContents.GetControllingClient; | ||
108 | |||
109 | } | ||
110 | |||
111 | /// <summary> | ||
112 | /// Register a bunch of CAPS http service handlers | ||
113 | /// </summary> | ||
114 | public void RegisterHandlers() | ||
115 | { | ||
116 | m_HostCapsObj.DeregisterHandlers(); | ||
117 | |||
118 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; | ||
119 | |||
120 | RegisterRegionServiceHandlers(capsBase); | ||
121 | RegisterInventoryServiceHandlers(capsBase); | ||
122 | } | ||
123 | |||
124 | public void RegisterRegionServiceHandlers(string capsBase) | ||
125 | { | ||
126 | try | ||
127 | { | ||
128 | // the root of all evil | ||
129 | m_HostCapsObj.RegisterHandler("SEED", new RestStreamHandler("POST", capsBase + m_requestPath, SeedCapRequest)); | ||
130 | m_log.DebugFormat( | ||
131 | "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID); | ||
132 | |||
133 | //m_capsHandlers["MapLayer"] = | ||
134 | // new LLSDStreamhandler<OSDMapRequest, OSDMapLayerResponse>("POST", | ||
135 | // capsBase + m_mapLayerPath, | ||
136 | // GetMapLayer); | ||
137 | IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); | ||
138 | m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); | ||
139 | m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); | ||
140 | m_HostCapsObj.RegisterHandler("UploadBakedTexture", new RestStreamHandler("POST", capsBase + m_uploadBakedTexturePath, UploadBakedTexture)); | ||
141 | |||
142 | } | ||
143 | catch (Exception e) | ||
144 | { | ||
145 | m_log.Error("[CAPS]: " + e.ToString()); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | public void RegisterInventoryServiceHandlers(string capsBase) | ||
150 | { | ||
151 | try | ||
152 | { | ||
153 | // I don't think this one works... | ||
154 | m_HostCapsObj.RegisterHandler("NewFileAgentInventory", new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", | ||
155 | capsBase + m_newInventory, | ||
156 | NewAgentInventoryRequest)); | ||
157 | IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); | ||
158 | m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); | ||
159 | m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); | ||
160 | m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); | ||
161 | |||
162 | // As of RC 1.22.9 of the Linden client this is | ||
163 | // supported | ||
164 | |||
165 | //m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); | ||
166 | |||
167 | // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and | ||
168 | // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires | ||
169 | // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service, | ||
170 | // but when I went on the Linden grid, the | ||
171 | // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead, | ||
172 | // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP | ||
173 | // | ||
174 | // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid | ||
175 | // we will be | ||
176 | // able to get the data we need to implement the necessary part of the protocol to fix the issue above. | ||
177 | // m_capsHandlers["FetchInventoryDescendents"] = | ||
178 | // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); | ||
179 | |||
180 | // m_capsHandlers["FetchInventoryDescendents"] = | ||
181 | // new LLSDStreamhandler<LLSDFetchInventoryDescendents, LLSDInventoryDescendents>("POST", | ||
182 | // capsBase + m_fetchInventory, | ||
183 | // FetchInventory)); | ||
184 | // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST", | ||
185 | // capsBase + m_requestTexture, | ||
186 | // RequestTexture); | ||
187 | } | ||
188 | catch (Exception e) | ||
189 | { | ||
190 | m_log.Error("[CAPS]: " + e.ToString()); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | /// <summary> | ||
195 | /// Construct a client response detailing all the capabilities this server can provide. | ||
196 | /// </summary> | ||
197 | /// <param name="request"></param> | ||
198 | /// <param name="path"></param> | ||
199 | /// <param name="param"></param> | ||
200 | /// <param name="httpRequest">HTTP request header object</param> | ||
201 | /// <param name="httpResponse">HTTP response header object</param> | ||
202 | /// <returns></returns> | ||
203 | public string SeedCapRequest(string request, string path, string param, | ||
204 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
205 | { | ||
206 | m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); | ||
207 | |||
208 | if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) | ||
209 | { | ||
210 | m_log.DebugFormat("[CAPS]: Unauthorized CAPS client"); | ||
211 | return string.Empty; | ||
212 | } | ||
213 | |||
214 | // WARNING: Add the external too | ||
215 | string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.CapsHandlers.CapsDetails); | ||
216 | |||
217 | //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); | ||
218 | |||
219 | return result; | ||
220 | } | ||
221 | |||
222 | /// <summary> | ||
223 | /// Called by the script task update handler. Provides a URL to which the client can upload a new asset. | ||
224 | /// </summary> | ||
225 | /// <param name="request"></param> | ||
226 | /// <param name="path"></param> | ||
227 | /// <param name="param"></param> | ||
228 | /// <param name="httpRequest">HTTP request header object</param> | ||
229 | /// <param name="httpResponse">HTTP response header object</param> | ||
230 | /// <returns></returns> | ||
231 | public string ScriptTaskInventory(string request, string path, string param, | ||
232 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
233 | { | ||
234 | try | ||
235 | { | ||
236 | m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName); | ||
237 | //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); | ||
238 | |||
239 | Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
240 | LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); | ||
241 | LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest); | ||
242 | |||
243 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; | ||
244 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
245 | |||
246 | TaskInventoryScriptUpdater uploader = | ||
247 | new TaskInventoryScriptUpdater( | ||
248 | llsdUpdateRequest.item_id, | ||
249 | llsdUpdateRequest.task_id, | ||
250 | llsdUpdateRequest.is_script_running, | ||
251 | capsBase + uploaderPath, | ||
252 | m_HostCapsObj.HttpListener, | ||
253 | m_dumpAssetsToFile); | ||
254 | uploader.OnUpLoad += TaskScriptUpdated; | ||
255 | |||
256 | m_HostCapsObj.HttpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
257 | |||
258 | string protocol = "http://"; | ||
259 | |||
260 | if (m_HostCapsObj.SSLCaps) | ||
261 | protocol = "https://"; | ||
262 | |||
263 | string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + | ||
264 | uploaderPath; | ||
265 | |||
266 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | ||
267 | uploadResponse.uploader = uploaderURL; | ||
268 | uploadResponse.state = "upload"; | ||
269 | |||
270 | // m_log.InfoFormat("[CAPS]: " + | ||
271 | // "ScriptTaskInventory response: {0}", | ||
272 | // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); | ||
273 | |||
274 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | ||
275 | } | ||
276 | catch (Exception e) | ||
277 | { | ||
278 | m_log.Error("[CAPS]: " + e.ToString()); | ||
279 | } | ||
280 | |||
281 | return null; | ||
282 | } | ||
283 | |||
284 | /// <summary> | ||
285 | /// Called when new asset data for an agent inventory item update has been uploaded. | ||
286 | /// </summary> | ||
287 | /// <param name="itemID">Item to update</param> | ||
288 | /// <param name="primID">Prim containing item to update</param> | ||
289 | /// <param name="isScriptRunning">Signals whether the script to update is currently running</param> | ||
290 | /// <param name="data">New asset data</param> | ||
291 | public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors) | ||
292 | { | ||
293 | if (TaskScriptUpdatedCall != null) | ||
294 | { | ||
295 | ArrayList e = TaskScriptUpdatedCall(m_HostCapsObj.AgentID, itemID, primID, isScriptRunning, data); | ||
296 | foreach (Object item in e) | ||
297 | errors.Add(item); | ||
298 | } | ||
299 | } | ||
300 | |||
301 | public string UploadBakedTexture(string request, string path, | ||
302 | string param, OSHttpRequest httpRequest, | ||
303 | OSHttpResponse httpResponse) | ||
304 | { | ||
305 | try | ||
306 | { | ||
307 | // m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + | ||
308 | // m_regionName); | ||
309 | |||
310 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; | ||
311 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
312 | |||
313 | BakedTextureUploader uploader = | ||
314 | new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener); | ||
315 | uploader.OnUpLoad += BakedTextureUploaded; | ||
316 | |||
317 | m_HostCapsObj.HttpListener.AddStreamHandler( | ||
318 | new BinaryStreamHandler("POST", capsBase + uploaderPath, | ||
319 | uploader.uploaderCaps)); | ||
320 | |||
321 | string protocol = "http://"; | ||
322 | |||
323 | if (m_HostCapsObj.SSLCaps) | ||
324 | protocol = "https://"; | ||
325 | |||
326 | string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + | ||
327 | m_HostCapsObj.Port.ToString() + capsBase + uploaderPath; | ||
328 | |||
329 | LLSDAssetUploadResponse uploadResponse = | ||
330 | new LLSDAssetUploadResponse(); | ||
331 | uploadResponse.uploader = uploaderURL; | ||
332 | uploadResponse.state = "upload"; | ||
333 | |||
334 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | ||
335 | } | ||
336 | catch (Exception e) | ||
337 | { | ||
338 | m_log.Error("[CAPS]: " + e.ToString()); | ||
339 | } | ||
340 | |||
341 | return null; | ||
342 | } | ||
343 | |||
344 | public void BakedTextureUploaded(UUID assetID, byte[] data) | ||
345 | { | ||
346 | // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); | ||
347 | |||
348 | AssetBase asset; | ||
349 | asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString()); | ||
350 | asset.Data = data; | ||
351 | asset.Temporary = true; | ||
352 | asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are | ||
353 | m_assetService.Store(asset); | ||
354 | } | ||
355 | |||
356 | /// <summary> | ||
357 | /// Called when new asset data for an agent inventory item update has been uploaded. | ||
358 | /// </summary> | ||
359 | /// <param name="itemID">Item to update</param> | ||
360 | /// <param name="data">New asset data</param> | ||
361 | /// <returns></returns> | ||
362 | public UUID ItemUpdated(UUID itemID, byte[] data) | ||
363 | { | ||
364 | if (ItemUpdatedCall != null) | ||
365 | { | ||
366 | return ItemUpdatedCall(m_HostCapsObj.AgentID, itemID, data); | ||
367 | } | ||
368 | |||
369 | return UUID.Zero; | ||
370 | } | ||
371 | |||
372 | /// <summary> | ||
373 | /// | ||
374 | /// </summary> | ||
375 | /// <param name="llsdRequest"></param> | ||
376 | /// <returns></returns> | ||
377 | public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) | ||
378 | { | ||
379 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); | ||
380 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); | ||
381 | |||
382 | if (llsdRequest.asset_type == "texture" || | ||
383 | llsdRequest.asset_type == "animation" || | ||
384 | llsdRequest.asset_type == "sound") | ||
385 | { | ||
386 | IClientAPI client = null; | ||
387 | IScene scene = null; | ||
388 | if (GetClient != null) | ||
389 | { | ||
390 | client = GetClient(m_HostCapsObj.AgentID); | ||
391 | scene = client.Scene; | ||
392 | |||
393 | IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>(); | ||
394 | |||
395 | if (mm != null) | ||
396 | { | ||
397 | if (!mm.UploadCovered(client, mm.UploadCharge)) | ||
398 | { | ||
399 | if (client != null) | ||
400 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | ||
401 | |||
402 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | ||
403 | errorResponse.uploader = ""; | ||
404 | errorResponse.state = "error"; | ||
405 | return errorResponse; | ||
406 | } | ||
407 | } | ||
408 | } | ||
409 | } | ||
410 | |||
411 | string assetName = llsdRequest.name; | ||
412 | string assetDes = llsdRequest.description; | ||
413 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; | ||
414 | UUID newAsset = UUID.Random(); | ||
415 | UUID newInvItem = UUID.Random(); | ||
416 | UUID parentFolder = llsdRequest.folder_id; | ||
417 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
418 | |||
419 | AssetUploader uploader = | ||
420 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | ||
421 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); | ||
422 | m_HostCapsObj.HttpListener.AddStreamHandler( | ||
423 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
424 | |||
425 | string protocol = "http://"; | ||
426 | |||
427 | if (m_HostCapsObj.SSLCaps) | ||
428 | protocol = "https://"; | ||
429 | |||
430 | string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + | ||
431 | uploaderPath; | ||
432 | |||
433 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | ||
434 | uploadResponse.uploader = uploaderURL; | ||
435 | uploadResponse.state = "upload"; | ||
436 | uploader.OnUpLoad += UploadCompleteHandler; | ||
437 | return uploadResponse; | ||
438 | } | ||
439 | |||
440 | /// <summary> | ||
441 | /// | ||
442 | /// </summary> | ||
443 | /// <param name="assetID"></param> | ||
444 | /// <param name="inventoryItem"></param> | ||
445 | /// <param name="data"></param> | ||
446 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | ||
447 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | ||
448 | string assetType) | ||
449 | { | ||
450 | sbyte assType = 0; | ||
451 | sbyte inType = 0; | ||
452 | |||
453 | if (inventoryType == "sound") | ||
454 | { | ||
455 | inType = 1; | ||
456 | assType = 1; | ||
457 | } | ||
458 | else if (inventoryType == "animation") | ||
459 | { | ||
460 | inType = 19; | ||
461 | assType = 20; | ||
462 | } | ||
463 | else if (inventoryType == "wearable") | ||
464 | { | ||
465 | inType = 18; | ||
466 | switch (assetType) | ||
467 | { | ||
468 | case "bodypart": | ||
469 | assType = 13; | ||
470 | break; | ||
471 | case "clothing": | ||
472 | assType = 5; | ||
473 | break; | ||
474 | } | ||
475 | } | ||
476 | |||
477 | AssetBase asset; | ||
478 | asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString()); | ||
479 | asset.Data = data; | ||
480 | if (AddNewAsset != null) | ||
481 | AddNewAsset(asset); | ||
482 | else if (m_assetService != null) | ||
483 | m_assetService.Store(asset); | ||
484 | |||
485 | InventoryItemBase item = new InventoryItemBase(); | ||
486 | item.Owner = m_HostCapsObj.AgentID; | ||
487 | item.CreatorId = m_HostCapsObj.AgentID.ToString(); | ||
488 | item.CreatorData = String.Empty; | ||
489 | item.ID = inventoryItem; | ||
490 | item.AssetID = asset.FullID; | ||
491 | item.Description = assetDescription; | ||
492 | item.Name = assetName; | ||
493 | item.AssetType = assType; | ||
494 | item.InvType = inType; | ||
495 | item.Folder = parentFolder; | ||
496 | item.CurrentPermissions = (uint)PermissionMask.All; | ||
497 | item.BasePermissions = (uint)PermissionMask.All; | ||
498 | item.EveryOnePermissions = 0; | ||
499 | item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); | ||
500 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
501 | |||
502 | if (AddNewInventoryItem != null) | ||
503 | { | ||
504 | AddNewInventoryItem(m_HostCapsObj.AgentID, item); | ||
505 | } | ||
506 | } | ||
507 | |||
508 | /// <summary> | ||
509 | /// Processes a fetch inventory request and sends the reply | ||
510 | |||
511 | /// </summary> | ||
512 | /// <param name="request"></param> | ||
513 | /// <param name="path"></param> | ||
514 | /// <param name="param"></param> | ||
515 | /// <returns></returns> | ||
516 | // Request is like: | ||
517 | //<llsd> | ||
518 | // <map><key>folders</key> | ||
519 | // <array> | ||
520 | // <map> | ||
521 | // <key>fetch-folders</key><boolean>1</boolean><key>fetch-items</key><boolean>1</boolean><key>folder-id</key><uuid>8e1e3a30-b9bf-11dc-95ff-0800200c9a66</uuid><key>owner-id</key><uuid>11111111-1111-0000-0000-000100bba000</uuid><key>sort-order</key><integer>1</integer> | ||
522 | // </map> | ||
523 | // </array> | ||
524 | // </map> | ||
525 | //</llsd> | ||
526 | // | ||
527 | // multiple fetch-folder maps are allowed within the larger folders map. | ||
528 | public string FetchInventoryRequest(string request, string path, string param) | ||
529 | { | ||
530 | // string unmodifiedRequest = request.ToString(); | ||
531 | |||
532 | //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); | ||
533 | m_log.Debug("[CAPS]: Inventory Request in region: " + m_regionName); | ||
534 | |||
535 | Hashtable hash = new Hashtable(); | ||
536 | try | ||
537 | { | ||
538 | hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
539 | } | ||
540 | catch (LLSD.LLSDParseException pe) | ||
541 | { | ||
542 | m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); | ||
543 | m_log.Error("Request: " + request.ToString()); | ||
544 | } | ||
545 | |||
546 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | ||
547 | |||
548 | string response = ""; | ||
549 | |||
550 | for (int i = 0; i < foldersrequested.Count; i++) | ||
551 | { | ||
552 | string inventoryitemstr = ""; | ||
553 | Hashtable inventoryhash = (Hashtable)foldersrequested[i]; | ||
554 | |||
555 | LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); | ||
556 | LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); | ||
557 | LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); | ||
558 | |||
559 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); | ||
560 | inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); | ||
561 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | ||
562 | |||
563 | response += inventoryitemstr; | ||
564 | } | ||
565 | |||
566 | if (response.Length == 0) | ||
567 | { | ||
568 | // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. | ||
569 | // Therefore, I'm concluding that the client only has so many threads available to do requests | ||
570 | // and when a thread stalls.. is stays stalled. | ||
571 | // Therefore we need to return something valid | ||
572 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
573 | } | ||
574 | else | ||
575 | { | ||
576 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
577 | } | ||
578 | |||
579 | //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request with following xml"); | ||
580 | //m_log.Debug(Util.GetFormattedXml(response)); | ||
581 | |||
582 | return response; | ||
583 | } | ||
584 | |||
585 | public string FetchInventoryDescendentsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
586 | { | ||
587 | // nasty temporary hack here, the linden client falsely | ||
588 | // identifies the uuid 00000000-0000-0000-0000-000000000000 | ||
589 | // as a string which breaks us | ||
590 | // | ||
591 | // correctly mark it as a uuid | ||
592 | // | ||
593 | request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); | ||
594 | |||
595 | // another hack <integer>1</integer> results in a | ||
596 | // System.ArgumentException: Object type System.Int32 cannot | ||
597 | // be converted to target type: System.Boolean | ||
598 | // | ||
599 | request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); | ||
600 | request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); | ||
601 | |||
602 | Hashtable hash = new Hashtable(); | ||
603 | try | ||
604 | { | ||
605 | hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
606 | } | ||
607 | catch (LLSD.LLSDParseException pe) | ||
608 | { | ||
609 | m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); | ||
610 | m_log.Error("Request: " + request.ToString()); | ||
611 | } | ||
612 | |||
613 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | ||
614 | |||
615 | string response = ""; | ||
616 | lock (m_fetchLock) | ||
617 | { | ||
618 | for (int i = 0; i < foldersrequested.Count; i++) | ||
619 | { | ||
620 | string inventoryitemstr = ""; | ||
621 | Hashtable inventoryhash = (Hashtable)foldersrequested[i]; | ||
622 | |||
623 | LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); | ||
624 | |||
625 | try | ||
626 | { | ||
627 | LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); | ||
628 | } | ||
629 | catch (Exception e) | ||
630 | { | ||
631 | m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); | ||
632 | } | ||
633 | LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); | ||
634 | |||
635 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); | ||
636 | inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); | ||
637 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | ||
638 | |||
639 | response += inventoryitemstr; | ||
640 | } | ||
641 | |||
642 | |||
643 | if (response.Length == 0) | ||
644 | { | ||
645 | // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. | ||
646 | // Therefore, I'm concluding that the client only has so many threads available to do requests | ||
647 | // and when a thread stalls.. is stays stalled. | ||
648 | // Therefore we need to return something valid | ||
649 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
650 | } | ||
651 | else | ||
652 | { | ||
653 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
654 | } | ||
655 | |||
656 | //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); | ||
657 | //m_log.Debug("[CAPS] "+response); | ||
658 | |||
659 | } | ||
660 | return response; | ||
661 | } | ||
662 | |||
663 | |||
664 | |||
665 | /// <summary> | ||
666 | /// Construct an LLSD reply packet to a CAPS inventory request | ||
667 | /// </summary> | ||
668 | /// <param name="invFetch"></param> | ||
669 | /// <returns></returns> | ||
670 | private LLSDInventoryDescendents FetchInventoryReply(LLSDFetchInventoryDescendents invFetch) | ||
671 | { | ||
672 | LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); | ||
673 | LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); | ||
674 | contents.agent_id = m_HostCapsObj.AgentID; | ||
675 | contents.owner_id = invFetch.owner_id; | ||
676 | contents.folder_id = invFetch.folder_id; | ||
677 | |||
678 | reply.folders.Array.Add(contents); | ||
679 | InventoryCollection inv = new InventoryCollection(); | ||
680 | inv.Folders = new List<InventoryFolderBase>(); | ||
681 | inv.Items = new List<InventoryItemBase>(); | ||
682 | int version = 0; | ||
683 | if (CAPSFetchInventoryDescendents != null) | ||
684 | { | ||
685 | inv = CAPSFetchInventoryDescendents(m_HostCapsObj.AgentID, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); | ||
686 | } | ||
687 | |||
688 | if (inv.Folders != null) | ||
689 | { | ||
690 | foreach (InventoryFolderBase invFolder in inv.Folders) | ||
691 | { | ||
692 | contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); | ||
693 | } | ||
694 | } | ||
695 | |||
696 | if (inv.Items != null) | ||
697 | { | ||
698 | foreach (InventoryItemBase invItem in inv.Items) | ||
699 | { | ||
700 | contents.items.Array.Add(ConvertInventoryItem(invItem)); | ||
701 | } | ||
702 | } | ||
703 | |||
704 | contents.descendents = contents.items.Array.Count + contents.categories.Array.Count; | ||
705 | contents.version = version; | ||
706 | |||
707 | return reply; | ||
708 | } | ||
709 | |||
710 | /// <summary> | ||
711 | /// Convert an internal inventory folder object into an LLSD object. | ||
712 | /// </summary> | ||
713 | /// <param name="invFolder"></param> | ||
714 | /// <returns></returns> | ||
715 | private LLSDInventoryFolder ConvertInventoryFolder(InventoryFolderBase invFolder) | ||
716 | { | ||
717 | LLSDInventoryFolder llsdFolder = new LLSDInventoryFolder(); | ||
718 | llsdFolder.folder_id = invFolder.ID; | ||
719 | llsdFolder.parent_id = invFolder.ParentID; | ||
720 | llsdFolder.name = invFolder.Name; | ||
721 | if (invFolder.Type < 0 || invFolder.Type >= TaskInventoryItem.Types.Length) | ||
722 | llsdFolder.type = "-1"; | ||
723 | else | ||
724 | llsdFolder.type = TaskInventoryItem.Types[invFolder.Type]; | ||
725 | llsdFolder.preferred_type = "-1"; | ||
726 | |||
727 | return llsdFolder; | ||
728 | } | ||
729 | |||
730 | /// <summary> | ||
731 | /// Convert an internal inventory item object into an LLSD object. | ||
732 | /// </summary> | ||
733 | /// <param name="invItem"></param> | ||
734 | /// <returns></returns> | ||
735 | private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) | ||
736 | { | ||
737 | LLSDInventoryItem llsdItem = new LLSDInventoryItem(); | ||
738 | llsdItem.asset_id = invItem.AssetID; | ||
739 | llsdItem.created_at = invItem.CreationDate; | ||
740 | llsdItem.desc = invItem.Description; | ||
741 | llsdItem.flags = (int)invItem.Flags; | ||
742 | llsdItem.item_id = invItem.ID; | ||
743 | llsdItem.name = invItem.Name; | ||
744 | llsdItem.parent_id = invItem.Folder; | ||
745 | try | ||
746 | { | ||
747 | // TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions. | ||
748 | llsdItem.type = TaskInventoryItem.Types[invItem.AssetType]; | ||
749 | llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType]; | ||
750 | } | ||
751 | catch (Exception e) | ||
752 | { | ||
753 | m_log.Error("[CAPS]: Problem setting asset/inventory type while converting inventory item " + invItem.Name + " to LLSD:", e); | ||
754 | } | ||
755 | llsdItem.permissions = new LLSDPermissions(); | ||
756 | llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; | ||
757 | llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; | ||
758 | llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; | ||
759 | llsdItem.permissions.group_id = invItem.GroupID; | ||
760 | llsdItem.permissions.group_mask = (int)invItem.GroupPermissions; | ||
761 | llsdItem.permissions.is_owner_group = invItem.GroupOwned; | ||
762 | llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; | ||
763 | llsdItem.permissions.owner_id = m_HostCapsObj.AgentID; | ||
764 | llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; | ||
765 | llsdItem.sale_info = new LLSDSaleInfo(); | ||
766 | llsdItem.sale_info.sale_price = invItem.SalePrice; | ||
767 | switch (invItem.SaleType) | ||
768 | { | ||
769 | default: | ||
770 | llsdItem.sale_info.sale_type = "not"; | ||
771 | break; | ||
772 | case 1: | ||
773 | llsdItem.sale_info.sale_type = "original"; | ||
774 | break; | ||
775 | case 2: | ||
776 | llsdItem.sale_info.sale_type = "copy"; | ||
777 | break; | ||
778 | case 3: | ||
779 | llsdItem.sale_info.sale_type = "contents"; | ||
780 | break; | ||
781 | } | ||
782 | |||
783 | return llsdItem; | ||
784 | } | ||
785 | |||
786 | /// <summary> | ||
787 | /// | ||
788 | /// </summary> | ||
789 | /// <param name="mapReq"></param> | ||
790 | /// <returns></returns> | ||
791 | public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) | ||
792 | { | ||
793 | m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName); | ||
794 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | ||
795 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); | ||
796 | return mapResponse; | ||
797 | } | ||
798 | |||
799 | /// <summary> | ||
800 | /// | ||
801 | /// </summary> | ||
802 | /// <returns></returns> | ||
803 | protected static OSDMapLayer GetOSDMapLayerResponse() | ||
804 | { | ||
805 | OSDMapLayer mapLayer = new OSDMapLayer(); | ||
806 | mapLayer.Right = 5000; | ||
807 | mapLayer.Top = 5000; | ||
808 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); | ||
809 | |||
810 | return mapLayer; | ||
811 | } | ||
812 | |||
813 | /// <summary> | ||
814 | /// | ||
815 | /// </summary> | ||
816 | /// <param name="request"></param> | ||
817 | /// <param name="path"></param> | ||
818 | /// <param name="param"></param> | ||
819 | /// <returns></returns> | ||
820 | public string RequestTexture(string request, string path, string param) | ||
821 | { | ||
822 | m_log.Debug("texture request " + request); | ||
823 | // Needs implementing (added to remove compiler warning) | ||
824 | return String.Empty; | ||
825 | } | ||
826 | |||
827 | |||
828 | /// <summary> | ||
829 | /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. | ||
830 | /// </summary> | ||
831 | /// <param name="request"></param> | ||
832 | /// <param name="path"></param> | ||
833 | /// <param name="param"></param> | ||
834 | /// <returns></returns> | ||
835 | public string NoteCardAgentInventory(string request, string path, string param, | ||
836 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
837 | { | ||
838 | //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request); | ||
839 | //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request); | ||
840 | |||
841 | //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); | ||
842 | Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
843 | LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); | ||
844 | LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); | ||
845 | |||
846 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; | ||
847 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
848 | |||
849 | ItemUpdater uploader = | ||
850 | new ItemUpdater(llsdRequest.item_id, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); | ||
851 | uploader.OnUpLoad += ItemUpdated; | ||
852 | |||
853 | m_HostCapsObj.HttpListener.AddStreamHandler( | ||
854 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
855 | |||
856 | string protocol = "http://"; | ||
857 | |||
858 | if (m_HostCapsObj.SSLCaps) | ||
859 | protocol = "https://"; | ||
860 | |||
861 | string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + | ||
862 | uploaderPath; | ||
863 | |||
864 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | ||
865 | uploadResponse.uploader = uploaderURL; | ||
866 | uploadResponse.state = "upload"; | ||
867 | |||
868 | // m_log.InfoFormat("[CAPS]: " + | ||
869 | // "NoteCardAgentInventory response: {0}", | ||
870 | // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); | ||
871 | |||
872 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | ||
873 | } | ||
874 | } | ||
875 | |||
876 | public class AssetUploader | ||
877 | { | ||
878 | public event UpLoadedAsset OnUpLoad; | ||
879 | private UpLoadedAsset handlerUpLoad = null; | ||
880 | |||
881 | private string uploaderPath = String.Empty; | ||
882 | private UUID newAssetID; | ||
883 | private UUID inventoryItemID; | ||
884 | private UUID parentFolder; | ||
885 | private IHttpServer httpListener; | ||
886 | private bool m_dumpAssetsToFile; | ||
887 | private string m_assetName = String.Empty; | ||
888 | private string m_assetDes = String.Empty; | ||
889 | |||
890 | private string m_invType = String.Empty; | ||
891 | private string m_assetType = String.Empty; | ||
892 | |||
893 | public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, | ||
894 | UUID parentFolderID, string invType, string assetType, string path, | ||
895 | IHttpServer httpServer, bool dumpAssetsToFile) | ||
896 | { | ||
897 | m_assetName = assetName; | ||
898 | m_assetDes = description; | ||
899 | newAssetID = assetID; | ||
900 | inventoryItemID = inventoryItem; | ||
901 | uploaderPath = path; | ||
902 | httpListener = httpServer; | ||
903 | parentFolder = parentFolderID; | ||
904 | m_assetType = assetType; | ||
905 | m_invType = invType; | ||
906 | m_dumpAssetsToFile = dumpAssetsToFile; | ||
907 | } | ||
908 | |||
909 | /// <summary> | ||
910 | /// | ||
911 | /// </summary> | ||
912 | /// <param name="data"></param> | ||
913 | /// <param name="path"></param> | ||
914 | /// <param name="param"></param> | ||
915 | /// <returns></returns> | ||
916 | public string uploaderCaps(byte[] data, string path, string param) | ||
917 | { | ||
918 | UUID inv = inventoryItemID; | ||
919 | string res = String.Empty; | ||
920 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | ||
921 | uploadComplete.new_asset = newAssetID.ToString(); | ||
922 | uploadComplete.new_inventory_item = inv; | ||
923 | uploadComplete.state = "complete"; | ||
924 | |||
925 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
926 | |||
927 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
928 | |||
929 | // TODO: probably make this a better set of extensions here | ||
930 | string extension = ".jp2"; | ||
931 | if (m_invType != "image") | ||
932 | { | ||
933 | extension = ".dat"; | ||
934 | } | ||
935 | |||
936 | if (m_dumpAssetsToFile) | ||
937 | { | ||
938 | SaveAssetToFile(m_assetName + extension, data); | ||
939 | } | ||
940 | handlerUpLoad = OnUpLoad; | ||
941 | if (handlerUpLoad != null) | ||
942 | { | ||
943 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); | ||
944 | } | ||
945 | |||
946 | return res; | ||
947 | } | ||
948 | ///Left this in and commented in case there are unforseen issues | ||
949 | //private void SaveAssetToFile(string filename, byte[] data) | ||
950 | //{ | ||
951 | // FileStream fs = File.Create(filename); | ||
952 | // BinaryWriter bw = new BinaryWriter(fs); | ||
953 | // bw.Write(data); | ||
954 | // bw.Close(); | ||
955 | // fs.Close(); | ||
956 | //} | ||
957 | private static void SaveAssetToFile(string filename, byte[] data) | ||
958 | { | ||
959 | string assetPath = "UserAssets"; | ||
960 | if (!Directory.Exists(assetPath)) | ||
961 | { | ||
962 | Directory.CreateDirectory(assetPath); | ||
963 | } | ||
964 | FileStream fs = File.Create(Path.Combine(assetPath, Util.safeFileName(filename))); | ||
965 | BinaryWriter bw = new BinaryWriter(fs); | ||
966 | bw.Write(data); | ||
967 | bw.Close(); | ||
968 | fs.Close(); | ||
969 | } | ||
970 | } | ||
971 | |||
972 | /// <summary> | ||
973 | /// This class is a callback invoked when a client sends asset data to | ||
974 | /// an agent inventory notecard update url | ||
975 | /// </summary> | ||
976 | public class ItemUpdater | ||
977 | { | ||
978 | public event UpdateItem OnUpLoad; | ||
979 | |||
980 | private UpdateItem handlerUpdateItem = null; | ||
981 | |||
982 | private string uploaderPath = String.Empty; | ||
983 | private UUID inventoryItemID; | ||
984 | private IHttpServer httpListener; | ||
985 | private bool m_dumpAssetToFile; | ||
986 | |||
987 | public ItemUpdater(UUID inventoryItem, string path, IHttpServer httpServer, bool dumpAssetToFile) | ||
988 | { | ||
989 | m_dumpAssetToFile = dumpAssetToFile; | ||
990 | |||
991 | inventoryItemID = inventoryItem; | ||
992 | uploaderPath = path; | ||
993 | httpListener = httpServer; | ||
994 | } | ||
995 | |||
996 | /// <summary> | ||
997 | /// | ||
998 | /// </summary> | ||
999 | /// <param name="data"></param> | ||
1000 | /// <param name="path"></param> | ||
1001 | /// <param name="param"></param> | ||
1002 | /// <returns></returns> | ||
1003 | public string uploaderCaps(byte[] data, string path, string param) | ||
1004 | { | ||
1005 | UUID inv = inventoryItemID; | ||
1006 | string res = String.Empty; | ||
1007 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | ||
1008 | UUID assetID = UUID.Zero; | ||
1009 | handlerUpdateItem = OnUpLoad; | ||
1010 | if (handlerUpdateItem != null) | ||
1011 | { | ||
1012 | assetID = handlerUpdateItem(inv, data); | ||
1013 | } | ||
1014 | |||
1015 | uploadComplete.new_asset = assetID.ToString(); | ||
1016 | uploadComplete.new_inventory_item = inv; | ||
1017 | uploadComplete.state = "complete"; | ||
1018 | |||
1019 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1020 | |||
1021 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1022 | |||
1023 | if (m_dumpAssetToFile) | ||
1024 | { | ||
1025 | SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); | ||
1026 | } | ||
1027 | |||
1028 | return res; | ||
1029 | } | ||
1030 | ///Left this in and commented in case there are unforseen issues | ||
1031 | //private void SaveAssetToFile(string filename, byte[] data) | ||
1032 | //{ | ||
1033 | // FileStream fs = File.Create(filename); | ||
1034 | // BinaryWriter bw = new BinaryWriter(fs); | ||
1035 | // bw.Write(data); | ||
1036 | // bw.Close(); | ||
1037 | // fs.Close(); | ||
1038 | //} | ||
1039 | private static void SaveAssetToFile(string filename, byte[] data) | ||
1040 | { | ||
1041 | string assetPath = "UserAssets"; | ||
1042 | if (!Directory.Exists(assetPath)) | ||
1043 | { | ||
1044 | Directory.CreateDirectory(assetPath); | ||
1045 | } | ||
1046 | FileStream fs = File.Create(Path.Combine(assetPath, filename)); | ||
1047 | BinaryWriter bw = new BinaryWriter(fs); | ||
1048 | bw.Write(data); | ||
1049 | bw.Close(); | ||
1050 | fs.Close(); | ||
1051 | } | ||
1052 | } | ||
1053 | |||
1054 | /// <summary> | ||
1055 | /// This class is a callback invoked when a client sends asset data to | ||
1056 | /// a task inventory script update url | ||
1057 | /// </summary> | ||
1058 | public class TaskInventoryScriptUpdater | ||
1059 | { | ||
1060 | private static readonly ILog m_log = | ||
1061 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
1062 | |||
1063 | public event UpdateTaskScript OnUpLoad; | ||
1064 | |||
1065 | private UpdateTaskScript handlerUpdateTaskScript = null; | ||
1066 | |||
1067 | private string uploaderPath = String.Empty; | ||
1068 | private UUID inventoryItemID; | ||
1069 | private UUID primID; | ||
1070 | private bool isScriptRunning; | ||
1071 | private IHttpServer httpListener; | ||
1072 | private bool m_dumpAssetToFile; | ||
1073 | |||
1074 | public TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning, | ||
1075 | string path, IHttpServer httpServer, bool dumpAssetToFile) | ||
1076 | { | ||
1077 | m_dumpAssetToFile = dumpAssetToFile; | ||
1078 | |||
1079 | this.inventoryItemID = inventoryItemID; | ||
1080 | this.primID = primID; | ||
1081 | |||
1082 | // This comes in over the packet as an integer, but actually appears to be treated as a bool | ||
1083 | this.isScriptRunning = (0 == isScriptRunning ? false : true); | ||
1084 | |||
1085 | uploaderPath = path; | ||
1086 | httpListener = httpServer; | ||
1087 | } | ||
1088 | |||
1089 | /// <summary> | ||
1090 | /// | ||
1091 | /// </summary> | ||
1092 | /// <param name="data"></param> | ||
1093 | /// <param name="path"></param> | ||
1094 | /// <param name="param"></param> | ||
1095 | /// <returns></returns> | ||
1096 | public string uploaderCaps(byte[] data, string path, string param) | ||
1097 | { | ||
1098 | try | ||
1099 | { | ||
1100 | // m_log.InfoFormat("[CAPS]: " + | ||
1101 | // "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", | ||
1102 | // data, path, param)); | ||
1103 | |||
1104 | string res = String.Empty; | ||
1105 | LLSDTaskScriptUploadComplete uploadComplete = new LLSDTaskScriptUploadComplete(); | ||
1106 | |||
1107 | ArrayList errors = new ArrayList(); | ||
1108 | handlerUpdateTaskScript = OnUpLoad; | ||
1109 | if (handlerUpdateTaskScript != null) | ||
1110 | { | ||
1111 | handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data, ref errors); | ||
1112 | } | ||
1113 | |||
1114 | uploadComplete.new_asset = inventoryItemID; | ||
1115 | uploadComplete.compiled = errors.Count > 0 ? false : true; | ||
1116 | uploadComplete.state = "complete"; | ||
1117 | uploadComplete.errors = new OSDArray(); | ||
1118 | uploadComplete.errors.Array = errors; | ||
1119 | |||
1120 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1121 | |||
1122 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1123 | |||
1124 | if (m_dumpAssetToFile) | ||
1125 | { | ||
1126 | SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); | ||
1127 | } | ||
1128 | |||
1129 | // m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); | ||
1130 | |||
1131 | return res; | ||
1132 | } | ||
1133 | catch (Exception e) | ||
1134 | { | ||
1135 | m_log.Error("[CAPS]: " + e.ToString()); | ||
1136 | } | ||
1137 | |||
1138 | // XXX Maybe this should be some meaningful error packet | ||
1139 | return null; | ||
1140 | } | ||
1141 | ///Left this in and commented in case there are unforseen issues | ||
1142 | //private void SaveAssetToFile(string filename, byte[] data) | ||
1143 | //{ | ||
1144 | // FileStream fs = File.Create(filename); | ||
1145 | // BinaryWriter bw = new BinaryWriter(fs); | ||
1146 | // bw.Write(data); | ||
1147 | // bw.Close(); | ||
1148 | // fs.Close(); | ||
1149 | //} | ||
1150 | private static void SaveAssetToFile(string filename, byte[] data) | ||
1151 | { | ||
1152 | string assetPath = "UserAssets"; | ||
1153 | if (!Directory.Exists(assetPath)) | ||
1154 | { | ||
1155 | Directory.CreateDirectory(assetPath); | ||
1156 | } | ||
1157 | FileStream fs = File.Create(Path.Combine(assetPath, filename)); | ||
1158 | BinaryWriter bw = new BinaryWriter(fs); | ||
1159 | bw.Write(data); | ||
1160 | bw.Close(); | ||
1161 | fs.Close(); | ||
1162 | } | ||
1163 | } | ||
1164 | |||
1165 | public class BakedTextureUploader | ||
1166 | { | ||
1167 | public event UploadedBakedTexture OnUpLoad; | ||
1168 | private UploadedBakedTexture handlerUpLoad = null; | ||
1169 | |||
1170 | private string uploaderPath = String.Empty; | ||
1171 | private UUID newAssetID; | ||
1172 | private IHttpServer httpListener; | ||
1173 | |||
1174 | public BakedTextureUploader(string path, IHttpServer httpServer) | ||
1175 | { | ||
1176 | newAssetID = UUID.Random(); | ||
1177 | uploaderPath = path; | ||
1178 | httpListener = httpServer; | ||
1179 | // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); | ||
1180 | } | ||
1181 | |||
1182 | /// <summary> | ||
1183 | /// | ||
1184 | /// </summary> | ||
1185 | /// <param name="data"></param> | ||
1186 | /// <param name="path"></param> | ||
1187 | /// <param name="param"></param> | ||
1188 | /// <returns></returns> | ||
1189 | public string uploaderCaps(byte[] data, string path, string param) | ||
1190 | { | ||
1191 | handlerUpLoad = OnUpLoad; | ||
1192 | if (handlerUpLoad != null) | ||
1193 | { | ||
1194 | Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); }); | ||
1195 | } | ||
1196 | |||
1197 | string res = String.Empty; | ||
1198 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | ||
1199 | uploadComplete.new_asset = newAssetID.ToString(); | ||
1200 | uploadComplete.new_inventory_item = UUID.Zero; | ||
1201 | uploadComplete.state = "complete"; | ||
1202 | |||
1203 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1204 | |||
1205 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1206 | |||
1207 | // m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID); | ||
1208 | |||
1209 | return res; | ||
1210 | } | ||
1211 | } | ||
1212 | |||
1213 | } | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs new file mode 100644 index 0000000..14160ae --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs | |||
@@ -0,0 +1,91 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
35 | using Mono.Addins; | ||
36 | |||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.Framework; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
42 | |||
43 | [assembly: Addin("LindenCaps", "0.1")] | ||
44 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
45 | namespace OpenSim.Region.ClientStack.Linden | ||
46 | { | ||
47 | |||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
49 | public class BunchOfCapsModule : INonSharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = | ||
52 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | private Scene m_Scene; | ||
55 | |||
56 | #region INonSharedRegionModule | ||
57 | |||
58 | public string Name { get { return "BunchOfCapsModule"; } } | ||
59 | |||
60 | public Type ReplaceableInterface { get { return null; } } | ||
61 | |||
62 | public void Initialise(IConfigSource source) | ||
63 | { | ||
64 | } | ||
65 | |||
66 | public void Close() { } | ||
67 | |||
68 | public void AddRegion(Scene scene) | ||
69 | { | ||
70 | m_Scene = scene; | ||
71 | m_Scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
72 | } | ||
73 | |||
74 | public void RemoveRegion(Scene scene) | ||
75 | { | ||
76 | } | ||
77 | |||
78 | public void RegionLoaded(Scene scene) | ||
79 | { | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() { } | ||
83 | #endregion | ||
84 | |||
85 | private void OnRegisterCaps(UUID agentID, Caps caps) | ||
86 | { | ||
87 | new BunchOfCaps(m_Scene, caps); | ||
88 | } | ||
89 | |||
90 | } | ||
91 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 05fe3ee..4a8bb53 100644 --- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -33,6 +33,7 @@ using System.Reflection; | |||
33 | using System.Threading; | 33 | using System.Threading; |
34 | using log4net; | 34 | using log4net; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using Mono.Addins; | ||
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenMetaverse.Messages.Linden; | 38 | using OpenMetaverse.Messages.Linden; |
38 | using OpenMetaverse.Packets; | 39 | using OpenMetaverse.Packets; |
@@ -45,7 +46,7 @@ using OpenSim.Region.Framework.Scenes; | |||
45 | using BlockingLLSDQueue = OpenSim.Framework.BlockingQueue<OpenMetaverse.StructuredData.OSD>; | 46 | using BlockingLLSDQueue = OpenSim.Framework.BlockingQueue<OpenMetaverse.StructuredData.OSD>; |
46 | using Caps=OpenSim.Framework.Capabilities.Caps; | 47 | using Caps=OpenSim.Framework.Capabilities.Caps; |
47 | 48 | ||
48 | namespace OpenSim.Region.CoreModules.Framework.EventQueue | 49 | namespace OpenSim.Region.ClientStack.Linden |
49 | { | 50 | { |
50 | public struct QueueItem | 51 | public struct QueueItem |
51 | { | 52 | { |
@@ -53,6 +54,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
53 | public OSDMap body; | 54 | public OSDMap body; |
54 | } | 55 | } |
55 | 56 | ||
57 | //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
56 | public class EventQueueGetModule : IEventQueue, IRegionModule | 58 | public class EventQueueGetModule : IEventQueue, IRegionModule |
57 | { | 59 | { |
58 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 60 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -520,7 +522,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
520 | } | 522 | } |
521 | if (AvatarID != UUID.Zero) | 523 | if (AvatarID != UUID.Zero) |
522 | { | 524 | { |
523 | return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID)); | 525 | return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); |
524 | } | 526 | } |
525 | else | 527 | else |
526 | { | 528 | { |
@@ -715,5 +717,15 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
715 | OSD item = EventQueueHelper.PlacesQuery(groupUpdate); | 717 | OSD item = EventQueueHelper.PlacesQuery(groupUpdate); |
716 | Enqueue(item, avatarID); | 718 | Enqueue(item, avatarID); |
717 | } | 719 | } |
720 | |||
721 | public OSD ScriptRunningEvent(UUID objectID, UUID itemID, bool running, bool mono) | ||
722 | { | ||
723 | return EventQueueHelper.ScriptRunningReplyEvent(objectID, itemID, running, mono); | ||
724 | } | ||
725 | |||
726 | public OSD BuildEvent(string eventName, OSD eventBody) | ||
727 | { | ||
728 | return EventQueueHelper.BuildEvent(eventName, eventBody); | ||
729 | } | ||
718 | } | 730 | } |
719 | } | 731 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 0d7d16a..3f49aba 100644 --- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | |||
@@ -32,7 +32,7 @@ using OpenMetaverse.Packets; | |||
32 | using OpenMetaverse.StructuredData; | 32 | using OpenMetaverse.StructuredData; |
33 | using OpenMetaverse.Messages.Linden; | 33 | using OpenMetaverse.Messages.Linden; |
34 | 34 | ||
35 | namespace OpenSim.Region.CoreModules.Framework.EventQueue | 35 | namespace OpenSim.Region.ClientStack.Linden |
36 | { | 36 | { |
37 | public class EventQueueHelper | 37 | public class EventQueueHelper |
38 | { | 38 | { |
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
61 | // return result; | 61 | // return result; |
62 | // } | 62 | // } |
63 | 63 | ||
64 | public static OSD buildEvent(string eventName, OSD eventBody) | 64 | public static OSD BuildEvent(string eventName, OSD eventBody) |
65 | { | 65 | { |
66 | OSDMap llsdEvent = new OSDMap(2); | 66 | OSDMap llsdEvent = new OSDMap(2); |
67 | llsdEvent.Add("message", new OSDString(eventName)); | 67 | llsdEvent.Add("message", new OSDString(eventName)); |
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
84 | OSDMap llsdBody = new OSDMap(1); | 84 | OSDMap llsdBody = new OSDMap(1); |
85 | llsdBody.Add("SimulatorInfo", arr); | 85 | llsdBody.Add("SimulatorInfo", arr); |
86 | 86 | ||
87 | return buildEvent("EnableSimulator", llsdBody); | 87 | return BuildEvent("EnableSimulator", llsdBody); |
88 | } | 88 | } |
89 | 89 | ||
90 | public static OSD DisableSimulator(ulong handle) | 90 | public static OSD DisableSimulator(ulong handle) |
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
99 | OSDMap llsdBody = new OSDMap(0); | 99 | OSDMap llsdBody = new OSDMap(0); |
100 | //llsdBody.Add("SimulatorInfo", arr); | 100 | //llsdBody.Add("SimulatorInfo", arr); |
101 | 101 | ||
102 | return buildEvent("DisableSimulator", llsdBody); | 102 | return BuildEvent("DisableSimulator", llsdBody); |
103 | } | 103 | } |
104 | 104 | ||
105 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 105 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
@@ -144,7 +144,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
144 | llsdBody.Add("AgentData", agentDataArr); | 144 | llsdBody.Add("AgentData", agentDataArr); |
145 | llsdBody.Add("RegionData", regionDataArr); | 145 | llsdBody.Add("RegionData", regionDataArr); |
146 | 146 | ||
147 | return buildEvent("CrossedRegion", llsdBody); | 147 | return BuildEvent("CrossedRegion", llsdBody); |
148 | } | 148 | } |
149 | 149 | ||
150 | public static OSD TeleportFinishEvent( | 150 | public static OSD TeleportFinishEvent( |
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
167 | OSDMap body = new OSDMap(); | 167 | OSDMap body = new OSDMap(); |
168 | body.Add("Info", infoArr); | 168 | body.Add("Info", infoArr); |
169 | 169 | ||
170 | return buildEvent("TeleportFinish", body); | 170 | return BuildEvent("TeleportFinish", body); |
171 | } | 171 | } |
172 | 172 | ||
173 | public static OSD ScriptRunningReplyEvent(UUID objectID, UUID itemID, bool running, bool mono) | 173 | public static OSD ScriptRunningReplyEvent(UUID objectID, UUID itemID, bool running, bool mono) |
@@ -184,7 +184,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
184 | OSDMap body = new OSDMap(); | 184 | OSDMap body = new OSDMap(); |
185 | body.Add("Script", scriptArr); | 185 | body.Add("Script", scriptArr); |
186 | 186 | ||
187 | return buildEvent("ScriptRunningReply", body); | 187 | return BuildEvent("ScriptRunningReply", body); |
188 | } | 188 | } |
189 | 189 | ||
190 | public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap) | 190 | public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap) |
@@ -194,12 +194,12 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
194 | body.Add("sim-ip-and-port", new OSDString(simIpAndPort)); | 194 | body.Add("sim-ip-and-port", new OSDString(simIpAndPort)); |
195 | body.Add("seed-capability", new OSDString(seedcap)); | 195 | body.Add("seed-capability", new OSDString(seedcap)); |
196 | 196 | ||
197 | return buildEvent("EstablishAgentCommunication", body); | 197 | return BuildEvent("EstablishAgentCommunication", body); |
198 | } | 198 | } |
199 | 199 | ||
200 | public static OSD KeepAliveEvent() | 200 | public static OSD KeepAliveEvent() |
201 | { | 201 | { |
202 | return buildEvent("FAKEEVENT", new OSDMap()); | 202 | return BuildEvent("FAKEEVENT", new OSDMap()); |
203 | } | 203 | } |
204 | 204 | ||
205 | public static OSD AgentParams(UUID agentID, bool checkEstate, int godLevel, bool limitedToEstate) | 205 | public static OSD AgentParams(UUID agentID, bool checkEstate, int godLevel, bool limitedToEstate) |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs new file mode 100644 index 0000000..f2f765c --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -0,0 +1,136 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Web; | ||
34 | using Mono.Addins; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Capabilities.Handlers; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
47 | |||
48 | namespace OpenSim.Region.ClientStack.Linden | ||
49 | { | ||
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
51 | public class GetMeshModule : INonSharedRegionModule | ||
52 | { | ||
53 | private static readonly ILog m_log = | ||
54 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | private Scene m_scene; | ||
57 | private IAssetService m_AssetService; | ||
58 | private bool m_Enabled = true; | ||
59 | private string m_URL; | ||
60 | |||
61 | #region IRegionModuleBase Members | ||
62 | |||
63 | public Type ReplaceableInterface | ||
64 | { | ||
65 | get { return null; } | ||
66 | } | ||
67 | |||
68 | public void Initialise(IConfigSource source) | ||
69 | { | ||
70 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
71 | if (config == null) | ||
72 | return; | ||
73 | |||
74 | m_URL = config.GetString("Cap_GetMesh", string.Empty); | ||
75 | // Cap doesn't exist | ||
76 | if (m_URL != string.Empty) | ||
77 | m_Enabled = true; | ||
78 | } | ||
79 | |||
80 | public void AddRegion(Scene pScene) | ||
81 | { | ||
82 | if (!m_Enabled) | ||
83 | return; | ||
84 | |||
85 | m_scene = pScene; | ||
86 | } | ||
87 | |||
88 | public void RemoveRegion(Scene scene) | ||
89 | { | ||
90 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
91 | m_scene = null; | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene scene) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | |||
99 | m_AssetService = m_scene.RequestModuleInterface<IAssetService>(); | ||
100 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
101 | } | ||
102 | |||
103 | |||
104 | public void Close() { } | ||
105 | |||
106 | public string Name { get { return "GetMeshModule"; } } | ||
107 | |||
108 | #endregion | ||
109 | |||
110 | |||
111 | public void RegisterCaps(UUID agentID, Caps caps) | ||
112 | { | ||
113 | UUID capID = UUID.Random(); | ||
114 | |||
115 | //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | ||
116 | if (m_URL == "localhost") | ||
117 | { | ||
118 | m_log.InfoFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | ||
119 | GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService); | ||
120 | IRequestHandler reqHandler = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), | ||
121 | delegate(Hashtable m_dhttpMethod) | ||
122 | { | ||
123 | return gmeshHandler.ProcessGetMesh(m_dhttpMethod, UUID.Zero, null); | ||
124 | }); | ||
125 | |||
126 | caps.RegisterHandler("GetMesh", reqHandler); | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | m_log.InfoFormat("[GETMESH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | ||
131 | caps.RegisterHandler("GetMesh", m_URL); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | } | ||
136 | } | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs new file mode 100644 index 0000000..564ef31 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -0,0 +1,139 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Drawing; | ||
32 | using System.Drawing.Imaging; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Web; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using Mono.Addins; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using OpenMetaverse.Imaging; | ||
42 | using OpenSim.Framework; | ||
43 | using OpenSim.Framework.Servers; | ||
44 | using OpenSim.Framework.Servers.HttpServer; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Region.Framework.Scenes; | ||
47 | using OpenSim.Services.Interfaces; | ||
48 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
49 | using OpenSim.Capabilities.Handlers; | ||
50 | |||
51 | namespace OpenSim.Region.ClientStack.Linden | ||
52 | { | ||
53 | |||
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
55 | public class GetTextureModule : INonSharedRegionModule | ||
56 | { | ||
57 | private static readonly ILog m_log = | ||
58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
59 | private Scene m_scene; | ||
60 | private IAssetService m_assetService; | ||
61 | |||
62 | private bool m_Enabled = false; | ||
63 | |||
64 | // TODO: Change this to a config option | ||
65 | const string REDIRECT_URL = null; | ||
66 | |||
67 | private string m_URL; | ||
68 | |||
69 | #region ISharedRegionModule Members | ||
70 | |||
71 | public void Initialise(IConfigSource source) | ||
72 | { | ||
73 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
74 | if (config == null) | ||
75 | return; | ||
76 | |||
77 | m_URL = config.GetString("Cap_GetTexture", string.Empty); | ||
78 | // Cap doesn't exist | ||
79 | if (m_URL != string.Empty) | ||
80 | m_Enabled = true; | ||
81 | } | ||
82 | |||
83 | public void AddRegion(Scene s) | ||
84 | { | ||
85 | if (!m_Enabled) | ||
86 | return; | ||
87 | |||
88 | m_scene = s; | ||
89 | } | ||
90 | |||
91 | public void RemoveRegion(Scene s) | ||
92 | { | ||
93 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
94 | m_scene = null; | ||
95 | } | ||
96 | |||
97 | public void RegionLoaded(Scene s) | ||
98 | { | ||
99 | if (!m_Enabled) | ||
100 | return; | ||
101 | |||
102 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | ||
103 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
104 | } | ||
105 | |||
106 | public void PostInitialise() | ||
107 | { | ||
108 | } | ||
109 | |||
110 | public void Close() { } | ||
111 | |||
112 | public string Name { get { return "GetTextureModule"; } } | ||
113 | |||
114 | public Type ReplaceableInterface | ||
115 | { | ||
116 | get { return null; } | ||
117 | } | ||
118 | |||
119 | #endregion | ||
120 | |||
121 | public void RegisterCaps(UUID agentID, Caps caps) | ||
122 | { | ||
123 | UUID capID = UUID.Random(); | ||
124 | |||
125 | //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | ||
126 | if (m_URL == "localhost") | ||
127 | { | ||
128 | m_log.InfoFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | ||
129 | caps.RegisterHandler("GetTexture", new GetTextureHandler("/CAPS/" + capID + "/", m_assetService)); | ||
130 | } | ||
131 | else | ||
132 | { | ||
133 | m_log.InfoFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | ||
134 | caps.RegisterHandler("GetTexture", m_URL); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | } | ||
139 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index 3d4c7b7..b7e79cc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs | |||
@@ -45,7 +45,7 @@ using OpenSim.Services.Interfaces; | |||
45 | using Caps = OpenSim.Framework.Capabilities.Caps; | 45 | using Caps = OpenSim.Framework.Capabilities.Caps; |
46 | using OpenSim.Framework.Capabilities; | 46 | using OpenSim.Framework.Capabilities; |
47 | 47 | ||
48 | namespace OpenSim.Region.CoreModules.Avatar.Assets | 48 | namespace OpenSim.Region.ClientStack.Linden |
49 | { | 49 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
51 | public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule | 51 | public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule |
@@ -171,8 +171,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets | |||
171 | UUID parentFolder = llsdRequest.folder_id; | 171 | UUID parentFolder = llsdRequest.folder_id; |
172 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; | 172 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; |
173 | 173 | ||
174 | Caps.AssetUploader uploader = | 174 | AssetUploader uploader = |
175 | new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | 175 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, |
176 | llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); | 176 | llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); |
177 | MainServer.Instance.AddStreamHandler( | 177 | MainServer.Instance.AddStreamHandler( |
178 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | 178 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); |
diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs index a0d72ed..15139a3 100644 --- a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using Caps=OpenSim.Framework.Capabilities.Caps; | 40 | using Caps=OpenSim.Framework.Capabilities.Caps; |
41 | 41 | ||
42 | namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps | 42 | namespace OpenSim.Region.ClientStack.Linden |
43 | { | 43 | { |
44 | public class ObjectAdd : IRegionModule | 44 | public class ObjectAdd : IRegionModule |
45 | { | 45 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs index 3114d7f..3809f84 100644 --- a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs | |||
@@ -49,7 +49,7 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; | |||
49 | using OpenSim.Framework.Capabilities; | 49 | using OpenSim.Framework.Capabilities; |
50 | using ExtraParamType = OpenMetaverse.ExtraParamType; | 50 | using ExtraParamType = OpenMetaverse.ExtraParamType; |
51 | 51 | ||
52 | namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps | 52 | namespace OpenSim.Region.ClientStack.Linden |
53 | { | 53 | { |
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
55 | public class UploadObjectAssetModule : INonSharedRegionModule | 55 | public class UploadObjectAssetModule : INonSharedRegionModule |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/IncomingPacket.cs b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs index 90b3ede..90b3ede 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/IncomingPacket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/IncomingPacketHistoryCollection.cs b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacketHistoryCollection.cs index 1f73a1d..1f73a1d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/IncomingPacketHistoryCollection.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacketHistoryCollection.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index e9e2dca..e9e2dca 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 43903ce..43903ce 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 9e0db12..9e0db12 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index ca5501d..ca5501d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index aff90c5..aff90c5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 6eebd9d..6eebd9d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/Linden/UDP/OutgoingPacket.cs index 76c6c14..76c6c14 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OutgoingPacket.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs index daab84f..daab84f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs index 34c21aa..34c21aa 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/PacketHandlerTests.cs index 7d0757f..7d0757f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/PacketHandlerTests.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLPacketServer.cs index e995d65..e995d65 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLPacketServer.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs index f98586d..f98586d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs index c9aac0b..c9aac0b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs index 29fd1a4..29fd1a4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs | |||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs index 793aefe..793aefe 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/UnackedPacketCollection.cs | |||
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs deleted file mode 100644 index fc1ddef..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ /dev/null | |||
@@ -1,211 +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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Web; | ||
34 | using Mono.Addins; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
46 | |||
47 | namespace 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 | |||
55 | private Scene m_scene; | ||
56 | private IAssetService m_assetService; | ||
57 | private bool m_enabled = true; | ||
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 | IConfig meshConfig = source.Configs["Mesh"]; | ||
70 | if (meshConfig == null) | ||
71 | return; | ||
72 | |||
73 | m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene pScene) | ||
77 | { | ||
78 | m_scene = pScene; | ||
79 | } | ||
80 | |||
81 | public void RemoveRegion(Scene scene) | ||
82 | { | ||
83 | |||
84 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
85 | m_scene = null; | ||
86 | } | ||
87 | |||
88 | public void RegionLoaded(Scene scene) | ||
89 | { | ||
90 | |||
91 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | ||
92 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
93 | } | ||
94 | |||
95 | #endregion | ||
96 | |||
97 | |||
98 | #region IRegionModule Members | ||
99 | |||
100 | |||
101 | |||
102 | public void Close() { } | ||
103 | |||
104 | public string Name { get { return "GetMeshModule"; } } | ||
105 | |||
106 | |||
107 | public void RegisterCaps(UUID agentID, Caps caps) | ||
108 | { | ||
109 | if(!m_enabled) | ||
110 | return; | ||
111 | |||
112 | UUID capID = UUID.Random(); | ||
113 | |||
114 | // m_log.Info("[GETMESH]: /CAPS/" + capID); | ||
115 | |||
116 | caps.RegisterHandler("GetMesh", | ||
117 | new RestHTTPHandler("GET", "/CAPS/" + capID, | ||
118 | delegate(Hashtable m_dhttpMethod) | ||
119 | { | ||
120 | return ProcessGetMesh(m_dhttpMethod, agentID, caps); | ||
121 | })); | ||
122 | } | ||
123 | |||
124 | #endregion | ||
125 | |||
126 | public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) | ||
127 | { | ||
128 | |||
129 | Hashtable responsedata = new Hashtable(); | ||
130 | responsedata["int_response_code"] = 400; //501; //410; //404; | ||
131 | responsedata["content_type"] = "text/plain"; | ||
132 | responsedata["keepalive"] = false; | ||
133 | responsedata["str_response_string"] = "Request wasn't what was expected"; | ||
134 | |||
135 | string meshStr = string.Empty; | ||
136 | |||
137 | if (request.ContainsKey("mesh_id")) | ||
138 | meshStr = request["mesh_id"].ToString(); | ||
139 | |||
140 | |||
141 | UUID meshID = UUID.Zero; | ||
142 | if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID)) | ||
143 | { | ||
144 | if (m_assetService == null) | ||
145 | { | ||
146 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
147 | responsedata["content_type"] = "text/plain"; | ||
148 | responsedata["keepalive"] = false; | ||
149 | responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; | ||
150 | return responsedata; | ||
151 | } | ||
152 | |||
153 | AssetBase mesh; | ||
154 | // Only try to fetch locally cached textures. Misses are redirected | ||
155 | mesh = m_assetService.GetCached(meshID.ToString()); | ||
156 | if (mesh != null) | ||
157 | { | ||
158 | if (mesh.Type == (SByte)AssetType.Mesh) | ||
159 | { | ||
160 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); | ||
161 | responsedata["content_type"] = "application/vnd.ll.mesh"; | ||
162 | responsedata["int_response_code"] = 200; | ||
163 | } | ||
164 | // Optionally add additional mesh types here | ||
165 | else | ||
166 | { | ||
167 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
168 | responsedata["content_type"] = "text/plain"; | ||
169 | responsedata["keepalive"] = false; | ||
170 | responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; | ||
171 | return responsedata; | ||
172 | } | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | mesh = m_assetService.Get(meshID.ToString()); | ||
177 | if (mesh != null) | ||
178 | { | ||
179 | if (mesh.Type == (SByte)AssetType.Mesh) | ||
180 | { | ||
181 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); | ||
182 | responsedata["content_type"] = "application/vnd.ll.mesh"; | ||
183 | responsedata["int_response_code"] = 200; | ||
184 | } | ||
185 | // Optionally add additional mesh types here | ||
186 | else | ||
187 | { | ||
188 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
189 | responsedata["content_type"] = "text/plain"; | ||
190 | responsedata["keepalive"] = false; | ||
191 | responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; | ||
192 | return responsedata; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | else | ||
197 | { | ||
198 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
199 | responsedata["content_type"] = "text/plain"; | ||
200 | responsedata["keepalive"] = false; | ||
201 | responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; | ||
202 | return responsedata; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | } | ||
207 | |||
208 | return responsedata; | ||
209 | } | ||
210 | } | ||
211 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs deleted file mode 100644 index df4d561..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs +++ /dev/null | |||
@@ -1,402 +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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Drawing; | ||
32 | using System.Drawing.Imaging; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Web; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using OpenMetaverse; | ||
39 | using OpenMetaverse.StructuredData; | ||
40 | using OpenMetaverse.Imaging; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using OpenSim.Region.Framework.Interfaces; | ||
45 | using OpenSim.Region.Framework.Scenes; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps | ||
50 | { | ||
51 | #region Stream Handler | ||
52 | |||
53 | public delegate byte[] StreamHandlerCallback(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse); | ||
54 | |||
55 | public class StreamHandler : BaseStreamHandler | ||
56 | { | ||
57 | StreamHandlerCallback m_callback; | ||
58 | |||
59 | public StreamHandler(string httpMethod, string path, StreamHandlerCallback callback) | ||
60 | : base(httpMethod, path) | ||
61 | { | ||
62 | m_callback = callback; | ||
63 | } | ||
64 | |||
65 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
66 | { | ||
67 | return m_callback(path, request, httpRequest, httpResponse); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | #endregion Stream Handler | ||
72 | |||
73 | public class GetTextureModule : IRegionModule | ||
74 | { | ||
75 | private static readonly ILog m_log = | ||
76 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
77 | private Scene m_scene; | ||
78 | private IAssetService m_assetService; | ||
79 | |||
80 | public const string DefaultFormat = "x-j2c"; | ||
81 | |||
82 | // TODO: Change this to a config option | ||
83 | const string REDIRECT_URL = null; | ||
84 | |||
85 | |||
86 | #region IRegionModule Members | ||
87 | |||
88 | public void Initialise(Scene pScene, IConfigSource pSource) | ||
89 | { | ||
90 | m_scene = pScene; | ||
91 | } | ||
92 | |||
93 | public void PostInitialise() | ||
94 | { | ||
95 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | ||
96 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
97 | } | ||
98 | |||
99 | public void Close() { } | ||
100 | |||
101 | public string Name { get { return "GetTextureModule"; } } | ||
102 | public bool IsSharedModule { get { return false; } } | ||
103 | |||
104 | public void RegisterCaps(UUID agentID, Caps caps) | ||
105 | { | ||
106 | UUID capID = UUID.Random(); | ||
107 | |||
108 | // m_log.InfoFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | ||
109 | caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | ||
110 | } | ||
111 | |||
112 | #endregion | ||
113 | |||
114 | private byte[] ProcessGetTexture(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
115 | { | ||
116 | //m_log.DebugFormat("[GETTEXTURE]: called in {0}", m_scene.RegionInfo.RegionName); | ||
117 | |||
118 | // Try to parse the texture ID from the request URL | ||
119 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | ||
120 | string textureStr = query.GetOne("texture_id"); | ||
121 | string format = query.GetOne("format"); | ||
122 | |||
123 | if (m_assetService == null) | ||
124 | { | ||
125 | m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service"); | ||
126 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; | ||
127 | return null; | ||
128 | } | ||
129 | |||
130 | UUID textureID; | ||
131 | if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID)) | ||
132 | { | ||
133 | string[] formats; | ||
134 | if (format != null && format != string.Empty) | ||
135 | { | ||
136 | formats = new string[1] { format.ToLower() }; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | formats = WebUtil.GetPreferredImageTypes(httpRequest.Headers.Get("Accept")); | ||
141 | if (formats.Length == 0) | ||
142 | formats = new string[1] { DefaultFormat }; // default | ||
143 | |||
144 | } | ||
145 | // OK, we have an array with preferred formats, possibly with only one entry | ||
146 | |||
147 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; | ||
148 | foreach (string f in formats) | ||
149 | { | ||
150 | if (FetchTexture(httpRequest, httpResponse, textureID, f)) | ||
151 | break; | ||
152 | } | ||
153 | |||
154 | } | ||
155 | else | ||
156 | { | ||
157 | m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url); | ||
158 | } | ||
159 | |||
160 | httpResponse.Send(); | ||
161 | return null; | ||
162 | } | ||
163 | |||
164 | /// <summary> | ||
165 | /// | ||
166 | /// </summary> | ||
167 | /// <param name="httpRequest"></param> | ||
168 | /// <param name="httpResponse"></param> | ||
169 | /// <param name="textureID"></param> | ||
170 | /// <param name="format"></param> | ||
171 | /// <returns>False for "caller try another codec"; true otherwise</returns> | ||
172 | private bool FetchTexture(OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID textureID, string format) | ||
173 | { | ||
174 | // m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format); | ||
175 | AssetBase texture; | ||
176 | |||
177 | string fullID = textureID.ToString(); | ||
178 | if (format != DefaultFormat) | ||
179 | fullID = fullID + "-" + format; | ||
180 | |||
181 | if (!String.IsNullOrEmpty(REDIRECT_URL)) | ||
182 | { | ||
183 | // Only try to fetch locally cached textures. Misses are redirected | ||
184 | texture = m_assetService.GetCached(fullID); | ||
185 | |||
186 | if (texture != null) | ||
187 | { | ||
188 | if (texture.Type != (sbyte)AssetType.Texture) | ||
189 | { | ||
190 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; | ||
191 | return true; | ||
192 | } | ||
193 | WriteTextureData(httpRequest, httpResponse, texture, format); | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | string textureUrl = REDIRECT_URL + textureID.ToString(); | ||
198 | m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); | ||
199 | httpResponse.RedirectLocation = textureUrl; | ||
200 | return true; | ||
201 | } | ||
202 | } | ||
203 | else // no redirect | ||
204 | { | ||
205 | // try the cache | ||
206 | texture = m_assetService.GetCached(fullID); | ||
207 | |||
208 | if (texture == null) | ||
209 | { | ||
210 | //m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache"); | ||
211 | |||
212 | // Fetch locally or remotely. Misses return a 404 | ||
213 | texture = m_assetService.Get(textureID.ToString()); | ||
214 | |||
215 | if (texture != null) | ||
216 | { | ||
217 | if (texture.Type != (sbyte)AssetType.Texture) | ||
218 | { | ||
219 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; | ||
220 | return true; | ||
221 | } | ||
222 | if (format == DefaultFormat) | ||
223 | { | ||
224 | WriteTextureData(httpRequest, httpResponse, texture, format); | ||
225 | return true; | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, (sbyte)AssetType.Texture, texture.Metadata.CreatorID); | ||
230 | newTexture.Data = ConvertTextureData(texture, format); | ||
231 | if (newTexture.Data.Length == 0) | ||
232 | return false; // !!! Caller try another codec, please! | ||
233 | |||
234 | newTexture.Flags = AssetFlags.Collectable; | ||
235 | newTexture.Temporary = true; | ||
236 | m_assetService.Store(newTexture); | ||
237 | WriteTextureData(httpRequest, httpResponse, newTexture, format); | ||
238 | return true; | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | else // it was on the cache | ||
243 | { | ||
244 | //m_log.DebugFormat("[GETTEXTURE]: texture was in the cache"); | ||
245 | WriteTextureData(httpRequest, httpResponse, texture, format); | ||
246 | return true; | ||
247 | } | ||
248 | } | ||
249 | |||
250 | // not found | ||
251 | // m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); | ||
252 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; | ||
253 | return true; | ||
254 | } | ||
255 | |||
256 | private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format) | ||
257 | { | ||
258 | string range = request.Headers.GetOne("Range"); | ||
259 | //m_log.DebugFormat("[GETTEXTURE]: Range {0}", range); | ||
260 | if (!String.IsNullOrEmpty(range)) // JP2's only | ||
261 | { | ||
262 | // Range request | ||
263 | int start, end; | ||
264 | if (TryParseRange(range, out start, out end)) | ||
265 | { | ||
266 | // Before clamping start make sure we can satisfy it in order to avoid | ||
267 | // sending back the last byte instead of an error status | ||
268 | if (start >= texture.Data.Length) | ||
269 | { | ||
270 | response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; | ||
271 | return; | ||
272 | } | ||
273 | |||
274 | end = Utils.Clamp(end, 0, texture.Data.Length - 1); | ||
275 | start = Utils.Clamp(start, 0, end); | ||
276 | int len = end - start + 1; | ||
277 | |||
278 | //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); | ||
279 | |||
280 | if (len < texture.Data.Length) | ||
281 | response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent; | ||
282 | |||
283 | response.ContentLength = len; | ||
284 | response.ContentType = texture.Metadata.ContentType; | ||
285 | response.AddHeader("Content-Range", String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length)); | ||
286 | |||
287 | response.Body.Write(texture.Data, start, len); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | m_log.Warn("[GETTEXTURE]: Malformed Range header: " + range); | ||
292 | response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; | ||
293 | } | ||
294 | } | ||
295 | else // JP2's or other formats | ||
296 | { | ||
297 | // Full content request | ||
298 | response.StatusCode = (int)System.Net.HttpStatusCode.OK; | ||
299 | response.ContentLength = texture.Data.Length; | ||
300 | if (format == DefaultFormat) | ||
301 | response.ContentType = texture.Metadata.ContentType; | ||
302 | else | ||
303 | response.ContentType = "image/" + format; | ||
304 | response.Body.Write(texture.Data, 0, texture.Data.Length); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | private bool TryParseRange(string header, out int start, out int end) | ||
309 | { | ||
310 | if (header.StartsWith("bytes=")) | ||
311 | { | ||
312 | string[] rangeValues = header.Substring(6).Split('-'); | ||
313 | if (rangeValues.Length == 2) | ||
314 | { | ||
315 | if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end)) | ||
316 | return true; | ||
317 | } | ||
318 | } | ||
319 | |||
320 | start = end = 0; | ||
321 | return false; | ||
322 | } | ||
323 | |||
324 | |||
325 | private byte[] ConvertTextureData(AssetBase texture, string format) | ||
326 | { | ||
327 | m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format); | ||
328 | byte[] data = new byte[0]; | ||
329 | |||
330 | MemoryStream imgstream = new MemoryStream(); | ||
331 | Bitmap mTexture = new Bitmap(1, 1); | ||
332 | ManagedImage managedImage; | ||
333 | Image image = (Image)mTexture; | ||
334 | |||
335 | try | ||
336 | { | ||
337 | // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data | ||
338 | |||
339 | imgstream = new MemoryStream(); | ||
340 | |||
341 | // Decode image to System.Drawing.Image | ||
342 | if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image)) | ||
343 | { | ||
344 | // Save to bitmap | ||
345 | mTexture = new Bitmap(image); | ||
346 | |||
347 | EncoderParameters myEncoderParameters = new EncoderParameters(); | ||
348 | myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L); | ||
349 | |||
350 | // Save bitmap to stream | ||
351 | ImageCodecInfo codec = GetEncoderInfo("image/" + format); | ||
352 | if (codec != null) | ||
353 | { | ||
354 | mTexture.Save(imgstream, codec, myEncoderParameters); | ||
355 | // Write the stream to a byte array for output | ||
356 | data = imgstream.ToArray(); | ||
357 | } | ||
358 | else | ||
359 | m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format); | ||
360 | |||
361 | } | ||
362 | } | ||
363 | catch (Exception e) | ||
364 | { | ||
365 | m_log.WarnFormat("[GETTEXTURE]: Unable to convert texture {0} to {1}: {2}", texture.ID, format, e.Message); | ||
366 | } | ||
367 | finally | ||
368 | { | ||
369 | // Reclaim memory, these are unmanaged resources | ||
370 | // If we encountered an exception, one or more of these will be null | ||
371 | if (mTexture != null) | ||
372 | mTexture.Dispose(); | ||
373 | |||
374 | if (image != null) | ||
375 | image.Dispose(); | ||
376 | |||
377 | if (imgstream != null) | ||
378 | { | ||
379 | imgstream.Close(); | ||
380 | imgstream.Dispose(); | ||
381 | } | ||
382 | } | ||
383 | |||
384 | return data; | ||
385 | } | ||
386 | |||
387 | // From msdn | ||
388 | private static ImageCodecInfo GetEncoderInfo(String mimeType) | ||
389 | { | ||
390 | ImageCodecInfo[] encoders; | ||
391 | encoders = ImageCodecInfo.GetImageEncoders(); | ||
392 | for (int j = 0; j < encoders.Length; ++j) | ||
393 | { | ||
394 | if (encoders[j].MimeType == mimeType) | ||
395 | return encoders[j]; | ||
396 | } | ||
397 | return null; | ||
398 | } | ||
399 | |||
400 | |||
401 | } | ||
402 | } | ||
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index 1d8e70e..5e22c8c 100644 --- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using Mono.Addins; | ||
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
@@ -38,8 +39,9 @@ using OpenSim.Region.Framework.Interfaces; | |||
38 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
39 | using Caps=OpenSim.Framework.Capabilities.Caps; | 40 | using Caps=OpenSim.Framework.Capabilities.Caps; |
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.Agent.Capabilities | 42 | namespace OpenSim.Region.CoreModules.Framework |
42 | { | 43 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
43 | public class CapabilitiesModule : INonSharedRegionModule, ICapabilitiesModule | 45 | public class CapabilitiesModule : INonSharedRegionModule, ICapabilitiesModule |
44 | { | 46 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -49,7 +51,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities | |||
49 | /// <summary> | 51 | /// <summary> |
50 | /// Each agent has its own capabilities handler. | 52 | /// Each agent has its own capabilities handler. |
51 | /// </summary> | 53 | /// </summary> |
52 | protected Dictionary<UUID, Caps> m_capsHandlers = new Dictionary<UUID, Caps>(); | 54 | protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>(); |
53 | 55 | ||
54 | protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); | 56 | protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); |
55 | protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds | 57 | protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds |
@@ -93,19 +95,19 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities | |||
93 | get { return null; } | 95 | get { return null; } |
94 | } | 96 | } |
95 | 97 | ||
96 | public void AddCapsHandler(UUID agentId) | 98 | public void CreateCaps(UUID agentId) |
97 | { | 99 | { |
98 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) | 100 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) |
99 | return; | 101 | return; |
100 | 102 | ||
101 | String capsObjectPath = GetCapsPath(agentId); | 103 | String capsObjectPath = GetCapsPath(agentId); |
102 | 104 | ||
103 | if (m_capsHandlers.ContainsKey(agentId)) | 105 | if (m_capsObjects.ContainsKey(agentId)) |
104 | { | 106 | { |
105 | Caps oldCaps = m_capsHandlers[agentId]; | 107 | Caps oldCaps = m_capsObjects[agentId]; |
106 | 108 | ||
107 | m_log.DebugFormat( | 109 | m_log.DebugFormat( |
108 | "[CAPS]: Reregistering caps for agent {0}. Old caps path {1}, new caps path {2}. ", | 110 | "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", |
109 | agentId, oldCaps.CapsObjectPath, capsObjectPath); | 111 | agentId, oldCaps.CapsObjectPath, capsObjectPath); |
110 | // This should not happen. The caller code is confused. We need to fix that. | 112 | // This should not happen. The caller code is confused. We need to fix that. |
111 | // CAPs can never be reregistered, or the client will be confused. | 113 | // CAPs can never be reregistered, or the client will be confused. |
@@ -113,39 +115,29 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities | |||
113 | //return; | 115 | //return; |
114 | } | 116 | } |
115 | 117 | ||
116 | Caps caps | 118 | Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, |
117 | = new Caps(m_scene, | ||
118 | m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName, | ||
119 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, | 119 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, |
120 | capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); | 120 | capsObjectPath, agentId, m_scene.RegionInfo.RegionName); |
121 | 121 | ||
122 | caps.RegisterHandlers(); | 122 | m_capsObjects[agentId] = caps; |
123 | 123 | ||
124 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | 124 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); |
125 | |||
126 | caps.AddNewInventoryItem = m_scene.AddUploadedInventoryItem; | ||
127 | caps.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset; | ||
128 | caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; | ||
129 | caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; | ||
130 | caps.GetClient = m_scene.SceneContents.GetControllingClient; | ||
131 | |||
132 | m_capsHandlers[agentId] = caps; | ||
133 | } | 125 | } |
134 | 126 | ||
135 | public void RemoveCapsHandler(UUID agentId) | 127 | public void RemoveCaps(UUID agentId) |
136 | { | 128 | { |
137 | if (childrenSeeds.ContainsKey(agentId)) | 129 | if (childrenSeeds.ContainsKey(agentId)) |
138 | { | 130 | { |
139 | childrenSeeds.Remove(agentId); | 131 | childrenSeeds.Remove(agentId); |
140 | } | 132 | } |
141 | 133 | ||
142 | lock (m_capsHandlers) | 134 | lock (m_capsObjects) |
143 | { | 135 | { |
144 | if (m_capsHandlers.ContainsKey(agentId)) | 136 | if (m_capsObjects.ContainsKey(agentId)) |
145 | { | 137 | { |
146 | m_capsHandlers[agentId].DeregisterHandlers(); | 138 | m_capsObjects[agentId].DeregisterHandlers(); |
147 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); | 139 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[agentId]); |
148 | m_capsHandlers.Remove(agentId); | 140 | m_capsObjects.Remove(agentId); |
149 | } | 141 | } |
150 | else | 142 | else |
151 | { | 143 | { |
@@ -156,20 +148,20 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities | |||
156 | } | 148 | } |
157 | } | 149 | } |
158 | 150 | ||
159 | public Caps GetCapsHandlerForUser(UUID agentId) | 151 | public Caps GetCapsForUser(UUID agentId) |
160 | { | 152 | { |
161 | lock (m_capsHandlers) | 153 | lock (m_capsObjects) |
162 | { | 154 | { |
163 | if (m_capsHandlers.ContainsKey(agentId)) | 155 | if (m_capsObjects.ContainsKey(agentId)) |
164 | { | 156 | { |
165 | return m_capsHandlers[agentId]; | 157 | return m_capsObjects[agentId]; |
166 | } | 158 | } |
167 | } | 159 | } |
168 | 160 | ||
169 | return null; | 161 | return null; |
170 | } | 162 | } |
171 | 163 | ||
172 | public void NewUserConnection(AgentCircuitData agent) | 164 | public void SetAgentCapsSeeds(AgentCircuitData agent) |
173 | { | 165 | { |
174 | capsPaths[agent.AgentID] = agent.CapsPath; | 166 | capsPaths[agent.AgentID] = agent.CapsPath; |
175 | childrenSeeds[agent.AgentID] | 167 | childrenSeeds[agent.AgentID] |
@@ -239,7 +231,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities | |||
239 | System.Text.StringBuilder caps = new System.Text.StringBuilder(); | 231 | System.Text.StringBuilder caps = new System.Text.StringBuilder(); |
240 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | 232 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); |
241 | 233 | ||
242 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsHandlers) | 234 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) |
243 | { | 235 | { |
244 | caps.AppendFormat("** User {0}:\n", kvp.Key); | 236 | caps.AppendFormat("** User {0}:\n", kvp.Key); |
245 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.CapsDetails.GetEnumerator(); kvp2.MoveNext(); ) | 237 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.CapsDetails.GetEnumerator(); kvp2.MoveNext(); ) |
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index 2dd7767..07999d1 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs | |||
@@ -575,7 +575,7 @@ namespace OpenSim.Region.CoreModules.InterGrid | |||
575 | string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez"; | 575 | string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez"; |
576 | // Get a reference to the user's cap so we can pull out the Caps Object Path | 576 | // Get a reference to the user's cap so we can pull out the Caps Object Path |
577 | Caps userCap | 577 | Caps userCap |
578 | = homeScene.CapsModule.GetCapsHandlerForUser(agentData.AgentID); | 578 | = homeScene.CapsModule.GetCapsForUser(agentData.AgentID); |
579 | 579 | ||
580 | string rezHttpProtocol = "http://"; | 580 | string rezHttpProtocol = "http://"; |
581 | string regionCapsHttpProtocol = "http://"; | 581 | string regionCapsHttpProtocol = "http://"; |
@@ -700,7 +700,7 @@ namespace OpenSim.Region.CoreModules.InterGrid | |||
700 | { | 700 | { |
701 | // Get a referenceokay - to their Cap object so we can pull out the capobjectroot | 701 | // Get a referenceokay - to their Cap object so we can pull out the capobjectroot |
702 | Caps userCap | 702 | Caps userCap |
703 | = homeScene.CapsModule.GetCapsHandlerForUser(userData.AgentID); | 703 | = homeScene.CapsModule.GetCapsForUser(userData.AgentID); |
704 | 704 | ||
705 | //Update the circuit data in the region so this user is authorized | 705 | //Update the circuit data in the region so this user is authorized |
706 | homeScene.UpdateCircuitData(userData); | 706 | homeScene.UpdateCircuitData(userData); |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index a9d247a..a0009a8 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -17,7 +17,7 @@ | |||
17 | <RegionModule id="PrimCountModule" type="OpenSim.Region.CoreModules.World.Land.PrimCountModule" /> | 17 | <RegionModule id="PrimCountModule" type="OpenSim.Region.CoreModules.World.Land.PrimCountModule" /> |
18 | <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" /> | 18 | <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" /> |
19 | <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> | 19 | <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> |
20 | <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Agent.Capabilities.CapabilitiesModule" /> | 20 | <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Framework.CapabilitiesModule" /> |
21 | <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> | 21 | <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> |
22 | <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> | 22 | <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> |
23 | <RegionModule id="Warp3DImageModule" type="OpenSim.Region.CoreModules.World.Warp3DMap.Warp3DImageModule" /> | 23 | <RegionModule id="Warp3DImageModule" type="OpenSim.Region.CoreModules.World.Warp3DMap.Warp3DImageModule" /> |
diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs index 964e4b9..a505999 100644 --- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs | |||
@@ -36,7 +36,7 @@ using OpenSim.Framework.Capabilities; | |||
36 | using OpenSim.Framework.Servers; | 36 | using OpenSim.Framework.Servers; |
37 | using OpenSim.Framework.Servers.HttpServer; | 37 | using OpenSim.Framework.Servers.HttpServer; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using Caps=OpenSim.Framework.Capabilities.Caps; | 39 | using Caps = OpenSim.Framework.Capabilities.Caps; |
40 | 40 | ||
41 | namespace OpenSim.Region.DataSnapshot | 41 | namespace OpenSim.Region.DataSnapshot |
42 | { | 42 | { |
diff --git a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs index 73bffa0..522c82d 100644 --- a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs | |||
@@ -34,31 +34,27 @@ namespace OpenSim.Region.Framework.Interfaces | |||
34 | { | 34 | { |
35 | public interface ICapabilitiesModule | 35 | public interface ICapabilitiesModule |
36 | { | 36 | { |
37 | void NewUserConnection(AgentCircuitData agent); | ||
38 | |||
39 | /// <summary> | 37 | /// <summary> |
40 | /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent, | 38 | /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent, |
41 | /// then it is replaced by a new CAPS handler. | 39 | /// then it is replaced by a new CAPS handler. |
42 | /// | ||
43 | /// FIXME: On login this is called twice, once for the login and once when the connection is made. | ||
44 | /// This is somewhat innefficient and should be fixed. The initial login creation is necessary | ||
45 | /// since the client asks for capabilities immediately after being informed of the seed. | ||
46 | /// </summary> | 40 | /// </summary> |
47 | /// <param name="agentId"></param> | 41 | /// <param name="agentId"></param> |
48 | /// <param name="capsObjectPath"></param> | 42 | /// <param name="capsObjectPath"></param> |
49 | void AddCapsHandler(UUID agentId); | 43 | void CreateCaps(UUID agentId); |
50 | 44 | ||
51 | /// <summary> | 45 | /// <summary> |
52 | /// Remove the caps handler for a given agent. | 46 | /// Remove the caps handler for a given agent. |
53 | /// </summary> | 47 | /// </summary> |
54 | /// <param name="agentId"></param> | 48 | /// <param name="agentId"></param> |
55 | void RemoveCapsHandler(UUID agentId); | 49 | void RemoveCaps(UUID agentId); |
56 | 50 | ||
57 | /// <summary> | 51 | /// <summary> |
58 | /// Will return null if the agent doesn't have a caps handler registered | 52 | /// Will return null if the agent doesn't have a caps handler registered |
59 | /// </summary> | 53 | /// </summary> |
60 | /// <param name="agentId"></param> | 54 | /// <param name="agentId"></param> |
61 | Caps GetCapsHandlerForUser(UUID agentId); | 55 | Caps GetCapsForUser(UUID agentId); |
56 | |||
57 | void SetAgentCapsSeeds(AgentCircuitData agent); | ||
62 | 58 | ||
63 | Dictionary<ulong, string> GetChildrenSeeds(UUID agentID); | 59 | Dictionary<ulong, string> GetChildrenSeeds(UUID agentID); |
64 | 60 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs index 81e4952..bfa5d17 100644 --- a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs +++ b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs | |||
@@ -57,5 +57,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
57 | bool isModerator, bool textMute); | 57 | bool isModerator, bool textMute); |
58 | void ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID); | 58 | void ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID); |
59 | void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID); | 59 | void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID); |
60 | OSD ScriptRunningEvent(UUID objectID, UUID itemID, bool running, bool mono); | ||
61 | OSD BuildEvent(string eventName, OSD eventBody); | ||
60 | } | 62 | } |
61 | } | 63 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7c5e246..b537381 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -3033,7 +3033,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3033 | m_sceneGraph.removeUserCount(!childagentYN); | 3033 | m_sceneGraph.removeUserCount(!childagentYN); |
3034 | 3034 | ||
3035 | if (CapsModule != null) | 3035 | if (CapsModule != null) |
3036 | CapsModule.RemoveCapsHandler(agentID); | 3036 | CapsModule.RemoveCaps(agentID); |
3037 | 3037 | ||
3038 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever | 3038 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3039 | // this method is doing is HORRIBLE!!! | 3039 | // this method is doing is HORRIBLE!!! |
@@ -3290,8 +3290,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3290 | 3290 | ||
3291 | if (CapsModule != null) | 3291 | if (CapsModule != null) |
3292 | { | 3292 | { |
3293 | CapsModule.NewUserConnection(agent); | 3293 | CapsModule.SetAgentCapsSeeds(agent); |
3294 | CapsModule.AddCapsHandler(agent.AgentID); | 3294 | CapsModule.CreateCaps(agent.AgentID); |
3295 | } | 3295 | } |
3296 | } | 3296 | } |
3297 | else | 3297 | else |
@@ -3309,7 +3309,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3309 | sp.AdjustKnownSeeds(); | 3309 | sp.AdjustKnownSeeds(); |
3310 | 3310 | ||
3311 | if (CapsModule != null) | 3311 | if (CapsModule != null) |
3312 | CapsModule.NewUserConnection(agent); | 3312 | CapsModule.SetAgentCapsSeeds(agent); |
3313 | } | 3313 | } |
3314 | } | 3314 | } |
3315 | 3315 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 8c01d75..2bf8489 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -34,12 +34,9 @@ using Nini.Config; | |||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | 35 | using OpenMetaverse.StructuredData; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Region.CoreModules.Framework.EventQueue; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
40 | 39 | ||
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
42 | |||
43 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 40 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
44 | { | 41 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
@@ -472,7 +469,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
472 | 469 | ||
473 | if (queue != null) | 470 | if (queue != null) |
474 | { | 471 | { |
475 | queue.Enqueue(EventQueueHelper.buildEvent("ChatterBoxSessionStartReply", bodyMap), remoteClient.AgentId); | 472 | queue.Enqueue(queue.BuildEvent("ChatterBoxSessionStartReply", bodyMap), remoteClient.AgentId); |
476 | } | 473 | } |
477 | } | 474 | } |
478 | 475 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index a8dec63..1c791b9 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -39,13 +39,11 @@ using OpenMetaverse.StructuredData; | |||
39 | 39 | ||
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Framework.Communications; | 41 | using OpenSim.Framework.Communications; |
42 | using OpenSim.Region.CoreModules.Framework.EventQueue; | ||
43 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
44 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
45 | 44 | ||
46 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
47 | 46 | ||
48 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
49 | using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; | 47 | using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; |
50 | 48 | ||
51 | 49 | ||
@@ -1154,7 +1152,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1154 | 1152 | ||
1155 | if (queue != null) | 1153 | if (queue != null) |
1156 | { | 1154 | { |
1157 | queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); | 1155 | queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); |
1158 | } | 1156 | } |
1159 | 1157 | ||
1160 | } | 1158 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 8629674..97ab411 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -41,7 +41,6 @@ using log4net; | |||
41 | using Nini.Config; | 41 | using Nini.Config; |
42 | using Amib.Threading; | 42 | using Amib.Threading; |
43 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
44 | using OpenSim.Region.CoreModules.Framework.EventQueue; | ||
45 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
46 | using OpenSim.Region.Framework.Interfaces; | 45 | using OpenSim.Region.Framework.Interfaces; |
47 | using OpenSim.Region.ScriptEngine.Shared; | 46 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -1283,7 +1282,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1283 | } | 1282 | } |
1284 | else | 1283 | else |
1285 | { | 1284 | { |
1286 | eq.Enqueue(EventQueueHelper.ScriptRunningReplyEvent(objectID, itemID, GetScriptState(itemID), true), | 1285 | eq.Enqueue(eq.ScriptRunningEvent(objectID, itemID, GetScriptState(itemID), true), |
1287 | controllingClient.AgentId); | 1286 | controllingClient.AgentId); |
1288 | } | 1287 | } |
1289 | } | 1288 | } |
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index a03cc4c..3139b8a 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -44,7 +44,6 @@ using OpenSim.Region.Framework.Interfaces; | |||
44 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
45 | using Mono.Data.SqliteClient; | 45 | using Mono.Data.SqliteClient; |
46 | 46 | ||
47 | |||
48 | using Caps = OpenSim.Framework.Capabilities.Caps; | 47 | using Caps = OpenSim.Framework.Capabilities.Caps; |
49 | 48 | ||
50 | using OSD = OpenMetaverse.StructuredData.OSD; | 49 | using OSD = OpenMetaverse.StructuredData.OSD; |