diff options
author | Diva Canto | 2011-04-30 11:03:22 -0700 |
---|---|---|
committer | Diva Canto | 2011-04-30 11:03:22 -0700 |
commit | 3e79842312ace5b4294e3d6501b1d35ffea5f1b5 (patch) | |
tree | f8832e79c25dec366cbf78bc5c6dcbc0c5bf0ea4 /OpenSim/Capabilities | |
parent | First stab at cleaning up Caps. Compiles. Untested. (diff) | |
download | opensim-SC-3e79842312ace5b4294e3d6501b1d35ffea5f1b5.zip opensim-SC-3e79842312ace5b4294e3d6501b1d35ffea5f1b5.tar.gz opensim-SC-3e79842312ace5b4294e3d6501b1d35ffea5f1b5.tar.bz2 opensim-SC-3e79842312ace5b4294e3d6501b1d35ffea5f1b5.tar.xz |
Renamed OpenSim.Framework.Capabilities.dll to OpenSim.Capabilities.dll
Diffstat (limited to 'OpenSim/Capabilities')
27 files changed, 3490 insertions, 0 deletions
diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs new file mode 100644 index 0000000..3be97b5 --- /dev/null +++ b/OpenSim/Capabilities/Caps.cs | |||
@@ -0,0 +1,1368 @@ | |||
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.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework.Servers; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | |||
40 | // using OpenSim.Region.Framework.Interfaces; | ||
41 | |||
42 | namespace OpenSim.Framework.Capabilities | ||
43 | { | ||
44 | public delegate void UpLoadedAsset( | ||
45 | string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, | ||
46 | byte[] data, string inventoryType, string assetType); | ||
47 | |||
48 | public delegate void UploadedBakedTexture(UUID assetID, byte[] data); | ||
49 | |||
50 | public delegate UUID UpdateItem(UUID itemID, byte[] data); | ||
51 | |||
52 | public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors); | ||
53 | |||
54 | public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); | ||
55 | |||
56 | public delegate void NewAsset(AssetBase asset); | ||
57 | |||
58 | public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data); | ||
59 | |||
60 | public delegate ArrayList TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, | ||
61 | bool isScriptRunning, byte[] data); | ||
62 | |||
63 | public delegate InventoryCollection FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, | ||
64 | bool fetchFolders, bool fetchItems, int sortOrder, out int version); | ||
65 | |||
66 | /// <summary> | ||
67 | /// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that | ||
68 | /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want | ||
69 | /// to just pass the whole Scene into CAPS. | ||
70 | /// </summary> | ||
71 | public delegate IClientAPI GetClientDelegate(UUID agentID); | ||
72 | |||
73 | public class Caps | ||
74 | { | ||
75 | private static readonly ILog m_log = | ||
76 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
77 | |||
78 | private string m_httpListenerHostName; | ||
79 | private uint m_httpListenPort; | ||
80 | |||
81 | /// <summary> | ||
82 | /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. | ||
83 | /// </summary> | ||
84 | private string m_capsObjectPath; | ||
85 | public string CapsObjectPath { get { return m_capsObjectPath; } } | ||
86 | |||
87 | private CapsHandlers m_capsHandlers; | ||
88 | |||
89 | private static readonly string m_requestPath = "0000/"; | ||
90 | // private static readonly string m_mapLayerPath = "0001/"; | ||
91 | private static readonly string m_newInventory = "0002/"; | ||
92 | //private static readonly string m_requestTexture = "0003/"; | ||
93 | private static readonly string m_notecardUpdatePath = "0004/"; | ||
94 | private static readonly string m_notecardTaskUpdatePath = "0005/"; | ||
95 | // private static readonly string m_fetchInventoryPath = "0006/"; | ||
96 | |||
97 | // The following entries are in a module, however, they are also here so that we don't re-assign | ||
98 | // the path to another cap by mistake. | ||
99 | // private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. | ||
100 | // private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. | ||
101 | |||
102 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. | ||
103 | private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule. | ||
104 | |||
105 | //private string eventQueue = "0100/"; | ||
106 | private IScene m_Scene; | ||
107 | private IHttpServer m_httpListener; | ||
108 | private UUID m_agentID; | ||
109 | private IAssetService m_assetCache; | ||
110 | private int m_eventQueueCount = 1; | ||
111 | private Queue<string> m_capsEventQueue = new Queue<string>(); | ||
112 | private bool m_dumpAssetsToFile; | ||
113 | private string m_regionName; | ||
114 | private object m_fetchLock = new Object(); | ||
115 | |||
116 | private bool m_persistBakedTextures = false; | ||
117 | |||
118 | public bool SSLCaps | ||
119 | { | ||
120 | get { return m_httpListener.UseSSL; } | ||
121 | } | ||
122 | public string SSLCommonName | ||
123 | { | ||
124 | get { return m_httpListener.SSLCommonName; } | ||
125 | } | ||
126 | public CapsHandlers CapsHandlers | ||
127 | { | ||
128 | get { return m_capsHandlers; } | ||
129 | } | ||
130 | |||
131 | // These are callbacks which will be setup by the scene so that we can update scene data when we | ||
132 | // receive capability calls | ||
133 | public NewInventoryItem AddNewInventoryItem = null; | ||
134 | public NewAsset AddNewAsset = null; | ||
135 | public ItemUpdatedCallback ItemUpdatedCall = null; | ||
136 | public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; | ||
137 | public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; | ||
138 | public GetClientDelegate GetClient = null; | ||
139 | |||
140 | public Caps(IScene scene, IAssetService assetCache, IHttpServer httpServer, string httpListen, uint httpPort, string capsPath, | ||
141 | UUID agent, bool dumpAssetsToFile, string regionName) | ||
142 | { | ||
143 | m_Scene = scene; | ||
144 | m_assetCache = assetCache; | ||
145 | m_capsObjectPath = capsPath; | ||
146 | m_httpListener = httpServer; | ||
147 | m_httpListenerHostName = httpListen; | ||
148 | |||
149 | m_httpListenPort = httpPort; | ||
150 | |||
151 | m_persistBakedTextures = false; | ||
152 | IConfigSource config = m_Scene.Config; | ||
153 | if (config != null) | ||
154 | { | ||
155 | IConfig sconfig = config.Configs["Startup"]; | ||
156 | if (sconfig != null) | ||
157 | m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures",m_persistBakedTextures); | ||
158 | } | ||
159 | |||
160 | if (httpServer != null && httpServer.UseSSL) | ||
161 | { | ||
162 | m_httpListenPort = httpServer.SSLPort; | ||
163 | httpListen = httpServer.SSLCommonName; | ||
164 | httpPort = httpServer.SSLPort; | ||
165 | } | ||
166 | |||
167 | m_agentID = agent; | ||
168 | m_dumpAssetsToFile = dumpAssetsToFile; | ||
169 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); | ||
170 | m_regionName = regionName; | ||
171 | } | ||
172 | |||
173 | /// <summary> | ||
174 | /// Register all CAPS http service handlers | ||
175 | /// </summary> | ||
176 | public void RegisterHandlers() | ||
177 | { | ||
178 | DeregisterHandlers(); | ||
179 | |||
180 | string capsBase = "/CAPS/" + m_capsObjectPath; | ||
181 | |||
182 | RegisterRegionServiceHandlers(capsBase); | ||
183 | RegisterInventoryServiceHandlers(capsBase); | ||
184 | } | ||
185 | |||
186 | public void RegisterRegionServiceHandlers(string capsBase) | ||
187 | { | ||
188 | try | ||
189 | { | ||
190 | // the root of all evil | ||
191 | m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); | ||
192 | m_log.DebugFormat( | ||
193 | "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_agentID); | ||
194 | |||
195 | //m_capsHandlers["MapLayer"] = | ||
196 | // new LLSDStreamhandler<OSDMapRequest, OSDMapLayerResponse>("POST", | ||
197 | // capsBase + m_mapLayerPath, | ||
198 | // GetMapLayer); | ||
199 | m_capsHandlers["UpdateScriptTaskInventory"] = | ||
200 | new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); | ||
201 | m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"]; | ||
202 | m_capsHandlers["UploadBakedTexture"] = | ||
203 | new RestStreamHandler("POST", capsBase + m_uploadBakedTexturePath, UploadBakedTexture); | ||
204 | |||
205 | } | ||
206 | catch (Exception e) | ||
207 | { | ||
208 | m_log.Error("[CAPS]: " + e.ToString()); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | public void RegisterInventoryServiceHandlers(string capsBase) | ||
213 | { | ||
214 | try | ||
215 | { | ||
216 | // I don't think this one works... | ||
217 | m_capsHandlers["NewFileAgentInventory"] = | ||
218 | new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", | ||
219 | capsBase + m_newInventory, | ||
220 | NewAgentInventoryRequest); | ||
221 | m_capsHandlers["UpdateNotecardAgentInventory"] = | ||
222 | new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); | ||
223 | m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; | ||
224 | m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; | ||
225 | |||
226 | // As of RC 1.22.9 of the Linden client this is | ||
227 | // supported | ||
228 | |||
229 | //m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); | ||
230 | |||
231 | // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and | ||
232 | // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires | ||
233 | // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service, | ||
234 | // but when I went on the Linden grid, the | ||
235 | // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead, | ||
236 | // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP | ||
237 | // | ||
238 | // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid | ||
239 | // we will be | ||
240 | // able to get the data we need to implement the necessary part of the protocol to fix the issue above. | ||
241 | // m_capsHandlers["FetchInventoryDescendents"] = | ||
242 | // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); | ||
243 | |||
244 | // m_capsHandlers["FetchInventoryDescendents"] = | ||
245 | // new LLSDStreamhandler<LLSDFetchInventoryDescendents, LLSDInventoryDescendents>("POST", | ||
246 | // capsBase + m_fetchInventory, | ||
247 | // FetchInventory)); | ||
248 | // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST", | ||
249 | // capsBase + m_requestTexture, | ||
250 | // RequestTexture); | ||
251 | } | ||
252 | catch (Exception e) | ||
253 | { | ||
254 | m_log.Error("[CAPS]: " + e.ToString()); | ||
255 | } | ||
256 | } | ||
257 | |||
258 | /// <summary> | ||
259 | /// Register a handler. This allows modules to register handlers. | ||
260 | /// </summary> | ||
261 | /// <param name="capName"></param> | ||
262 | /// <param name="handler"></param> | ||
263 | public void RegisterHandler(string capName, IRequestHandler handler) | ||
264 | { | ||
265 | m_capsHandlers[capName] = handler; | ||
266 | //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); | ||
267 | } | ||
268 | |||
269 | /// <summary> | ||
270 | /// Remove all CAPS service handlers. | ||
271 | /// | ||
272 | /// </summary> | ||
273 | /// <param name="httpListener"></param> | ||
274 | /// <param name="path"></param> | ||
275 | /// <param name="restMethod"></param> | ||
276 | public void DeregisterHandlers() | ||
277 | { | ||
278 | if (m_capsHandlers != null) | ||
279 | { | ||
280 | foreach (string capsName in m_capsHandlers.Caps) | ||
281 | { | ||
282 | m_capsHandlers.Remove(capsName); | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | |||
287 | /// <summary> | ||
288 | /// Construct a client response detailing all the capabilities this server can provide. | ||
289 | /// </summary> | ||
290 | /// <param name="request"></param> | ||
291 | /// <param name="path"></param> | ||
292 | /// <param name="param"></param> | ||
293 | /// <param name="httpRequest">HTTP request header object</param> | ||
294 | /// <param name="httpResponse">HTTP response header object</param> | ||
295 | /// <returns></returns> | ||
296 | public string CapsRequest(string request, string path, string param, | ||
297 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
298 | { | ||
299 | m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); | ||
300 | |||
301 | if (!m_Scene.CheckClient(m_agentID, httpRequest.RemoteIPEndPoint)) | ||
302 | { | ||
303 | m_log.DebugFormat("[CAPS]: Unauthorized CAPS client"); | ||
304 | return string.Empty; | ||
305 | } | ||
306 | |||
307 | string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); | ||
308 | |||
309 | //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); | ||
310 | |||
311 | return result; | ||
312 | } | ||
313 | |||
314 | // FIXME: these all should probably go into the respective region | ||
315 | // modules | ||
316 | |||
317 | /// <summary> | ||
318 | /// Processes a fetch inventory request and sends the reply | ||
319 | |||
320 | /// </summary> | ||
321 | /// <param name="request"></param> | ||
322 | /// <param name="path"></param> | ||
323 | /// <param name="param"></param> | ||
324 | /// <returns></returns> | ||
325 | // Request is like: | ||
326 | //<llsd> | ||
327 | // <map><key>folders</key> | ||
328 | // <array> | ||
329 | // <map> | ||
330 | // <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> | ||
331 | // </map> | ||
332 | // </array> | ||
333 | // </map> | ||
334 | //</llsd> | ||
335 | // | ||
336 | // multiple fetch-folder maps are allowed within the larger folders map. | ||
337 | public string FetchInventoryRequest(string request, string path, string param) | ||
338 | { | ||
339 | // string unmodifiedRequest = request.ToString(); | ||
340 | |||
341 | //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); | ||
342 | m_log.Debug("[CAPS]: Inventory Request in region: " + m_regionName); | ||
343 | |||
344 | Hashtable hash = new Hashtable(); | ||
345 | try | ||
346 | { | ||
347 | hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
348 | } | ||
349 | catch (LLSD.LLSDParseException pe) | ||
350 | { | ||
351 | m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); | ||
352 | m_log.Error("Request: " + request.ToString()); | ||
353 | } | ||
354 | |||
355 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | ||
356 | |||
357 | string response = ""; | ||
358 | |||
359 | for (int i = 0; i < foldersrequested.Count; i++) | ||
360 | { | ||
361 | string inventoryitemstr = ""; | ||
362 | Hashtable inventoryhash = (Hashtable)foldersrequested[i]; | ||
363 | |||
364 | LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); | ||
365 | LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); | ||
366 | LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); | ||
367 | |||
368 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); | ||
369 | inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); | ||
370 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | ||
371 | |||
372 | response += inventoryitemstr; | ||
373 | } | ||
374 | |||
375 | if (response.Length == 0) | ||
376 | { | ||
377 | // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. | ||
378 | // Therefore, I'm concluding that the client only has so many threads available to do requests | ||
379 | // and when a thread stalls.. is stays stalled. | ||
380 | // Therefore we need to return something valid | ||
381 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
386 | } | ||
387 | |||
388 | //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request with following xml"); | ||
389 | //m_log.Debug(Util.GetFormattedXml(response)); | ||
390 | |||
391 | return response; | ||
392 | } | ||
393 | |||
394 | public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
395 | { | ||
396 | // nasty temporary hack here, the linden client falsely | ||
397 | // identifies the uuid 00000000-0000-0000-0000-000000000000 | ||
398 | // as a string which breaks us | ||
399 | // | ||
400 | // correctly mark it as a uuid | ||
401 | // | ||
402 | request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); | ||
403 | |||
404 | // another hack <integer>1</integer> results in a | ||
405 | // System.ArgumentException: Object type System.Int32 cannot | ||
406 | // be converted to target type: System.Boolean | ||
407 | // | ||
408 | request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); | ||
409 | request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); | ||
410 | |||
411 | Hashtable hash = new Hashtable(); | ||
412 | try | ||
413 | { | ||
414 | hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
415 | } | ||
416 | catch (LLSD.LLSDParseException pe) | ||
417 | { | ||
418 | m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); | ||
419 | m_log.Error("Request: " + request.ToString()); | ||
420 | } | ||
421 | |||
422 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | ||
423 | |||
424 | string response = ""; | ||
425 | lock (m_fetchLock) | ||
426 | { | ||
427 | for (int i = 0; i < foldersrequested.Count; i++) | ||
428 | { | ||
429 | string inventoryitemstr = ""; | ||
430 | Hashtable inventoryhash = (Hashtable)foldersrequested[i]; | ||
431 | |||
432 | LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); | ||
433 | |||
434 | try{ | ||
435 | LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); | ||
436 | } | ||
437 | catch(Exception e) | ||
438 | { | ||
439 | m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); | ||
440 | } | ||
441 | LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); | ||
442 | |||
443 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); | ||
444 | inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); | ||
445 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | ||
446 | |||
447 | response += inventoryitemstr; | ||
448 | } | ||
449 | |||
450 | |||
451 | if (response.Length == 0) | ||
452 | { | ||
453 | // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. | ||
454 | // Therefore, I'm concluding that the client only has so many threads available to do requests | ||
455 | // and when a thread stalls.. is stays stalled. | ||
456 | // Therefore we need to return something valid | ||
457 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
458 | } | ||
459 | else | ||
460 | { | ||
461 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
462 | } | ||
463 | |||
464 | //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); | ||
465 | //m_log.Debug("[CAPS] "+response); | ||
466 | |||
467 | } | ||
468 | return response; | ||
469 | } | ||
470 | |||
471 | |||
472 | |||
473 | /// <summary> | ||
474 | /// Construct an LLSD reply packet to a CAPS inventory request | ||
475 | /// </summary> | ||
476 | /// <param name="invFetch"></param> | ||
477 | /// <returns></returns> | ||
478 | private LLSDInventoryDescendents FetchInventoryReply(LLSDFetchInventoryDescendents invFetch) | ||
479 | { | ||
480 | LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); | ||
481 | LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); | ||
482 | contents.agent_id = m_agentID; | ||
483 | contents.owner_id = invFetch.owner_id; | ||
484 | contents.folder_id = invFetch.folder_id; | ||
485 | |||
486 | reply.folders.Array.Add(contents); | ||
487 | InventoryCollection inv = new InventoryCollection(); | ||
488 | inv.Folders = new List<InventoryFolderBase>(); | ||
489 | inv.Items = new List<InventoryItemBase>(); | ||
490 | int version = 0; | ||
491 | if (CAPSFetchInventoryDescendents != null) | ||
492 | { | ||
493 | inv = CAPSFetchInventoryDescendents(m_agentID, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); | ||
494 | } | ||
495 | |||
496 | if (inv.Folders != null) | ||
497 | { | ||
498 | foreach (InventoryFolderBase invFolder in inv.Folders) | ||
499 | { | ||
500 | contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); | ||
501 | } | ||
502 | } | ||
503 | |||
504 | if (inv.Items != null) | ||
505 | { | ||
506 | foreach (InventoryItemBase invItem in inv.Items) | ||
507 | { | ||
508 | contents.items.Array.Add(ConvertInventoryItem(invItem)); | ||
509 | } | ||
510 | } | ||
511 | |||
512 | contents.descendents = contents.items.Array.Count + contents.categories.Array.Count; | ||
513 | contents.version = version; | ||
514 | |||
515 | return reply; | ||
516 | } | ||
517 | |||
518 | /// <summary> | ||
519 | /// Convert an internal inventory folder object into an LLSD object. | ||
520 | /// </summary> | ||
521 | /// <param name="invFolder"></param> | ||
522 | /// <returns></returns> | ||
523 | private LLSDInventoryFolder ConvertInventoryFolder(InventoryFolderBase invFolder) | ||
524 | { | ||
525 | LLSDInventoryFolder llsdFolder = new LLSDInventoryFolder(); | ||
526 | llsdFolder.folder_id = invFolder.ID; | ||
527 | llsdFolder.parent_id = invFolder.ParentID; | ||
528 | llsdFolder.name = invFolder.Name; | ||
529 | if (invFolder.Type < 0 || invFolder.Type >= TaskInventoryItem.Types.Length) | ||
530 | llsdFolder.type = "-1"; | ||
531 | else | ||
532 | llsdFolder.type = TaskInventoryItem.Types[invFolder.Type]; | ||
533 | llsdFolder.preferred_type = "-1"; | ||
534 | |||
535 | return llsdFolder; | ||
536 | } | ||
537 | |||
538 | /// <summary> | ||
539 | /// Convert an internal inventory item object into an LLSD object. | ||
540 | /// </summary> | ||
541 | /// <param name="invItem"></param> | ||
542 | /// <returns></returns> | ||
543 | private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) | ||
544 | { | ||
545 | LLSDInventoryItem llsdItem = new LLSDInventoryItem(); | ||
546 | llsdItem.asset_id = invItem.AssetID; | ||
547 | llsdItem.created_at = invItem.CreationDate; | ||
548 | llsdItem.desc = invItem.Description; | ||
549 | llsdItem.flags = (int)invItem.Flags; | ||
550 | llsdItem.item_id = invItem.ID; | ||
551 | llsdItem.name = invItem.Name; | ||
552 | llsdItem.parent_id = invItem.Folder; | ||
553 | try | ||
554 | { | ||
555 | // TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions. | ||
556 | llsdItem.type = TaskInventoryItem.Types[invItem.AssetType]; | ||
557 | llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType]; | ||
558 | } | ||
559 | catch (Exception e) | ||
560 | { | ||
561 | m_log.Error("[CAPS]: Problem setting asset/inventory type while converting inventory item " + invItem.Name + " to LLSD:", e); | ||
562 | } | ||
563 | llsdItem.permissions = new LLSDPermissions(); | ||
564 | llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; | ||
565 | llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; | ||
566 | llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; | ||
567 | llsdItem.permissions.group_id = invItem.GroupID; | ||
568 | llsdItem.permissions.group_mask = (int)invItem.GroupPermissions; | ||
569 | llsdItem.permissions.is_owner_group = invItem.GroupOwned; | ||
570 | llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; | ||
571 | llsdItem.permissions.owner_id = m_agentID; | ||
572 | llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; | ||
573 | llsdItem.sale_info = new LLSDSaleInfo(); | ||
574 | llsdItem.sale_info.sale_price = invItem.SalePrice; | ||
575 | switch (invItem.SaleType) | ||
576 | { | ||
577 | default: | ||
578 | llsdItem.sale_info.sale_type = "not"; | ||
579 | break; | ||
580 | case 1: | ||
581 | llsdItem.sale_info.sale_type = "original"; | ||
582 | break; | ||
583 | case 2: | ||
584 | llsdItem.sale_info.sale_type = "copy"; | ||
585 | break; | ||
586 | case 3: | ||
587 | llsdItem.sale_info.sale_type = "contents"; | ||
588 | break; | ||
589 | } | ||
590 | |||
591 | return llsdItem; | ||
592 | } | ||
593 | |||
594 | /// <summary> | ||
595 | /// | ||
596 | /// </summary> | ||
597 | /// <param name="mapReq"></param> | ||
598 | /// <returns></returns> | ||
599 | public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) | ||
600 | { | ||
601 | m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName); | ||
602 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | ||
603 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); | ||
604 | return mapResponse; | ||
605 | } | ||
606 | |||
607 | /// <summary> | ||
608 | /// | ||
609 | /// </summary> | ||
610 | /// <returns></returns> | ||
611 | protected static OSDMapLayer GetOSDMapLayerResponse() | ||
612 | { | ||
613 | OSDMapLayer mapLayer = new OSDMapLayer(); | ||
614 | mapLayer.Right = 5000; | ||
615 | mapLayer.Top = 5000; | ||
616 | mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); | ||
617 | |||
618 | return mapLayer; | ||
619 | } | ||
620 | |||
621 | /// <summary> | ||
622 | /// | ||
623 | /// </summary> | ||
624 | /// <param name="request"></param> | ||
625 | /// <param name="path"></param> | ||
626 | /// <param name="param"></param> | ||
627 | /// <returns></returns> | ||
628 | public string RequestTexture(string request, string path, string param) | ||
629 | { | ||
630 | m_log.Debug("texture request " + request); | ||
631 | // Needs implementing (added to remove compiler warning) | ||
632 | return String.Empty; | ||
633 | } | ||
634 | |||
635 | #region EventQueue (Currently not enabled) | ||
636 | |||
637 | /// <summary> | ||
638 | /// | ||
639 | /// </summary> | ||
640 | /// <param name="request"></param> | ||
641 | /// <param name="path"></param> | ||
642 | /// <param name="param"></param> | ||
643 | /// <returns></returns> | ||
644 | public string ProcessEventQueue(string request, string path, string param) | ||
645 | { | ||
646 | string res = String.Empty; | ||
647 | |||
648 | if (m_capsEventQueue.Count > 0) | ||
649 | { | ||
650 | lock (m_capsEventQueue) | ||
651 | { | ||
652 | string item = m_capsEventQueue.Dequeue(); | ||
653 | res = item; | ||
654 | } | ||
655 | } | ||
656 | else | ||
657 | { | ||
658 | res = CreateEmptyEventResponse(); | ||
659 | } | ||
660 | return res; | ||
661 | } | ||
662 | |||
663 | /// <summary> | ||
664 | /// | ||
665 | /// </summary> | ||
666 | /// <param name="caps"></param> | ||
667 | /// <param name="ipAddressPort"></param> | ||
668 | /// <returns></returns> | ||
669 | public string CreateEstablishAgentComms(string caps, string ipAddressPort) | ||
670 | { | ||
671 | LLSDCapEvent eventItem = new LLSDCapEvent(); | ||
672 | eventItem.id = m_eventQueueCount; | ||
673 | //should be creating a EstablishAgentComms item, but there isn't a class for it yet | ||
674 | eventItem.events.Array.Add(new LLSDEmpty()); | ||
675 | string res = LLSDHelpers.SerialiseLLSDReply(eventItem); | ||
676 | m_eventQueueCount++; | ||
677 | |||
678 | m_capsEventQueue.Enqueue(res); | ||
679 | return res; | ||
680 | } | ||
681 | |||
682 | /// <summary> | ||
683 | /// | ||
684 | /// </summary> | ||
685 | /// <returns></returns> | ||
686 | public string CreateEmptyEventResponse() | ||
687 | { | ||
688 | LLSDCapEvent eventItem = new LLSDCapEvent(); | ||
689 | eventItem.id = m_eventQueueCount; | ||
690 | eventItem.events.Array.Add(new LLSDEmpty()); | ||
691 | string res = LLSDHelpers.SerialiseLLSDReply(eventItem); | ||
692 | m_eventQueueCount++; | ||
693 | return res; | ||
694 | } | ||
695 | |||
696 | #endregion | ||
697 | |||
698 | /// <summary> | ||
699 | /// Called by the script task update handler. Provides a URL to which the client can upload a new asset. | ||
700 | /// </summary> | ||
701 | /// <param name="request"></param> | ||
702 | /// <param name="path"></param> | ||
703 | /// <param name="param"></param> | ||
704 | /// <param name="httpRequest">HTTP request header object</param> | ||
705 | /// <param name="httpResponse">HTTP response header object</param> | ||
706 | /// <returns></returns> | ||
707 | public string ScriptTaskInventory(string request, string path, string param, | ||
708 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
709 | { | ||
710 | try | ||
711 | { | ||
712 | m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName); | ||
713 | //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); | ||
714 | |||
715 | Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
716 | LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); | ||
717 | LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest); | ||
718 | |||
719 | string capsBase = "/CAPS/" + m_capsObjectPath; | ||
720 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
721 | |||
722 | TaskInventoryScriptUpdater uploader = | ||
723 | new TaskInventoryScriptUpdater( | ||
724 | llsdUpdateRequest.item_id, | ||
725 | llsdUpdateRequest.task_id, | ||
726 | llsdUpdateRequest.is_script_running, | ||
727 | capsBase + uploaderPath, | ||
728 | m_httpListener, | ||
729 | m_dumpAssetsToFile); | ||
730 | uploader.OnUpLoad += TaskScriptUpdated; | ||
731 | |||
732 | m_httpListener.AddStreamHandler( | ||
733 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
734 | |||
735 | string protocol = "http://"; | ||
736 | |||
737 | if (m_httpListener.UseSSL) | ||
738 | protocol = "https://"; | ||
739 | |||
740 | string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + | ||
741 | uploaderPath; | ||
742 | |||
743 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | ||
744 | uploadResponse.uploader = uploaderURL; | ||
745 | uploadResponse.state = "upload"; | ||
746 | |||
747 | // m_log.InfoFormat("[CAPS]: " + | ||
748 | // "ScriptTaskInventory response: {0}", | ||
749 | // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); | ||
750 | |||
751 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | ||
752 | } | ||
753 | catch (Exception e) | ||
754 | { | ||
755 | m_log.Error("[CAPS]: " + e.ToString()); | ||
756 | } | ||
757 | |||
758 | return null; | ||
759 | } | ||
760 | |||
761 | public string UploadBakedTexture(string request, string path, | ||
762 | string param, OSHttpRequest httpRequest, | ||
763 | OSHttpResponse httpResponse) | ||
764 | { | ||
765 | try | ||
766 | { | ||
767 | // m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + | ||
768 | // m_regionName); | ||
769 | |||
770 | string capsBase = "/CAPS/" + m_capsObjectPath; | ||
771 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
772 | |||
773 | BakedTextureUploader uploader = | ||
774 | new BakedTextureUploader(capsBase + uploaderPath, | ||
775 | m_httpListener); | ||
776 | uploader.OnUpLoad += BakedTextureUploaded; | ||
777 | |||
778 | m_httpListener.AddStreamHandler( | ||
779 | new BinaryStreamHandler("POST", capsBase + uploaderPath, | ||
780 | uploader.uploaderCaps)); | ||
781 | |||
782 | string protocol = "http://"; | ||
783 | |||
784 | if (m_httpListener.UseSSL) | ||
785 | protocol = "https://"; | ||
786 | |||
787 | string uploaderURL = protocol + m_httpListenerHostName + ":" + | ||
788 | m_httpListenPort.ToString() + capsBase + uploaderPath; | ||
789 | |||
790 | LLSDAssetUploadResponse uploadResponse = | ||
791 | new LLSDAssetUploadResponse(); | ||
792 | uploadResponse.uploader = uploaderURL; | ||
793 | uploadResponse.state = "upload"; | ||
794 | |||
795 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | ||
796 | } | ||
797 | catch (Exception e) | ||
798 | { | ||
799 | m_log.Error("[CAPS]: " + e.ToString()); | ||
800 | } | ||
801 | |||
802 | return null; | ||
803 | } | ||
804 | |||
805 | /// <summary> | ||
806 | /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. | ||
807 | /// </summary> | ||
808 | /// <param name="request"></param> | ||
809 | /// <param name="path"></param> | ||
810 | /// <param name="param"></param> | ||
811 | /// <returns></returns> | ||
812 | public string NoteCardAgentInventory(string request, string path, string param, | ||
813 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
814 | { | ||
815 | //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request); | ||
816 | //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request); | ||
817 | |||
818 | //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); | ||
819 | Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
820 | LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); | ||
821 | LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); | ||
822 | |||
823 | string capsBase = "/CAPS/" + m_capsObjectPath; | ||
824 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
825 | |||
826 | ItemUpdater uploader = | ||
827 | new ItemUpdater(llsdRequest.item_id, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); | ||
828 | uploader.OnUpLoad += ItemUpdated; | ||
829 | |||
830 | m_httpListener.AddStreamHandler( | ||
831 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
832 | |||
833 | string protocol = "http://"; | ||
834 | |||
835 | if (m_httpListener.UseSSL) | ||
836 | protocol = "https://"; | ||
837 | |||
838 | string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + | ||
839 | uploaderPath; | ||
840 | |||
841 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | ||
842 | uploadResponse.uploader = uploaderURL; | ||
843 | uploadResponse.state = "upload"; | ||
844 | |||
845 | // m_log.InfoFormat("[CAPS]: " + | ||
846 | // "NoteCardAgentInventory response: {0}", | ||
847 | // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); | ||
848 | |||
849 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | ||
850 | } | ||
851 | |||
852 | /// <summary> | ||
853 | /// | ||
854 | /// </summary> | ||
855 | /// <param name="llsdRequest"></param> | ||
856 | /// <returns></returns> | ||
857 | public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) | ||
858 | { | ||
859 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); | ||
860 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); | ||
861 | |||
862 | if (llsdRequest.asset_type == "texture" || | ||
863 | llsdRequest.asset_type == "animation" || | ||
864 | llsdRequest.asset_type == "sound") | ||
865 | { | ||
866 | IClientAPI client = null; | ||
867 | IScene scene = null; | ||
868 | if (GetClient != null) | ||
869 | { | ||
870 | client = GetClient(m_agentID); | ||
871 | scene = client.Scene; | ||
872 | |||
873 | IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>(); | ||
874 | |||
875 | if (mm != null) | ||
876 | { | ||
877 | if (!mm.UploadCovered(client, mm.UploadCharge)) | ||
878 | { | ||
879 | if (client != null) | ||
880 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | ||
881 | |||
882 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | ||
883 | errorResponse.uploader = ""; | ||
884 | errorResponse.state = "error"; | ||
885 | return errorResponse; | ||
886 | } | ||
887 | } | ||
888 | } | ||
889 | } | ||
890 | |||
891 | |||
892 | string assetName = llsdRequest.name; | ||
893 | string assetDes = llsdRequest.description; | ||
894 | string capsBase = "/CAPS/" + m_capsObjectPath; | ||
895 | UUID newAsset = UUID.Random(); | ||
896 | UUID newInvItem = UUID.Random(); | ||
897 | UUID parentFolder = llsdRequest.folder_id; | ||
898 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
899 | |||
900 | AssetUploader uploader = | ||
901 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | ||
902 | llsdRequest.asset_type, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); | ||
903 | m_httpListener.AddStreamHandler( | ||
904 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
905 | |||
906 | string protocol = "http://"; | ||
907 | |||
908 | if (m_httpListener.UseSSL) | ||
909 | protocol = "https://"; | ||
910 | |||
911 | string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + | ||
912 | uploaderPath; | ||
913 | |||
914 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | ||
915 | uploadResponse.uploader = uploaderURL; | ||
916 | uploadResponse.state = "upload"; | ||
917 | uploader.OnUpLoad += UploadCompleteHandler; | ||
918 | return uploadResponse; | ||
919 | } | ||
920 | |||
921 | /// <summary> | ||
922 | /// | ||
923 | /// </summary> | ||
924 | /// <param name="assetID"></param> | ||
925 | /// <param name="inventoryItem"></param> | ||
926 | /// <param name="data"></param> | ||
927 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | ||
928 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | ||
929 | string assetType) | ||
930 | { | ||
931 | sbyte assType = 0; | ||
932 | sbyte inType = 0; | ||
933 | |||
934 | if (inventoryType == "sound") | ||
935 | { | ||
936 | inType = 1; | ||
937 | assType = 1; | ||
938 | } | ||
939 | else if (inventoryType == "animation") | ||
940 | { | ||
941 | inType = 19; | ||
942 | assType = 20; | ||
943 | } | ||
944 | else if (inventoryType == "wearable") | ||
945 | { | ||
946 | inType = 18; | ||
947 | switch (assetType) | ||
948 | { | ||
949 | case "bodypart": | ||
950 | assType = 13; | ||
951 | break; | ||
952 | case "clothing": | ||
953 | assType = 5; | ||
954 | break; | ||
955 | } | ||
956 | } | ||
957 | |||
958 | AssetBase asset; | ||
959 | asset = new AssetBase(assetID, assetName, assType, m_agentID.ToString()); | ||
960 | asset.Data = data; | ||
961 | if (AddNewAsset != null) | ||
962 | AddNewAsset(asset); | ||
963 | else if (m_assetCache != null) | ||
964 | m_assetCache.Store(asset); | ||
965 | |||
966 | InventoryItemBase item = new InventoryItemBase(); | ||
967 | item.Owner = m_agentID; | ||
968 | item.CreatorId = m_agentID.ToString(); | ||
969 | item.CreatorData = String.Empty; | ||
970 | item.ID = inventoryItem; | ||
971 | item.AssetID = asset.FullID; | ||
972 | item.Description = assetDescription; | ||
973 | item.Name = assetName; | ||
974 | item.AssetType = assType; | ||
975 | item.InvType = inType; | ||
976 | item.Folder = parentFolder; | ||
977 | item.CurrentPermissions = (uint)PermissionMask.All; | ||
978 | item.BasePermissions = (uint)PermissionMask.All; | ||
979 | item.EveryOnePermissions = 0; | ||
980 | item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); | ||
981 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
982 | |||
983 | if (AddNewInventoryItem != null) | ||
984 | { | ||
985 | AddNewInventoryItem(m_agentID, item); | ||
986 | } | ||
987 | } | ||
988 | |||
989 | public void BakedTextureUploaded(UUID assetID, byte[] data) | ||
990 | { | ||
991 | // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); | ||
992 | |||
993 | AssetBase asset; | ||
994 | asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); | ||
995 | asset.Data = data; | ||
996 | asset.Temporary = true; | ||
997 | asset.Local = ! m_persistBakedTextures; // Local assets aren't persisted, non-local are | ||
998 | m_assetCache.Store(asset); | ||
999 | } | ||
1000 | |||
1001 | /// <summary> | ||
1002 | /// Called when new asset data for an agent inventory item update has been uploaded. | ||
1003 | /// </summary> | ||
1004 | /// <param name="itemID">Item to update</param> | ||
1005 | /// <param name="data">New asset data</param> | ||
1006 | /// <returns></returns> | ||
1007 | public UUID ItemUpdated(UUID itemID, byte[] data) | ||
1008 | { | ||
1009 | if (ItemUpdatedCall != null) | ||
1010 | { | ||
1011 | return ItemUpdatedCall(m_agentID, itemID, data); | ||
1012 | } | ||
1013 | |||
1014 | return UUID.Zero; | ||
1015 | } | ||
1016 | |||
1017 | /// <summary> | ||
1018 | /// Called when new asset data for an agent inventory item update has been uploaded. | ||
1019 | /// </summary> | ||
1020 | /// <param name="itemID">Item to update</param> | ||
1021 | /// <param name="primID">Prim containing item to update</param> | ||
1022 | /// <param name="isScriptRunning">Signals whether the script to update is currently running</param> | ||
1023 | /// <param name="data">New asset data</param> | ||
1024 | public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors) | ||
1025 | { | ||
1026 | if (TaskScriptUpdatedCall != null) | ||
1027 | { | ||
1028 | ArrayList e = TaskScriptUpdatedCall(m_agentID, itemID, primID, isScriptRunning, data); | ||
1029 | foreach (Object item in e) | ||
1030 | errors.Add(item); | ||
1031 | } | ||
1032 | } | ||
1033 | |||
1034 | public class AssetUploader | ||
1035 | { | ||
1036 | public event UpLoadedAsset OnUpLoad; | ||
1037 | private UpLoadedAsset handlerUpLoad = null; | ||
1038 | |||
1039 | private string uploaderPath = String.Empty; | ||
1040 | private UUID newAssetID; | ||
1041 | private UUID inventoryItemID; | ||
1042 | private UUID parentFolder; | ||
1043 | private IHttpServer httpListener; | ||
1044 | private bool m_dumpAssetsToFile; | ||
1045 | private string m_assetName = String.Empty; | ||
1046 | private string m_assetDes = String.Empty; | ||
1047 | |||
1048 | private string m_invType = String.Empty; | ||
1049 | private string m_assetType = String.Empty; | ||
1050 | |||
1051 | public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, | ||
1052 | UUID parentFolderID, string invType, string assetType, string path, | ||
1053 | IHttpServer httpServer, bool dumpAssetsToFile) | ||
1054 | { | ||
1055 | m_assetName = assetName; | ||
1056 | m_assetDes = description; | ||
1057 | newAssetID = assetID; | ||
1058 | inventoryItemID = inventoryItem; | ||
1059 | uploaderPath = path; | ||
1060 | httpListener = httpServer; | ||
1061 | parentFolder = parentFolderID; | ||
1062 | m_assetType = assetType; | ||
1063 | m_invType = invType; | ||
1064 | m_dumpAssetsToFile = dumpAssetsToFile; | ||
1065 | } | ||
1066 | |||
1067 | /// <summary> | ||
1068 | /// | ||
1069 | /// </summary> | ||
1070 | /// <param name="data"></param> | ||
1071 | /// <param name="path"></param> | ||
1072 | /// <param name="param"></param> | ||
1073 | /// <returns></returns> | ||
1074 | public string uploaderCaps(byte[] data, string path, string param) | ||
1075 | { | ||
1076 | UUID inv = inventoryItemID; | ||
1077 | string res = String.Empty; | ||
1078 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | ||
1079 | uploadComplete.new_asset = newAssetID.ToString(); | ||
1080 | uploadComplete.new_inventory_item = inv; | ||
1081 | uploadComplete.state = "complete"; | ||
1082 | |||
1083 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1084 | |||
1085 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1086 | |||
1087 | // TODO: probably make this a better set of extensions here | ||
1088 | string extension = ".jp2"; | ||
1089 | if (m_invType != "image") | ||
1090 | { | ||
1091 | extension = ".dat"; | ||
1092 | } | ||
1093 | |||
1094 | if (m_dumpAssetsToFile) | ||
1095 | { | ||
1096 | SaveAssetToFile(m_assetName + extension, data); | ||
1097 | } | ||
1098 | handlerUpLoad = OnUpLoad; | ||
1099 | if (handlerUpLoad != null) | ||
1100 | { | ||
1101 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); | ||
1102 | } | ||
1103 | |||
1104 | return res; | ||
1105 | } | ||
1106 | ///Left this in and commented in case there are unforseen issues | ||
1107 | //private void SaveAssetToFile(string filename, byte[] data) | ||
1108 | //{ | ||
1109 | // FileStream fs = File.Create(filename); | ||
1110 | // BinaryWriter bw = new BinaryWriter(fs); | ||
1111 | // bw.Write(data); | ||
1112 | // bw.Close(); | ||
1113 | // fs.Close(); | ||
1114 | //} | ||
1115 | private static void SaveAssetToFile(string filename, byte[] data) | ||
1116 | { | ||
1117 | string assetPath = "UserAssets"; | ||
1118 | if (!Directory.Exists(assetPath)) | ||
1119 | { | ||
1120 | Directory.CreateDirectory(assetPath); | ||
1121 | } | ||
1122 | FileStream fs = File.Create(Path.Combine(assetPath, Util.safeFileName(filename))); | ||
1123 | BinaryWriter bw = new BinaryWriter(fs); | ||
1124 | bw.Write(data); | ||
1125 | bw.Close(); | ||
1126 | fs.Close(); | ||
1127 | } | ||
1128 | } | ||
1129 | |||
1130 | /// <summary> | ||
1131 | /// This class is a callback invoked when a client sends asset data to | ||
1132 | /// an agent inventory notecard update url | ||
1133 | /// </summary> | ||
1134 | public class ItemUpdater | ||
1135 | { | ||
1136 | public event UpdateItem OnUpLoad; | ||
1137 | |||
1138 | private UpdateItem handlerUpdateItem = null; | ||
1139 | |||
1140 | private string uploaderPath = String.Empty; | ||
1141 | private UUID inventoryItemID; | ||
1142 | private IHttpServer httpListener; | ||
1143 | private bool m_dumpAssetToFile; | ||
1144 | |||
1145 | public ItemUpdater(UUID inventoryItem, string path, IHttpServer httpServer, bool dumpAssetToFile) | ||
1146 | { | ||
1147 | m_dumpAssetToFile = dumpAssetToFile; | ||
1148 | |||
1149 | inventoryItemID = inventoryItem; | ||
1150 | uploaderPath = path; | ||
1151 | httpListener = httpServer; | ||
1152 | } | ||
1153 | |||
1154 | /// <summary> | ||
1155 | /// | ||
1156 | /// </summary> | ||
1157 | /// <param name="data"></param> | ||
1158 | /// <param name="path"></param> | ||
1159 | /// <param name="param"></param> | ||
1160 | /// <returns></returns> | ||
1161 | public string uploaderCaps(byte[] data, string path, string param) | ||
1162 | { | ||
1163 | UUID inv = inventoryItemID; | ||
1164 | string res = String.Empty; | ||
1165 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | ||
1166 | UUID assetID = UUID.Zero; | ||
1167 | handlerUpdateItem = OnUpLoad; | ||
1168 | if (handlerUpdateItem != null) | ||
1169 | { | ||
1170 | assetID = handlerUpdateItem(inv, data); | ||
1171 | } | ||
1172 | |||
1173 | uploadComplete.new_asset = assetID.ToString(); | ||
1174 | uploadComplete.new_inventory_item = inv; | ||
1175 | uploadComplete.state = "complete"; | ||
1176 | |||
1177 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1178 | |||
1179 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1180 | |||
1181 | if (m_dumpAssetToFile) | ||
1182 | { | ||
1183 | SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); | ||
1184 | } | ||
1185 | |||
1186 | return res; | ||
1187 | } | ||
1188 | ///Left this in and commented in case there are unforseen issues | ||
1189 | //private void SaveAssetToFile(string filename, byte[] data) | ||
1190 | //{ | ||
1191 | // FileStream fs = File.Create(filename); | ||
1192 | // BinaryWriter bw = new BinaryWriter(fs); | ||
1193 | // bw.Write(data); | ||
1194 | // bw.Close(); | ||
1195 | // fs.Close(); | ||
1196 | //} | ||
1197 | private static void SaveAssetToFile(string filename, byte[] data) | ||
1198 | { | ||
1199 | string assetPath = "UserAssets"; | ||
1200 | if (!Directory.Exists(assetPath)) | ||
1201 | { | ||
1202 | Directory.CreateDirectory(assetPath); | ||
1203 | } | ||
1204 | FileStream fs = File.Create(Path.Combine(assetPath, filename)); | ||
1205 | BinaryWriter bw = new BinaryWriter(fs); | ||
1206 | bw.Write(data); | ||
1207 | bw.Close(); | ||
1208 | fs.Close(); | ||
1209 | } | ||
1210 | } | ||
1211 | |||
1212 | /// <summary> | ||
1213 | /// This class is a callback invoked when a client sends asset data to | ||
1214 | /// a task inventory script update url | ||
1215 | /// </summary> | ||
1216 | public class TaskInventoryScriptUpdater | ||
1217 | { | ||
1218 | public event UpdateTaskScript OnUpLoad; | ||
1219 | |||
1220 | private UpdateTaskScript handlerUpdateTaskScript = null; | ||
1221 | |||
1222 | private string uploaderPath = String.Empty; | ||
1223 | private UUID inventoryItemID; | ||
1224 | private UUID primID; | ||
1225 | private bool isScriptRunning; | ||
1226 | private IHttpServer httpListener; | ||
1227 | private bool m_dumpAssetToFile; | ||
1228 | |||
1229 | public TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning, | ||
1230 | string path, IHttpServer httpServer, bool dumpAssetToFile) | ||
1231 | { | ||
1232 | m_dumpAssetToFile = dumpAssetToFile; | ||
1233 | |||
1234 | this.inventoryItemID = inventoryItemID; | ||
1235 | this.primID = primID; | ||
1236 | |||
1237 | // This comes in over the packet as an integer, but actually appears to be treated as a bool | ||
1238 | this.isScriptRunning = (0 == isScriptRunning ? false : true); | ||
1239 | |||
1240 | uploaderPath = path; | ||
1241 | httpListener = httpServer; | ||
1242 | } | ||
1243 | |||
1244 | /// <summary> | ||
1245 | /// | ||
1246 | /// </summary> | ||
1247 | /// <param name="data"></param> | ||
1248 | /// <param name="path"></param> | ||
1249 | /// <param name="param"></param> | ||
1250 | /// <returns></returns> | ||
1251 | public string uploaderCaps(byte[] data, string path, string param) | ||
1252 | { | ||
1253 | try | ||
1254 | { | ||
1255 | // m_log.InfoFormat("[CAPS]: " + | ||
1256 | // "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", | ||
1257 | // data, path, param)); | ||
1258 | |||
1259 | string res = String.Empty; | ||
1260 | LLSDTaskScriptUploadComplete uploadComplete = new LLSDTaskScriptUploadComplete(); | ||
1261 | |||
1262 | ArrayList errors = new ArrayList(); | ||
1263 | handlerUpdateTaskScript = OnUpLoad; | ||
1264 | if (handlerUpdateTaskScript != null) | ||
1265 | { | ||
1266 | handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data, ref errors); | ||
1267 | } | ||
1268 | |||
1269 | uploadComplete.new_asset = inventoryItemID; | ||
1270 | uploadComplete.compiled = errors.Count > 0 ? false : true; | ||
1271 | uploadComplete.state = "complete"; | ||
1272 | uploadComplete.errors = new OSDArray(); | ||
1273 | uploadComplete.errors.Array = errors; | ||
1274 | |||
1275 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1276 | |||
1277 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1278 | |||
1279 | if (m_dumpAssetToFile) | ||
1280 | { | ||
1281 | SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); | ||
1282 | } | ||
1283 | |||
1284 | // m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); | ||
1285 | |||
1286 | return res; | ||
1287 | } | ||
1288 | catch (Exception e) | ||
1289 | { | ||
1290 | m_log.Error("[CAPS]: " + e.ToString()); | ||
1291 | } | ||
1292 | |||
1293 | // XXX Maybe this should be some meaningful error packet | ||
1294 | return null; | ||
1295 | } | ||
1296 | ///Left this in and commented in case there are unforseen issues | ||
1297 | //private void SaveAssetToFile(string filename, byte[] data) | ||
1298 | //{ | ||
1299 | // FileStream fs = File.Create(filename); | ||
1300 | // BinaryWriter bw = new BinaryWriter(fs); | ||
1301 | // bw.Write(data); | ||
1302 | // bw.Close(); | ||
1303 | // fs.Close(); | ||
1304 | //} | ||
1305 | private static void SaveAssetToFile(string filename, byte[] data) | ||
1306 | { | ||
1307 | string assetPath = "UserAssets"; | ||
1308 | if (!Directory.Exists(assetPath)) | ||
1309 | { | ||
1310 | Directory.CreateDirectory(assetPath); | ||
1311 | } | ||
1312 | FileStream fs = File.Create(Path.Combine(assetPath, filename)); | ||
1313 | BinaryWriter bw = new BinaryWriter(fs); | ||
1314 | bw.Write(data); | ||
1315 | bw.Close(); | ||
1316 | fs.Close(); | ||
1317 | } | ||
1318 | } | ||
1319 | |||
1320 | public class BakedTextureUploader | ||
1321 | { | ||
1322 | public event UploadedBakedTexture OnUpLoad; | ||
1323 | private UploadedBakedTexture handlerUpLoad = null; | ||
1324 | |||
1325 | private string uploaderPath = String.Empty; | ||
1326 | private UUID newAssetID; | ||
1327 | private IHttpServer httpListener; | ||
1328 | |||
1329 | public BakedTextureUploader(string path, IHttpServer httpServer) | ||
1330 | { | ||
1331 | newAssetID = UUID.Random(); | ||
1332 | uploaderPath = path; | ||
1333 | httpListener = httpServer; | ||
1334 | // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); | ||
1335 | } | ||
1336 | |||
1337 | /// <summary> | ||
1338 | /// | ||
1339 | /// </summary> | ||
1340 | /// <param name="data"></param> | ||
1341 | /// <param name="path"></param> | ||
1342 | /// <param name="param"></param> | ||
1343 | /// <returns></returns> | ||
1344 | public string uploaderCaps(byte[] data, string path, string param) | ||
1345 | { | ||
1346 | handlerUpLoad = OnUpLoad; | ||
1347 | if (handlerUpLoad != null) | ||
1348 | { | ||
1349 | Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); }); | ||
1350 | } | ||
1351 | |||
1352 | string res = String.Empty; | ||
1353 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | ||
1354 | uploadComplete.new_asset = newAssetID.ToString(); | ||
1355 | uploadComplete.new_inventory_item = UUID.Zero; | ||
1356 | uploadComplete.state = "complete"; | ||
1357 | |||
1358 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1359 | |||
1360 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1361 | |||
1362 | // m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID); | ||
1363 | |||
1364 | return res; | ||
1365 | } | ||
1366 | } | ||
1367 | } | ||
1368 | } | ||
diff --git a/OpenSim/Capabilities/CapsHandlers.cs b/OpenSim/Capabilities/CapsHandlers.cs new file mode 100644 index 0000000..e1c800e --- /dev/null +++ b/OpenSim/Capabilities/CapsHandlers.cs | |||
@@ -0,0 +1,171 @@ | |||
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.Collections; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Framework.Servers; | ||
31 | using OpenSim.Framework.Servers.HttpServer; | ||
32 | |||
33 | namespace OpenSim.Framework.Capabilities | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// CapsHandlers is a cap handler container but also takes | ||
37 | /// care of adding and removing cap handlers to and from the | ||
38 | /// supplied BaseHttpServer. | ||
39 | /// </summary> | ||
40 | public class CapsHandlers | ||
41 | { | ||
42 | private Dictionary <string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>(); | ||
43 | private IHttpServer m_httpListener; | ||
44 | private string m_httpListenerHostName; | ||
45 | private uint m_httpListenerPort; | ||
46 | private bool m_useSSL = false; | ||
47 | |||
48 | /// <summary></summary> | ||
49 | /// CapsHandlers is a cap handler container but also takes | ||
50 | /// care of adding and removing cap handlers to and from the | ||
51 | /// supplied BaseHttpServer. | ||
52 | /// </summary> | ||
53 | /// <param name="httpListener">base HTTP server</param> | ||
54 | /// <param name="httpListenerHostname">host name of the HTTP | ||
55 | /// server</param> | ||
56 | /// <param name="httpListenerPort">HTTP port</param> | ||
57 | public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) | ||
58 | : this (httpListener,httpListenerHostname,httpListenerPort, false) | ||
59 | { | ||
60 | } | ||
61 | |||
62 | /// <summary></summary> | ||
63 | /// CapsHandlers is a cap handler container but also takes | ||
64 | /// care of adding and removing cap handlers to and from the | ||
65 | /// supplied BaseHttpServer. | ||
66 | /// </summary> | ||
67 | /// <param name="httpListener">base HTTP server</param> | ||
68 | /// <param name="httpListenerHostname">host name of the HTTP | ||
69 | /// server</param> | ||
70 | /// <param name="httpListenerPort">HTTP port</param> | ||
71 | public CapsHandlers(IHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https) | ||
72 | { | ||
73 | m_httpListener = httpListener; | ||
74 | m_httpListenerHostName = httpListenerHostname; | ||
75 | m_httpListenerPort = httpListenerPort; | ||
76 | m_useSSL = https; | ||
77 | if (httpListener != null && m_useSSL) | ||
78 | { | ||
79 | m_httpListenerHostName = httpListener.SSLCommonName; | ||
80 | m_httpListenerPort = httpListener.SSLPort; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Remove the cap handler for a capability. | ||
86 | /// </summary> | ||
87 | /// <param name="capsName">name of the capability of the cap | ||
88 | /// handler to be removed</param> | ||
89 | public void Remove(string capsName) | ||
90 | { | ||
91 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); | ||
92 | m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path); | ||
93 | m_capsHandlers.Remove(capsName); | ||
94 | } | ||
95 | |||
96 | public bool ContainsCap(string cap) | ||
97 | { | ||
98 | return m_capsHandlers.ContainsKey(cap); | ||
99 | } | ||
100 | |||
101 | /// <summary> | ||
102 | /// The indexer allows us to treat the CapsHandlers object | ||
103 | /// in an intuitive dictionary like way. | ||
104 | /// </summary> | ||
105 | /// <Remarks> | ||
106 | /// The indexer will throw an exception when you try to | ||
107 | /// retrieve a cap handler for a cap that is not contained in | ||
108 | /// CapsHandlers. | ||
109 | /// </Remarks> | ||
110 | public IRequestHandler this[string idx] | ||
111 | { | ||
112 | get | ||
113 | { | ||
114 | return m_capsHandlers[idx]; | ||
115 | } | ||
116 | |||
117 | set | ||
118 | { | ||
119 | if (m_capsHandlers.ContainsKey(idx)) | ||
120 | { | ||
121 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); | ||
122 | m_capsHandlers.Remove(idx); | ||
123 | } | ||
124 | |||
125 | if (null == value) return; | ||
126 | |||
127 | m_capsHandlers[idx] = value; | ||
128 | m_httpListener.AddStreamHandler(value); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Return the list of cap names for which this CapsHandlers | ||
134 | /// object contains cap handlers. | ||
135 | /// </summary> | ||
136 | public string[] Caps | ||
137 | { | ||
138 | get | ||
139 | { | ||
140 | string[] __keys = new string[m_capsHandlers.Keys.Count]; | ||
141 | m_capsHandlers.Keys.CopyTo(__keys, 0); | ||
142 | return __keys; | ||
143 | } | ||
144 | } | ||
145 | |||
146 | /// <summary> | ||
147 | /// Return an LLSD-serializable Hashtable describing the | ||
148 | /// capabilities and their handler details. | ||
149 | /// </summary> | ||
150 | public Hashtable CapsDetails | ||
151 | { | ||
152 | get | ||
153 | { | ||
154 | Hashtable caps = new Hashtable(); | ||
155 | string protocol = "http://"; | ||
156 | |||
157 | if (m_useSSL) | ||
158 | protocol = "https://"; | ||
159 | |||
160 | string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); | ||
161 | foreach (string capsName in m_capsHandlers.Keys) | ||
162 | { | ||
163 | // skip SEED cap | ||
164 | if ("SEED" == capsName) continue; | ||
165 | caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; | ||
166 | } | ||
167 | return caps; | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | } | ||
diff --git a/OpenSim/Capabilities/LLSD.cs b/OpenSim/Capabilities/LLSD.cs new file mode 100644 index 0000000..eec9e61 --- /dev/null +++ b/OpenSim/Capabilities/LLSD.cs | |||
@@ -0,0 +1,679 @@ | |||
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.Globalization; | ||
31 | using System.IO; | ||
32 | using System.Security.Cryptography; | ||
33 | using System.Text; | ||
34 | using System.Xml; | ||
35 | using OpenMetaverse; | ||
36 | |||
37 | namespace OpenSim.Framework.Capabilities | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Borrowed from (a older version of) libsl for now, as their new llsd code doesn't work we our decoding code. | ||
41 | /// </summary> | ||
42 | public static class LLSD | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | public class LLSDParseException : Exception | ||
48 | { | ||
49 | public LLSDParseException(string message) : base(message) | ||
50 | { | ||
51 | } | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// | ||
56 | /// </summary> | ||
57 | public class LLSDSerializeException : Exception | ||
58 | { | ||
59 | public LLSDSerializeException(string message) : base(message) | ||
60 | { | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// | ||
66 | /// </summary> | ||
67 | /// <param name="b"></param> | ||
68 | /// <returns></returns> | ||
69 | public static object LLSDDeserialize(byte[] b) | ||
70 | { | ||
71 | return LLSDDeserialize(new MemoryStream(b, false)); | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// | ||
76 | /// </summary> | ||
77 | /// <param name="st"></param> | ||
78 | /// <returns></returns> | ||
79 | public static object LLSDDeserialize(Stream st) | ||
80 | { | ||
81 | XmlTextReader reader = new XmlTextReader(st); | ||
82 | reader.Read(); | ||
83 | SkipWS(reader); | ||
84 | |||
85 | if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "llsd") | ||
86 | throw new LLSDParseException("Expected <llsd>"); | ||
87 | |||
88 | reader.Read(); | ||
89 | object ret = LLSDParseOne(reader); | ||
90 | SkipWS(reader); | ||
91 | |||
92 | if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "llsd") | ||
93 | throw new LLSDParseException("Expected </llsd>"); | ||
94 | |||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | /// <summary> | ||
99 | /// | ||
100 | /// </summary> | ||
101 | /// <param name="obj"></param> | ||
102 | /// <returns></returns> | ||
103 | public static byte[] LLSDSerialize(object obj) | ||
104 | { | ||
105 | StringWriter sw = new StringWriter(); | ||
106 | XmlTextWriter writer = new XmlTextWriter(sw); | ||
107 | writer.Formatting = Formatting.None; | ||
108 | |||
109 | writer.WriteStartElement(String.Empty, "llsd", String.Empty); | ||
110 | LLSDWriteOne(writer, obj); | ||
111 | writer.WriteEndElement(); | ||
112 | |||
113 | writer.Close(); | ||
114 | |||
115 | return Util.UTF8.GetBytes(sw.ToString()); | ||
116 | } | ||
117 | |||
118 | /// <summary> | ||
119 | /// | ||
120 | /// </summary> | ||
121 | /// <param name="writer"></param> | ||
122 | /// <param name="obj"></param> | ||
123 | public static void LLSDWriteOne(XmlTextWriter writer, object obj) | ||
124 | { | ||
125 | if (obj == null) | ||
126 | { | ||
127 | writer.WriteStartElement(String.Empty, "undef", String.Empty); | ||
128 | writer.WriteEndElement(); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | if (obj is string) | ||
133 | { | ||
134 | writer.WriteStartElement(String.Empty, "string", String.Empty); | ||
135 | writer.WriteString((string) obj); | ||
136 | writer.WriteEndElement(); | ||
137 | } | ||
138 | else if (obj is int) | ||
139 | { | ||
140 | writer.WriteStartElement(String.Empty, "integer", String.Empty); | ||
141 | writer.WriteString(obj.ToString()); | ||
142 | writer.WriteEndElement(); | ||
143 | } | ||
144 | else if (obj is double) | ||
145 | { | ||
146 | writer.WriteStartElement(String.Empty, "real", String.Empty); | ||
147 | writer.WriteString(obj.ToString()); | ||
148 | writer.WriteEndElement(); | ||
149 | } | ||
150 | else if (obj is bool) | ||
151 | { | ||
152 | bool b = (bool) obj; | ||
153 | writer.WriteStartElement(String.Empty, "boolean", String.Empty); | ||
154 | writer.WriteString(b ? "1" : "0"); | ||
155 | writer.WriteEndElement(); | ||
156 | } | ||
157 | else if (obj is ulong) | ||
158 | { | ||
159 | throw new Exception("ulong in LLSD is currently not implemented, fix me!"); | ||
160 | } | ||
161 | else if (obj is UUID) | ||
162 | { | ||
163 | UUID u = (UUID) obj; | ||
164 | writer.WriteStartElement(String.Empty, "uuid", String.Empty); | ||
165 | writer.WriteString(u.ToString()); | ||
166 | writer.WriteEndElement(); | ||
167 | } | ||
168 | else if (obj is Hashtable) | ||
169 | { | ||
170 | Hashtable h = obj as Hashtable; | ||
171 | writer.WriteStartElement(String.Empty, "map", String.Empty); | ||
172 | foreach (string key in h.Keys) | ||
173 | { | ||
174 | writer.WriteStartElement(String.Empty, "key", String.Empty); | ||
175 | writer.WriteString(key); | ||
176 | writer.WriteEndElement(); | ||
177 | LLSDWriteOne(writer, h[key]); | ||
178 | } | ||
179 | writer.WriteEndElement(); | ||
180 | } | ||
181 | else if (obj is ArrayList) | ||
182 | { | ||
183 | ArrayList a = obj as ArrayList; | ||
184 | writer.WriteStartElement(String.Empty, "array", String.Empty); | ||
185 | foreach (object item in a) | ||
186 | { | ||
187 | LLSDWriteOne(writer, item); | ||
188 | } | ||
189 | writer.WriteEndElement(); | ||
190 | } | ||
191 | else if (obj is byte[]) | ||
192 | { | ||
193 | byte[] b = obj as byte[]; | ||
194 | writer.WriteStartElement(String.Empty, "binary", String.Empty); | ||
195 | |||
196 | writer.WriteStartAttribute(String.Empty, "encoding", String.Empty); | ||
197 | writer.WriteString("base64"); | ||
198 | writer.WriteEndAttribute(); | ||
199 | |||
200 | //// Calculate the length of the base64 output | ||
201 | //long length = (long)(4.0d * b.Length / 3.0d); | ||
202 | //if (length % 4 != 0) length += 4 - (length % 4); | ||
203 | |||
204 | //// Create the char[] for base64 output and fill it | ||
205 | //char[] tmp = new char[length]; | ||
206 | //int i = Convert.ToBase64CharArray(b, 0, b.Length, tmp, 0); | ||
207 | |||
208 | //writer.WriteString(new String(tmp)); | ||
209 | |||
210 | writer.WriteString(Convert.ToBase64String(b)); | ||
211 | writer.WriteEndElement(); | ||
212 | } | ||
213 | else | ||
214 | { | ||
215 | throw new LLSDSerializeException("Unknown type " + obj.GetType().Name); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | /// <summary> | ||
220 | /// | ||
221 | /// </summary> | ||
222 | /// <param name="reader"></param> | ||
223 | /// <returns></returns> | ||
224 | public static object LLSDParseOne(XmlTextReader reader) | ||
225 | { | ||
226 | SkipWS(reader); | ||
227 | if (reader.NodeType != XmlNodeType.Element) | ||
228 | throw new LLSDParseException("Expected an element"); | ||
229 | |||
230 | string dtype = reader.LocalName; | ||
231 | object ret = null; | ||
232 | |||
233 | switch (dtype) | ||
234 | { | ||
235 | case "undef": | ||
236 | { | ||
237 | if (reader.IsEmptyElement) | ||
238 | { | ||
239 | reader.Read(); | ||
240 | return null; | ||
241 | } | ||
242 | |||
243 | reader.Read(); | ||
244 | SkipWS(reader); | ||
245 | ret = null; | ||
246 | break; | ||
247 | } | ||
248 | case "boolean": | ||
249 | { | ||
250 | if (reader.IsEmptyElement) | ||
251 | { | ||
252 | reader.Read(); | ||
253 | return false; | ||
254 | } | ||
255 | |||
256 | reader.Read(); | ||
257 | string s = reader.ReadString().Trim(); | ||
258 | |||
259 | if (s == String.Empty || s == "false" || s == "0") | ||
260 | ret = false; | ||
261 | else if (s == "true" || s == "1") | ||
262 | ret = true; | ||
263 | else | ||
264 | throw new LLSDParseException("Bad boolean value " + s); | ||
265 | |||
266 | break; | ||
267 | } | ||
268 | case "integer": | ||
269 | { | ||
270 | if (reader.IsEmptyElement) | ||
271 | { | ||
272 | reader.Read(); | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | reader.Read(); | ||
277 | ret = Convert.ToInt32(reader.ReadString().Trim()); | ||
278 | break; | ||
279 | } | ||
280 | case "real": | ||
281 | { | ||
282 | if (reader.IsEmptyElement) | ||
283 | { | ||
284 | reader.Read(); | ||
285 | return 0.0f; | ||
286 | } | ||
287 | |||
288 | reader.Read(); | ||
289 | ret = Convert.ToDouble(reader.ReadString().Trim()); | ||
290 | break; | ||
291 | } | ||
292 | case "uuid": | ||
293 | { | ||
294 | if (reader.IsEmptyElement) | ||
295 | { | ||
296 | reader.Read(); | ||
297 | return UUID.Zero; | ||
298 | } | ||
299 | |||
300 | reader.Read(); | ||
301 | ret = new UUID(reader.ReadString().Trim()); | ||
302 | break; | ||
303 | } | ||
304 | case "string": | ||
305 | { | ||
306 | if (reader.IsEmptyElement) | ||
307 | { | ||
308 | reader.Read(); | ||
309 | return String.Empty; | ||
310 | } | ||
311 | |||
312 | reader.Read(); | ||
313 | ret = reader.ReadString(); | ||
314 | break; | ||
315 | } | ||
316 | case "binary": | ||
317 | { | ||
318 | if (reader.IsEmptyElement) | ||
319 | { | ||
320 | reader.Read(); | ||
321 | return new byte[0]; | ||
322 | } | ||
323 | |||
324 | if (reader.GetAttribute("encoding") != null && | ||
325 | reader.GetAttribute("encoding") != "base64") | ||
326 | { | ||
327 | throw new LLSDParseException("Unknown encoding: " + reader.GetAttribute("encoding")); | ||
328 | } | ||
329 | |||
330 | reader.Read(); | ||
331 | FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces); | ||
332 | byte[] inp = Util.UTF8.GetBytes(reader.ReadString()); | ||
333 | ret = b64.TransformFinalBlock(inp, 0, inp.Length); | ||
334 | break; | ||
335 | } | ||
336 | case "date": | ||
337 | { | ||
338 | reader.Read(); | ||
339 | throw new Exception("LLSD TODO: date"); | ||
340 | } | ||
341 | case "map": | ||
342 | { | ||
343 | return LLSDParseMap(reader); | ||
344 | } | ||
345 | case "array": | ||
346 | { | ||
347 | return LLSDParseArray(reader); | ||
348 | } | ||
349 | default: | ||
350 | throw new LLSDParseException("Unknown element <" + dtype + ">"); | ||
351 | } | ||
352 | |||
353 | if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != dtype) | ||
354 | { | ||
355 | throw new LLSDParseException("Expected </" + dtype + ">"); | ||
356 | } | ||
357 | |||
358 | reader.Read(); | ||
359 | return ret; | ||
360 | } | ||
361 | |||
362 | /// <summary> | ||
363 | /// | ||
364 | /// </summary> | ||
365 | /// <param name="reader"></param> | ||
366 | /// <returns></returns> | ||
367 | public static Hashtable LLSDParseMap(XmlTextReader reader) | ||
368 | { | ||
369 | Hashtable ret = new Hashtable(); | ||
370 | |||
371 | if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "map") | ||
372 | throw new LLSDParseException("Expected <map>"); | ||
373 | |||
374 | if (reader.IsEmptyElement) | ||
375 | { | ||
376 | reader.Read(); | ||
377 | return ret; | ||
378 | } | ||
379 | |||
380 | reader.Read(); | ||
381 | |||
382 | while (true) | ||
383 | { | ||
384 | SkipWS(reader); | ||
385 | if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "map") | ||
386 | { | ||
387 | reader.Read(); | ||
388 | break; | ||
389 | } | ||
390 | |||
391 | if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "key") | ||
392 | throw new LLSDParseException("Expected <key>"); | ||
393 | |||
394 | string key = reader.ReadString(); | ||
395 | |||
396 | if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "key") | ||
397 | throw new LLSDParseException("Expected </key>"); | ||
398 | |||
399 | reader.Read(); | ||
400 | object val = LLSDParseOne(reader); | ||
401 | ret[key] = val; | ||
402 | } | ||
403 | |||
404 | return ret; // TODO | ||
405 | } | ||
406 | |||
407 | /// <summary> | ||
408 | /// | ||
409 | /// </summary> | ||
410 | /// <param name="reader"></param> | ||
411 | /// <returns></returns> | ||
412 | public static ArrayList LLSDParseArray(XmlTextReader reader) | ||
413 | { | ||
414 | ArrayList ret = new ArrayList(); | ||
415 | |||
416 | if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "array") | ||
417 | throw new LLSDParseException("Expected <array>"); | ||
418 | |||
419 | if (reader.IsEmptyElement) | ||
420 | { | ||
421 | reader.Read(); | ||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | reader.Read(); | ||
426 | |||
427 | while (true) | ||
428 | { | ||
429 | SkipWS(reader); | ||
430 | |||
431 | if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "array") | ||
432 | { | ||
433 | reader.Read(); | ||
434 | break; | ||
435 | } | ||
436 | |||
437 | ret.Insert(ret.Count, LLSDParseOne(reader)); | ||
438 | } | ||
439 | |||
440 | return ret; // TODO | ||
441 | } | ||
442 | |||
443 | /// <summary> | ||
444 | /// | ||
445 | /// </summary> | ||
446 | /// <param name="count"></param> | ||
447 | /// <returns></returns> | ||
448 | private static string GetSpaces(int count) | ||
449 | { | ||
450 | StringBuilder b = new StringBuilder(); | ||
451 | for (int i = 0; i < count; i++) b.Append(" "); | ||
452 | return b.ToString(); | ||
453 | } | ||
454 | |||
455 | /// <summary> | ||
456 | /// | ||
457 | /// </summary> | ||
458 | /// <param name="obj"></param> | ||
459 | /// <param name="indent"></param> | ||
460 | /// <returns></returns> | ||
461 | public static String LLSDDump(object obj, int indent) | ||
462 | { | ||
463 | if (obj == null) | ||
464 | { | ||
465 | return GetSpaces(indent) + "- undef\n"; | ||
466 | } | ||
467 | else if (obj is string) | ||
468 | { | ||
469 | return GetSpaces(indent) + "- string \"" + (string) obj + "\"\n"; | ||
470 | } | ||
471 | else if (obj is int) | ||
472 | { | ||
473 | return GetSpaces(indent) + "- integer " + obj.ToString() + "\n"; | ||
474 | } | ||
475 | else if (obj is double) | ||
476 | { | ||
477 | return GetSpaces(indent) + "- float " + obj.ToString() + "\n"; | ||
478 | } | ||
479 | else if (obj is UUID) | ||
480 | { | ||
481 | return GetSpaces(indent) + "- uuid " + ((UUID) obj).ToString() + Environment.NewLine; | ||
482 | } | ||
483 | else if (obj is Hashtable) | ||
484 | { | ||
485 | StringBuilder ret = new StringBuilder(); | ||
486 | ret.Append(GetSpaces(indent) + "- map" + Environment.NewLine); | ||
487 | Hashtable map = (Hashtable) obj; | ||
488 | |||
489 | foreach (string key in map.Keys) | ||
490 | { | ||
491 | ret.Append(GetSpaces(indent + 2) + "- key \"" + key + "\"" + Environment.NewLine); | ||
492 | ret.Append(LLSDDump(map[key], indent + 3)); | ||
493 | } | ||
494 | |||
495 | return ret.ToString(); | ||
496 | } | ||
497 | else if (obj is ArrayList) | ||
498 | { | ||
499 | StringBuilder ret = new StringBuilder(); | ||
500 | ret.Append(GetSpaces(indent) + "- array\n"); | ||
501 | ArrayList list = (ArrayList) obj; | ||
502 | |||
503 | foreach (object item in list) | ||
504 | { | ||
505 | ret.Append(LLSDDump(item, indent + 2)); | ||
506 | } | ||
507 | |||
508 | return ret.ToString(); | ||
509 | } | ||
510 | else if (obj is byte[]) | ||
511 | { | ||
512 | return GetSpaces(indent) + "- binary\n" + Utils.BytesToHexString((byte[]) obj, GetSpaces(indent)) + | ||
513 | Environment.NewLine; | ||
514 | } | ||
515 | else | ||
516 | { | ||
517 | return GetSpaces(indent) + "- unknown type " + obj.GetType().Name + Environment.NewLine; | ||
518 | } | ||
519 | } | ||
520 | |||
521 | public static object ParseTerseLLSD(string llsd) | ||
522 | { | ||
523 | int notused; | ||
524 | return ParseTerseLLSD(llsd, out notused); | ||
525 | } | ||
526 | |||
527 | public static object ParseTerseLLSD(string llsd, out int endPos) | ||
528 | { | ||
529 | if (llsd.Length == 0) | ||
530 | { | ||
531 | endPos = 0; | ||
532 | return null; | ||
533 | } | ||
534 | |||
535 | // Identify what type of object this is | ||
536 | switch (llsd[0]) | ||
537 | { | ||
538 | case '!': | ||
539 | throw new LLSDParseException("Undefined value type encountered"); | ||
540 | case '1': | ||
541 | endPos = 1; | ||
542 | return true; | ||
543 | case '0': | ||
544 | endPos = 1; | ||
545 | return false; | ||
546 | case 'i': | ||
547 | { | ||
548 | if (llsd.Length < 2) throw new LLSDParseException("Integer value type with no value"); | ||
549 | int value; | ||
550 | endPos = FindEnd(llsd, 1); | ||
551 | |||
552 | if (Int32.TryParse(llsd.Substring(1, endPos - 1), out value)) | ||
553 | return value; | ||
554 | else | ||
555 | throw new LLSDParseException("Failed to parse integer value type"); | ||
556 | } | ||
557 | case 'r': | ||
558 | { | ||
559 | if (llsd.Length < 2) throw new LLSDParseException("Real value type with no value"); | ||
560 | double value; | ||
561 | endPos = FindEnd(llsd, 1); | ||
562 | |||
563 | if (Double.TryParse(llsd.Substring(1, endPos - 1), NumberStyles.Float, | ||
564 | Utils.EnUsCulture.NumberFormat, out value)) | ||
565 | return value; | ||
566 | else | ||
567 | throw new LLSDParseException("Failed to parse double value type"); | ||
568 | } | ||
569 | case 'u': | ||
570 | { | ||
571 | if (llsd.Length < 17) throw new LLSDParseException("UUID value type with no value"); | ||
572 | UUID value; | ||
573 | endPos = FindEnd(llsd, 1); | ||
574 | |||
575 | if (UUID.TryParse(llsd.Substring(1, endPos - 1), out value)) | ||
576 | return value; | ||
577 | else | ||
578 | throw new LLSDParseException("Failed to parse UUID value type"); | ||
579 | } | ||
580 | case 'b': | ||
581 | //byte[] value = new byte[llsd.Length - 1]; | ||
582 | // This isn't the actual binary LLSD format, just the terse format sent | ||
583 | // at login so I don't even know if there is a binary type | ||
584 | throw new LLSDParseException("Binary value type is unimplemented"); | ||
585 | case 's': | ||
586 | case 'l': | ||
587 | if (llsd.Length < 2) throw new LLSDParseException("String value type with no value"); | ||
588 | endPos = FindEnd(llsd, 1); | ||
589 | return llsd.Substring(1, endPos - 1); | ||
590 | case 'd': | ||
591 | // Never seen one before, don't know what the format is | ||
592 | throw new LLSDParseException("Date value type is unimplemented"); | ||
593 | case '[': | ||
594 | { | ||
595 | if (llsd.IndexOf(']') == -1) throw new LLSDParseException("Invalid array"); | ||
596 | |||
597 | int pos = 0; | ||
598 | ArrayList array = new ArrayList(); | ||
599 | |||
600 | while (llsd[pos] != ']') | ||
601 | { | ||
602 | ++pos; | ||
603 | |||
604 | // Advance past comma if need be | ||
605 | if (llsd[pos] == ',') ++pos; | ||
606 | |||
607 | // Allow a single whitespace character | ||
608 | if (pos < llsd.Length && llsd[pos] == ' ') ++pos; | ||
609 | |||
610 | int end; | ||
611 | array.Add(ParseTerseLLSD(llsd.Substring(pos), out end)); | ||
612 | pos += end; | ||
613 | } | ||
614 | |||
615 | endPos = pos + 1; | ||
616 | return array; | ||
617 | } | ||
618 | case '{': | ||
619 | { | ||
620 | if (llsd.IndexOf('}') == -1) throw new LLSDParseException("Invalid map"); | ||
621 | |||
622 | int pos = 0; | ||
623 | Hashtable hashtable = new Hashtable(); | ||
624 | |||
625 | while (llsd[pos] != '}') | ||
626 | { | ||
627 | ++pos; | ||
628 | |||
629 | // Advance past comma if need be | ||
630 | if (llsd[pos] == ',') ++pos; | ||
631 | |||
632 | // Allow a single whitespace character | ||
633 | if (pos < llsd.Length && llsd[pos] == ' ') ++pos; | ||
634 | |||
635 | if (llsd[pos] != '\'') throw new LLSDParseException("Expected a map key"); | ||
636 | int endquote = llsd.IndexOf('\'', pos + 1); | ||
637 | if (endquote == -1 || (endquote + 1) >= llsd.Length || llsd[endquote + 1] != ':') | ||
638 | throw new LLSDParseException("Invalid map format"); | ||
639 | string key = llsd.Substring(pos, endquote - pos); | ||
640 | key = key.Replace("'", String.Empty); | ||
641 | pos += (endquote - pos) + 2; | ||
642 | |||
643 | int end; | ||
644 | hashtable.Add(key, ParseTerseLLSD(llsd.Substring(pos), out end)); | ||
645 | pos += end; | ||
646 | } | ||
647 | |||
648 | endPos = pos + 1; | ||
649 | return hashtable; | ||
650 | } | ||
651 | default: | ||
652 | throw new Exception("Unknown value type"); | ||
653 | } | ||
654 | } | ||
655 | |||
656 | private static int FindEnd(string llsd, int start) | ||
657 | { | ||
658 | int end = llsd.IndexOfAny(new char[] {',', ']', '}'}); | ||
659 | if (end == -1) end = llsd.Length - 1; | ||
660 | return end; | ||
661 | } | ||
662 | |||
663 | /// <summary> | ||
664 | /// | ||
665 | /// </summary> | ||
666 | /// <param name="reader"></param> | ||
667 | private static void SkipWS(XmlTextReader reader) | ||
668 | { | ||
669 | while ( | ||
670 | reader.NodeType == XmlNodeType.Comment || | ||
671 | reader.NodeType == XmlNodeType.Whitespace || | ||
672 | reader.NodeType == XmlNodeType.SignificantWhitespace || | ||
673 | reader.NodeType == XmlNodeType.XmlDeclaration) | ||
674 | { | ||
675 | reader.Read(); | ||
676 | } | ||
677 | } | ||
678 | } | ||
679 | } | ||
diff --git a/OpenSim/Capabilities/LLSDArray.cs b/OpenSim/Capabilities/LLSDArray.cs new file mode 100644 index 0000000..3459e49 --- /dev/null +++ b/OpenSim/Capabilities/LLSDArray.cs | |||
@@ -0,0 +1,41 @@ | |||
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.Collections; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [LLSDType("ARRAY")] | ||
33 | public class OSDArray | ||
34 | { | ||
35 | public ArrayList Array = new ArrayList(); | ||
36 | |||
37 | public OSDArray() | ||
38 | { | ||
39 | } | ||
40 | } | ||
41 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs new file mode 100644 index 0000000..ab6cee5 --- /dev/null +++ b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs | |||
@@ -0,0 +1,45 @@ | |||
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 OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Framework.Capabilities | ||
32 | { | ||
33 | [LLSDType("MAP")] | ||
34 | public class LLSDAssetUploadComplete | ||
35 | { | ||
36 | public string new_asset = String.Empty; | ||
37 | public UUID new_inventory_item = UUID.Zero; | ||
38 | public string state = String.Empty; | ||
39 | //public bool success = false; | ||
40 | |||
41 | public LLSDAssetUploadComplete() | ||
42 | { | ||
43 | } | ||
44 | } | ||
45 | } | ||
diff --git a/OpenSim/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs new file mode 100644 index 0000000..6e66f0a --- /dev/null +++ b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs | |||
@@ -0,0 +1,46 @@ | |||
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 OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Framework.Capabilities | ||
32 | { | ||
33 | [OSDMap] | ||
34 | public class LLSDAssetUploadRequest | ||
35 | { | ||
36 | public string asset_type = String.Empty; | ||
37 | public string description = String.Empty; | ||
38 | public UUID folder_id = UUID.Zero; | ||
39 | public string inventory_type = String.Empty; | ||
40 | public string name = String.Empty; | ||
41 | |||
42 | public LLSDAssetUploadRequest() | ||
43 | { | ||
44 | } | ||
45 | } | ||
46 | } | ||
diff --git a/OpenSim/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs new file mode 100644 index 0000000..0d6f7f9 --- /dev/null +++ b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs | |||
@@ -0,0 +1,56 @@ | |||
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 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [OSDMap] | ||
33 | public class LLSDAssetUploadResponse | ||
34 | { | ||
35 | public string uploader = String.Empty; | ||
36 | public string state = String.Empty; | ||
37 | |||
38 | public LLSDAssetUploadResponse() | ||
39 | { | ||
40 | } | ||
41 | } | ||
42 | |||
43 | [OSDMap] | ||
44 | public class LLSDNewFileAngentInventoryVariablePriceReplyResponse | ||
45 | { | ||
46 | public int resource_cost; | ||
47 | public string state; | ||
48 | public int upload_price; | ||
49 | public string rsvp; | ||
50 | |||
51 | public LLSDNewFileAngentInventoryVariablePriceReplyResponse() | ||
52 | { | ||
53 | state = "confirm_upload"; | ||
54 | } | ||
55 | } | ||
56 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDCapEvent.cs b/OpenSim/Capabilities/LLSDCapEvent.cs new file mode 100644 index 0000000..63abd62 --- /dev/null +++ b/OpenSim/Capabilities/LLSDCapEvent.cs | |||
@@ -0,0 +1,40 @@ | |||
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 | namespace OpenSim.Framework.Capabilities | ||
29 | { | ||
30 | [LLSDType("MAP")] | ||
31 | public class LLSDCapEvent | ||
32 | { | ||
33 | public int id = 0; | ||
34 | public OSDArray events = new OSDArray(); | ||
35 | |||
36 | public LLSDCapEvent() | ||
37 | { | ||
38 | } | ||
39 | } | ||
40 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDEmpty.cs b/OpenSim/Capabilities/LLSDEmpty.cs new file mode 100644 index 0000000..f94fcba --- /dev/null +++ b/OpenSim/Capabilities/LLSDEmpty.cs | |||
@@ -0,0 +1,37 @@ | |||
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 | namespace OpenSim.Framework.Capabilities | ||
29 | { | ||
30 | [LLSDType("MAP")] | ||
31 | public class LLSDEmpty | ||
32 | { | ||
33 | public LLSDEmpty() | ||
34 | { | ||
35 | } | ||
36 | } | ||
37 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDHelpers.cs b/OpenSim/Capabilities/LLSDHelpers.cs new file mode 100644 index 0000000..8f1a40e --- /dev/null +++ b/OpenSim/Capabilities/LLSDHelpers.cs | |||
@@ -0,0 +1,172 @@ | |||
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.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Xml; | ||
33 | |||
34 | namespace OpenSim.Framework.Capabilities | ||
35 | { | ||
36 | public class LLSDHelpers | ||
37 | { | ||
38 | // private static readonly log4net.ILog m_log | ||
39 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | |||
41 | public static string SerialiseLLSDReply(object obj) | ||
42 | { | ||
43 | StringWriter sw = new StringWriter(); | ||
44 | XmlTextWriter writer = new XmlTextWriter(sw); | ||
45 | writer.Formatting = Formatting.None; | ||
46 | writer.WriteStartElement(String.Empty, "llsd", String.Empty); | ||
47 | SerializeOSDType(writer, obj); | ||
48 | writer.WriteEndElement(); | ||
49 | writer.Close(); | ||
50 | |||
51 | //m_log.DebugFormat("[LLSD Helpers]: Generated serialized LLSD reply {0}", sw.ToString()); | ||
52 | |||
53 | return sw.ToString(); | ||
54 | } | ||
55 | |||
56 | private static void SerializeOSDType(XmlTextWriter writer, object obj) | ||
57 | { | ||
58 | Type myType = obj.GetType(); | ||
59 | LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); | ||
60 | if (llsdattributes.Length > 0) | ||
61 | { | ||
62 | switch (llsdattributes[0].ObjectType) | ||
63 | { | ||
64 | case "MAP": | ||
65 | writer.WriteStartElement(String.Empty, "map", String.Empty); | ||
66 | FieldInfo[] fields = myType.GetFields(); | ||
67 | for (int i = 0; i < fields.Length; i++) | ||
68 | { | ||
69 | if (fields[i] != null && fields[i].GetValue(obj) != null) | ||
70 | { | ||
71 | object fieldValue = fields[i].GetValue(obj); | ||
72 | LLSDType[] fieldAttributes = | ||
73 | (LLSDType[]) fieldValue.GetType().GetCustomAttributes(typeof (LLSDType), false); | ||
74 | if (fieldAttributes.Length > 0) | ||
75 | { | ||
76 | writer.WriteStartElement(String.Empty, "key", String.Empty); | ||
77 | string fieldName = fields[i].Name; | ||
78 | fieldName = fieldName.Replace("___", "-"); | ||
79 | writer.WriteString(fieldName); | ||
80 | writer.WriteEndElement(); | ||
81 | SerializeOSDType(writer, fieldValue); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | writer.WriteStartElement(String.Empty, "key", String.Empty); | ||
86 | string fieldName = fields[i].Name; | ||
87 | fieldName = fieldName.Replace("___", "-"); | ||
88 | writer.WriteString(fieldName); | ||
89 | writer.WriteEndElement(); | ||
90 | LLSD.LLSDWriteOne(writer, fieldValue); | ||
91 | // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( | ||
92 | // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); | ||
93 | } | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | // TODO from ADAM: There is a nullref being caused by fields[i] being null | ||
98 | // on some computers. Unsure what is causing this, but would appreciate | ||
99 | // if sdague could take a look at this. | ||
100 | } | ||
101 | } | ||
102 | writer.WriteEndElement(); | ||
103 | break; | ||
104 | case "ARRAY": | ||
105 | // OSDArray arrayObject = obj as OSDArray; | ||
106 | // ArrayList a = arrayObject.Array; | ||
107 | ArrayList a = (ArrayList) obj.GetType().GetField("Array").GetValue(obj); | ||
108 | if (a != null) | ||
109 | { | ||
110 | writer.WriteStartElement(String.Empty, "array", String.Empty); | ||
111 | foreach (object item in a) | ||
112 | { | ||
113 | SerializeOSDType(writer, item); | ||
114 | } | ||
115 | writer.WriteEndElement(); | ||
116 | } | ||
117 | break; | ||
118 | } | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | LLSD.LLSDWriteOne(writer, obj); | ||
123 | //OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( | ||
124 | // writer, OpenMetaverse.StructuredData.OSD.FromObject(obj)); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | public static object DeserialiseOSDMap(Hashtable llsd, object obj) | ||
129 | { | ||
130 | Type myType = obj.GetType(); | ||
131 | LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); | ||
132 | if (llsdattributes.Length > 0) | ||
133 | { | ||
134 | switch (llsdattributes[0].ObjectType) | ||
135 | { | ||
136 | case "MAP": | ||
137 | IDictionaryEnumerator enumerator = llsd.GetEnumerator(); | ||
138 | while (enumerator.MoveNext()) | ||
139 | { | ||
140 | string keyName = (string)enumerator.Key; | ||
141 | keyName = keyName.Replace("-","_"); | ||
142 | FieldInfo field = myType.GetField(keyName); | ||
143 | if (field != null) | ||
144 | { | ||
145 | // if (enumerator.Value is OpenMetaverse.StructuredData.OSDMap) | ||
146 | if (enumerator.Value is Hashtable) | ||
147 | { | ||
148 | object fieldValue = field.GetValue(obj); | ||
149 | DeserialiseOSDMap((Hashtable) enumerator.Value, fieldValue); | ||
150 | // DeserialiseOSDMap((OpenMetaverse.StructuredData.OSDMap) enumerator.Value, fieldValue); | ||
151 | } | ||
152 | else if (enumerator.Value is ArrayList) | ||
153 | { | ||
154 | object fieldValue = field.GetValue(obj); | ||
155 | fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value); | ||
156 | //TODO | ||
157 | // the LLSD map/array types in the array need to be deserialised | ||
158 | // but first we need to know the right class to deserialise them into. | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | field.SetValue(obj, enumerator.Value); | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | break; | ||
167 | } | ||
168 | } | ||
169 | return obj; | ||
170 | } | ||
171 | } | ||
172 | } | ||
diff --git a/OpenSim/Capabilities/LLSDInventoryFolder.cs b/OpenSim/Capabilities/LLSDInventoryFolder.cs new file mode 100644 index 0000000..3c216e9 --- /dev/null +++ b/OpenSim/Capabilities/LLSDInventoryFolder.cs | |||
@@ -0,0 +1,41 @@ | |||
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 OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [OSDMap] | ||
33 | public class LLSDInventoryFolder | ||
34 | { | ||
35 | public UUID folder_id; | ||
36 | public UUID parent_id; | ||
37 | public string name; | ||
38 | public string type; | ||
39 | public string preferred_type; | ||
40 | } | ||
41 | } | ||
diff --git a/OpenSim/Capabilities/LLSDInventoryItem.cs b/OpenSim/Capabilities/LLSDInventoryItem.cs new file mode 100644 index 0000000..cce18d7 --- /dev/null +++ b/OpenSim/Capabilities/LLSDInventoryItem.cs | |||
@@ -0,0 +1,98 @@ | |||
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 OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [OSDMap] | ||
33 | public class LLSDInventoryItem | ||
34 | { | ||
35 | public UUID parent_id; | ||
36 | |||
37 | public UUID asset_id; | ||
38 | public UUID item_id; | ||
39 | public LLSDPermissions permissions; | ||
40 | public string type; | ||
41 | public string inv_type; | ||
42 | public int flags; | ||
43 | |||
44 | public LLSDSaleInfo sale_info; | ||
45 | public string name; | ||
46 | public string desc; | ||
47 | public int created_at; | ||
48 | } | ||
49 | |||
50 | [OSDMap] | ||
51 | public class LLSDPermissions | ||
52 | { | ||
53 | public UUID creator_id; | ||
54 | public UUID owner_id; | ||
55 | public UUID group_id; | ||
56 | public int base_mask; | ||
57 | public int owner_mask; | ||
58 | public int group_mask; | ||
59 | public int everyone_mask; | ||
60 | public int next_owner_mask; | ||
61 | public bool is_owner_group; | ||
62 | } | ||
63 | |||
64 | [OSDMap] | ||
65 | public class LLSDSaleInfo | ||
66 | { | ||
67 | public int sale_price; | ||
68 | public string sale_type; | ||
69 | } | ||
70 | |||
71 | [OSDMap] | ||
72 | public class LLSDInventoryDescendents | ||
73 | { | ||
74 | public OSDArray folders = new OSDArray(); | ||
75 | } | ||
76 | |||
77 | [OSDMap] | ||
78 | public class LLSDFetchInventoryDescendents | ||
79 | { | ||
80 | public UUID folder_id; | ||
81 | public UUID owner_id; | ||
82 | public int sort_order; | ||
83 | public bool fetch_folders; | ||
84 | public bool fetch_items; | ||
85 | } | ||
86 | |||
87 | [OSDMap] | ||
88 | public class LLSDInventoryFolderContents | ||
89 | { | ||
90 | public UUID agent_id; | ||
91 | public int descendents; | ||
92 | public UUID folder_id; | ||
93 | public OSDArray categories = new OSDArray(); | ||
94 | public OSDArray items = new OSDArray(); | ||
95 | public UUID owner_id; | ||
96 | public int version; | ||
97 | } | ||
98 | } | ||
diff --git a/OpenSim/Capabilities/LLSDItemUpdate.cs b/OpenSim/Capabilities/LLSDItemUpdate.cs new file mode 100644 index 0000000..96e2b61 --- /dev/null +++ b/OpenSim/Capabilities/LLSDItemUpdate.cs | |||
@@ -0,0 +1,41 @@ | |||
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 OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [OSDMap] | ||
33 | public class LLSDItemUpdate | ||
34 | { | ||
35 | public UUID item_id; | ||
36 | |||
37 | public LLSDItemUpdate() | ||
38 | { | ||
39 | } | ||
40 | } | ||
41 | } | ||
diff --git a/OpenSim/Capabilities/LLSDMapLayer.cs b/OpenSim/Capabilities/LLSDMapLayer.cs new file mode 100644 index 0000000..4aeb1ff --- /dev/null +++ b/OpenSim/Capabilities/LLSDMapLayer.cs | |||
@@ -0,0 +1,45 @@ | |||
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 OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [LLSDType("MAP")] | ||
33 | public class OSDMapLayer | ||
34 | { | ||
35 | public int Left = 0; | ||
36 | public int Right = 0; | ||
37 | public int Top = 0; | ||
38 | public int Bottom = 0; | ||
39 | public UUID ImageID = UUID.Zero; | ||
40 | |||
41 | public OSDMapLayer() | ||
42 | { | ||
43 | } | ||
44 | } | ||
45 | } | ||
diff --git a/OpenSim/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Capabilities/LLSDMapLayerResponse.cs new file mode 100644 index 0000000..839e34c --- /dev/null +++ b/OpenSim/Capabilities/LLSDMapLayerResponse.cs | |||
@@ -0,0 +1,40 @@ | |||
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 | namespace OpenSim.Framework.Capabilities | ||
29 | { | ||
30 | [LLSDType("MAP")] | ||
31 | public class LLSDMapLayerResponse | ||
32 | { | ||
33 | public LLSDMapRequest AgentData = new LLSDMapRequest(); | ||
34 | public OSDArray LayerData = new OSDArray(); | ||
35 | |||
36 | public LLSDMapLayerResponse() | ||
37 | { | ||
38 | } | ||
39 | } | ||
40 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDMapRequest.cs b/OpenSim/Capabilities/LLSDMapRequest.cs new file mode 100644 index 0000000..debf387 --- /dev/null +++ b/OpenSim/Capabilities/LLSDMapRequest.cs | |||
@@ -0,0 +1,39 @@ | |||
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 | namespace OpenSim.Framework.Capabilities | ||
29 | { | ||
30 | [LLSDType("MAP")] | ||
31 | public class LLSDMapRequest | ||
32 | { | ||
33 | public int Flags = 0; | ||
34 | |||
35 | public LLSDMapRequest() | ||
36 | { | ||
37 | } | ||
38 | } | ||
39 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDMethod.cs b/OpenSim/Capabilities/LLSDMethod.cs new file mode 100644 index 0000000..cd2574d --- /dev/null +++ b/OpenSim/Capabilities/LLSDMethod.cs | |||
@@ -0,0 +1,31 @@ | |||
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 | namespace OpenSim.Framework.Capabilities | ||
29 | { | ||
30 | public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request); | ||
31 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDMethodString.cs b/OpenSim/Capabilities/LLSDMethodString.cs new file mode 100644 index 0000000..38700d5 --- /dev/null +++ b/OpenSim/Capabilities/LLSDMethodString.cs | |||
@@ -0,0 +1,31 @@ | |||
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 | namespace OpenSim.Framework.Capabilities | ||
29 | { | ||
30 | public delegate TResponse LLSDMethodString<TRequest, TResponse>(TRequest request, string path); | ||
31 | } | ||
diff --git a/OpenSim/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Capabilities/LLSDParcelVoiceInfoResponse.cs new file mode 100644 index 0000000..b34a668 --- /dev/null +++ b/OpenSim/Capabilities/LLSDParcelVoiceInfoResponse.cs | |||
@@ -0,0 +1,51 @@ | |||
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 | |||
29 | using System.Collections; | ||
30 | |||
31 | namespace OpenSim.Framework.Capabilities | ||
32 | { | ||
33 | [OSDMap] | ||
34 | public class LLSDParcelVoiceInfoResponse | ||
35 | { | ||
36 | public int parcel_local_id; | ||
37 | public string region_name; | ||
38 | public Hashtable voice_credentials; | ||
39 | |||
40 | public LLSDParcelVoiceInfoResponse() | ||
41 | { | ||
42 | } | ||
43 | |||
44 | public LLSDParcelVoiceInfoResponse(string region, int localID, Hashtable creds) | ||
45 | { | ||
46 | region_name = region; | ||
47 | parcel_local_id = localID; | ||
48 | voice_credentials = creds; | ||
49 | } | ||
50 | } | ||
51 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Capabilities/LLSDRemoteParcelResponse.cs new file mode 100644 index 0000000..13d69d3 --- /dev/null +++ b/OpenSim/Capabilities/LLSDRemoteParcelResponse.cs | |||
@@ -0,0 +1,42 @@ | |||
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 | |||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Framework.Capabilities | ||
32 | { | ||
33 | [LLSDType("MAP")] | ||
34 | public class LLSDRemoteParcelResponse | ||
35 | { | ||
36 | public UUID parcel_id; | ||
37 | |||
38 | public LLSDRemoteParcelResponse() | ||
39 | { | ||
40 | } | ||
41 | } | ||
42 | } | ||
diff --git a/OpenSim/Capabilities/LLSDStreamHandler.cs b/OpenSim/Capabilities/LLSDStreamHandler.cs new file mode 100644 index 0000000..7aaa994 --- /dev/null +++ b/OpenSim/Capabilities/LLSDStreamHandler.cs | |||
@@ -0,0 +1,70 @@ | |||
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.Collections; | ||
29 | using System.IO; | ||
30 | using System.Text; | ||
31 | using OpenSim.Framework.Servers; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | |||
34 | namespace OpenSim.Framework.Capabilities | ||
35 | { | ||
36 | public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler | ||
37 | where TRequest : new() | ||
38 | { | ||
39 | private LLSDMethod<TRequest, TResponse> m_method; | ||
40 | |||
41 | public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method) | ||
42 | : base(httpMethod, path) | ||
43 | { | ||
44 | m_method = method; | ||
45 | } | ||
46 | |||
47 | public override byte[] Handle(string path, Stream request, | ||
48 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
49 | { | ||
50 | //Encoding encoding = Util.UTF8; | ||
51 | //StreamReader streamReader = new StreamReader(request, false); | ||
52 | |||
53 | //string requestBody = streamReader.ReadToEnd(); | ||
54 | //streamReader.Close(); | ||
55 | |||
56 | // OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap) | ||
57 | // OpenMetaverse.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); | ||
58 | |||
59 | Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); | ||
60 | TRequest llsdRequest = new TRequest(); | ||
61 | LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); | ||
62 | |||
63 | TResponse response = m_method(llsdRequest); | ||
64 | |||
65 | Encoding encoding = new UTF8Encoding(false); | ||
66 | |||
67 | return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); | ||
68 | } | ||
69 | } | ||
70 | } | ||
diff --git a/OpenSim/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Capabilities/LLSDTaskInventoryUploadComplete.cs new file mode 100644 index 0000000..47fdaca --- /dev/null +++ b/OpenSim/Capabilities/LLSDTaskInventoryUploadComplete.cs | |||
@@ -0,0 +1,50 @@ | |||
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 OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [OSDMap] | ||
33 | public class LLSDTaskInventoryUploadComplete | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// The task inventory item that was updated | ||
37 | /// </summary> | ||
38 | public UUID item_id; | ||
39 | |||
40 | /// <summary> | ||
41 | /// The task that was updated | ||
42 | /// </summary> | ||
43 | public UUID task_id; | ||
44 | |||
45 | /// <summary> | ||
46 | /// State of the upload. So far have only even seen this set to "complete" | ||
47 | /// </summary> | ||
48 | public string state; | ||
49 | } | ||
50 | } | ||
diff --git a/OpenSim/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Capabilities/LLSDTaskScriptUpdate.cs new file mode 100644 index 0000000..9d7c17f --- /dev/null +++ b/OpenSim/Capabilities/LLSDTaskScriptUpdate.cs | |||
@@ -0,0 +1,50 @@ | |||
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 OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [OSDMap] | ||
33 | public class LLSDTaskScriptUpdate | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// The item containing the script to update | ||
37 | /// </summary> | ||
38 | public UUID item_id; | ||
39 | |||
40 | /// <summary> | ||
41 | /// The task containing the script | ||
42 | /// </summary> | ||
43 | public UUID task_id; | ||
44 | |||
45 | /// <summary> | ||
46 | /// Signals whether the script is currently active | ||
47 | /// </summary> | ||
48 | public int is_script_running; | ||
49 | } | ||
50 | } | ||
diff --git a/OpenSim/Capabilities/LLSDTaskScriptUploadComplete.cs b/OpenSim/Capabilities/LLSDTaskScriptUploadComplete.cs new file mode 100644 index 0000000..d308831 --- /dev/null +++ b/OpenSim/Capabilities/LLSDTaskScriptUploadComplete.cs | |||
@@ -0,0 +1,54 @@ | |||
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 OpenMetaverse; | ||
29 | using System; | ||
30 | using System.Collections; | ||
31 | |||
32 | namespace OpenSim.Framework.Capabilities | ||
33 | { | ||
34 | [OSDMap] | ||
35 | public class LLSDTaskScriptUploadComplete | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// The task inventory item that was updated | ||
39 | /// </summary> | ||
40 | public UUID new_asset; | ||
41 | |||
42 | /// <summary> | ||
43 | /// Was it compiled? | ||
44 | /// </summary> | ||
45 | public bool compiled; | ||
46 | |||
47 | /// <summary> | ||
48 | /// State of the upload. So far have only even seen this set to "complete" | ||
49 | /// </summary> | ||
50 | public string state; | ||
51 | |||
52 | public OSDArray errors; | ||
53 | } | ||
54 | } | ||
diff --git a/OpenSim/Capabilities/LLSDTest.cs b/OpenSim/Capabilities/LLSDTest.cs new file mode 100644 index 0000000..5f77c3d --- /dev/null +++ b/OpenSim/Capabilities/LLSDTest.cs | |||
@@ -0,0 +1,40 @@ | |||
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 | namespace OpenSim.Framework.Capabilities | ||
29 | { | ||
30 | [LLSDType("MAP")] | ||
31 | public class LLSDTest | ||
32 | { | ||
33 | public int Test1 = 20; | ||
34 | public int Test2 = 10; | ||
35 | |||
36 | public LLSDTest() | ||
37 | { | ||
38 | } | ||
39 | } | ||
40 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDType.cs b/OpenSim/Capabilities/LLSDType.cs new file mode 100644 index 0000000..d5ca1ab --- /dev/null +++ b/OpenSim/Capabilities/LLSDType.cs | |||
@@ -0,0 +1,55 @@ | |||
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 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [AttributeUsage(AttributeTargets.Class)] | ||
33 | public class LLSDType : Attribute | ||
34 | { | ||
35 | protected string myType; | ||
36 | |||
37 | public LLSDType(string type) | ||
38 | { | ||
39 | myType = type; | ||
40 | } | ||
41 | |||
42 | public string ObjectType | ||
43 | { | ||
44 | get { return myType; } | ||
45 | } | ||
46 | } | ||
47 | |||
48 | [AttributeUsage(AttributeTargets.Class)] | ||
49 | public class OSDMap : LLSDType | ||
50 | { | ||
51 | public OSDMap() : base("MAP") | ||
52 | { | ||
53 | } | ||
54 | } | ||
55 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Capabilities/LLSDVoiceAccountResponse.cs new file mode 100644 index 0000000..53c11e7 --- /dev/null +++ b/OpenSim/Capabilities/LLSDVoiceAccountResponse.cs | |||
@@ -0,0 +1,57 @@ | |||
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 | |||
29 | namespace OpenSim.Framework.Capabilities | ||
30 | { | ||
31 | [OSDMap] | ||
32 | public class LLSDVoiceAccountResponse | ||
33 | { | ||
34 | public string username; | ||
35 | public string password; | ||
36 | public string voice_sip_uri_hostname; | ||
37 | public string voice_account_server_name; | ||
38 | |||
39 | public LLSDVoiceAccountResponse() | ||
40 | { | ||
41 | } | ||
42 | |||
43 | public LLSDVoiceAccountResponse(string user, string pass) | ||
44 | { | ||
45 | username = user; | ||
46 | password = pass; | ||
47 | } | ||
48 | |||
49 | public LLSDVoiceAccountResponse(string user, string pass, string sipUriHost, string accountServer) | ||
50 | { | ||
51 | username = user; | ||
52 | password = pass; | ||
53 | voice_sip_uri_hostname = sipUriHost; | ||
54 | voice_account_server_name = accountServer; | ||
55 | } | ||
56 | } | ||
57 | } \ No newline at end of file | ||