diff options
author | Melanie | 2011-05-05 09:49:10 +0100 |
---|---|---|
committer | Melanie | 2011-05-05 09:49:10 +0100 |
commit | 4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c (patch) | |
tree | 24e24cb7b424df74b13788d28be9d7588fbd99d0 /OpenSim/Capabilities | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | Test m_Enabled on RemoveRegion. (diff) | |
download | opensim-SC-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.zip opensim-SC-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.tar.gz opensim-SC-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.tar.bz2 opensim-SC-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Caps.cs | 176 | ||||
-rw-r--r-- | OpenSim/Capabilities/CapsHandlers.cs (renamed from OpenSim/Framework/Capabilities/CapsHandlers.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs (renamed from OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs) | 76 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs | 79 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs (renamed from OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs) | 61 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs | 69 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | 299 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescServerConnector.cs | 76 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSD.cs (renamed from OpenSim/Framework/Capabilities/LLSD.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDArray.cs (renamed from OpenSim/Framework/Capabilities/LLSDArray.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDAssetUploadComplete.cs (renamed from OpenSim/Framework/Capabilities/LLSDAssetUploadComplete.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDAssetUploadRequest.cs (renamed from OpenSim/Framework/Capabilities/LLSDAssetUploadRequest.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDAssetUploadResponse.cs (renamed from OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDCapEvent.cs (renamed from OpenSim/Framework/Capabilities/LLSDCapEvent.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDEmpty.cs (renamed from OpenSim/Framework/Capabilities/LLSDEmpty.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDHelpers.cs (renamed from OpenSim/Framework/Capabilities/LLSDHelpers.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDInventoryFolder.cs (renamed from OpenSim/Framework/Capabilities/LLSDInventoryFolder.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDInventoryItem.cs (renamed from OpenSim/Framework/Capabilities/LLSDInventoryItem.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDItemUpdate.cs (renamed from OpenSim/Framework/Capabilities/LLSDItemUpdate.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDMapLayer.cs (renamed from OpenSim/Framework/Capabilities/LLSDMapLayer.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDMapLayerResponse.cs (renamed from OpenSim/Framework/Capabilities/LLSDMapLayerResponse.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDMapRequest.cs (renamed from OpenSim/Framework/Capabilities/LLSDMapRequest.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDMethod.cs (renamed from OpenSim/Framework/Capabilities/LLSDMethod.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDMethodString.cs (renamed from OpenSim/Framework/Capabilities/LLSDMethodString.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDParcelVoiceInfoResponse.cs (renamed from OpenSim/Framework/Capabilities/LLSDParcelVoiceInfoResponse.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDRemoteParcelResponse.cs (renamed from OpenSim/Framework/Capabilities/LLSDRemoteParcelResponse.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDStreamHandler.cs (renamed from OpenSim/Framework/Capabilities/LLSDStreamHandler.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDTaskInventoryUploadComplete.cs (renamed from OpenSim/Framework/Capabilities/LLSDTaskInventoryUploadComplete.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDTaskScriptUpdate.cs (renamed from OpenSim/Framework/Capabilities/LLSDTaskScriptUpdate.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDTaskScriptUploadComplete.cs (renamed from OpenSim/Framework/Capabilities/LLSDTaskScriptUploadComplete.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDTest.cs (renamed from OpenSim/Framework/Capabilities/LLSDTest.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDType.cs (renamed from OpenSim/Framework/Capabilities/LLSDType.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Capabilities/LLSDVoiceAccountResponse.cs (renamed from OpenSim/Framework/Capabilities/LLSDVoiceAccountResponse.cs) | 0 |
33 files changed, 711 insertions, 125 deletions
diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs new file mode 100644 index 0000000..e188896 --- /dev/null +++ b/OpenSim/Capabilities/Caps.cs | |||
@@ -0,0 +1,176 @@ | |||
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 | /// <summary> | ||
45 | /// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that | ||
46 | /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want | ||
47 | /// to just pass the whole Scene into CAPS. | ||
48 | /// </summary> | ||
49 | public delegate IClientAPI GetClientDelegate(UUID agentID); | ||
50 | |||
51 | public class Caps | ||
52 | { | ||
53 | private static readonly ILog m_log = | ||
54 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | private string m_httpListenerHostName; | ||
57 | private uint m_httpListenPort; | ||
58 | |||
59 | /// <summary> | ||
60 | /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. | ||
61 | /// </summary> | ||
62 | private string m_capsObjectPath; | ||
63 | public string CapsObjectPath { get { return m_capsObjectPath; } } | ||
64 | |||
65 | private CapsHandlers m_capsHandlers; | ||
66 | private Dictionary<string, string> m_externalCapsHandlers; | ||
67 | |||
68 | private IHttpServer m_httpListener; | ||
69 | private UUID m_agentID; | ||
70 | private string m_regionName; | ||
71 | |||
72 | public UUID AgentID | ||
73 | { | ||
74 | get { return m_agentID; } | ||
75 | } | ||
76 | |||
77 | public string RegionName | ||
78 | { | ||
79 | get { return m_regionName; } | ||
80 | } | ||
81 | |||
82 | public string HostName | ||
83 | { | ||
84 | get { return m_httpListenerHostName; } | ||
85 | } | ||
86 | |||
87 | public uint Port | ||
88 | { | ||
89 | get { return m_httpListenPort; } | ||
90 | } | ||
91 | |||
92 | public IHttpServer HttpListener | ||
93 | { | ||
94 | get { return m_httpListener; } | ||
95 | } | ||
96 | |||
97 | public bool SSLCaps | ||
98 | { | ||
99 | get { return m_httpListener.UseSSL; } | ||
100 | } | ||
101 | public string SSLCommonName | ||
102 | { | ||
103 | get { return m_httpListener.SSLCommonName; } | ||
104 | } | ||
105 | public CapsHandlers CapsHandlers | ||
106 | { | ||
107 | get { return m_capsHandlers; } | ||
108 | } | ||
109 | public Dictionary<string, string> ExternalCapsHandlers | ||
110 | { | ||
111 | get { return m_externalCapsHandlers; } | ||
112 | } | ||
113 | |||
114 | public Caps(IHttpServer httpServer, string httpListen, uint httpPort, string capsPath, | ||
115 | UUID agent, string regionName) | ||
116 | { | ||
117 | m_capsObjectPath = capsPath; | ||
118 | m_httpListener = httpServer; | ||
119 | m_httpListenerHostName = httpListen; | ||
120 | |||
121 | m_httpListenPort = httpPort; | ||
122 | |||
123 | if (httpServer != null && httpServer.UseSSL) | ||
124 | { | ||
125 | m_httpListenPort = httpServer.SSLPort; | ||
126 | httpListen = httpServer.SSLCommonName; | ||
127 | httpPort = httpServer.SSLPort; | ||
128 | } | ||
129 | |||
130 | m_agentID = agent; | ||
131 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); | ||
132 | m_externalCapsHandlers = new Dictionary<string, string>(); | ||
133 | m_regionName = regionName; | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Register a handler. This allows modules to register handlers. | ||
138 | /// </summary> | ||
139 | /// <param name="capName"></param> | ||
140 | /// <param name="handler"></param> | ||
141 | public void RegisterHandler(string capName, IRequestHandler handler) | ||
142 | { | ||
143 | m_capsHandlers[capName] = handler; | ||
144 | //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// Register an external handler. The service for this capability is somewhere else | ||
149 | /// given by the URL. | ||
150 | /// </summary> | ||
151 | /// <param name="capsName"></param> | ||
152 | /// <param name="url"></param> | ||
153 | public void RegisterHandler(string capsName, string url) | ||
154 | { | ||
155 | m_externalCapsHandlers.Add(capsName, url); | ||
156 | } | ||
157 | |||
158 | /// <summary> | ||
159 | /// Remove all CAPS service handlers. | ||
160 | /// | ||
161 | /// </summary> | ||
162 | /// <param name="httpListener"></param> | ||
163 | /// <param name="path"></param> | ||
164 | /// <param name="restMethod"></param> | ||
165 | public void DeregisterHandlers() | ||
166 | { | ||
167 | if (m_capsHandlers != null) | ||
168 | { | ||
169 | foreach (string capsName in m_capsHandlers.Caps) | ||
170 | { | ||
171 | m_capsHandlers.Remove(capsName); | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | } | ||
diff --git a/OpenSim/Framework/Capabilities/CapsHandlers.cs b/OpenSim/Capabilities/CapsHandlers.cs index e1c800e..e1c800e 100644 --- a/OpenSim/Framework/Capabilities/CapsHandlers.cs +++ b/OpenSim/Capabilities/CapsHandlers.cs | |||
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs index fc1ddef..c60abb1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Specialized; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Web; | 33 | using System.Web; |
34 | using Mono.Addins; | ||
35 | using log4net; | 34 | using log4net; |
36 | using Nini.Config; | 35 | using Nini.Config; |
37 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -39,90 +38,23 @@ using OpenMetaverse.StructuredData; | |||
39 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Servers; | 39 | using OpenSim.Framework.Servers; |
41 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
45 | using Caps = OpenSim.Framework.Capabilities.Caps; | 42 | using Caps = OpenSim.Framework.Capabilities.Caps; |
46 | 43 | ||
47 | namespace OpenSim.Region.CoreModules.Avatar.Assets | 44 | namespace OpenSim.Capabilities.Handlers |
48 | { | 45 | { |
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 46 | public class GetMeshHandler |
50 | public class GetMeshModule : INonSharedRegionModule | ||
51 | { | 47 | { |
52 | // private static readonly ILog m_log = | 48 | // private static readonly ILog m_log = |
53 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | 50 | ||
55 | private Scene m_scene; | ||
56 | private IAssetService m_assetService; | 51 | private IAssetService m_assetService; |
57 | private bool m_enabled = true; | ||
58 | 52 | ||
59 | #region IRegionModuleBase Members | 53 | public GetMeshHandler(IAssetService assService) |
60 | |||
61 | |||
62 | public Type ReplaceableInterface | ||
63 | { | ||
64 | get { return null; } | ||
65 | } | ||
66 | |||
67 | public void Initialise(IConfigSource source) | ||
68 | { | ||
69 | IConfig meshConfig = source.Configs["Mesh"]; | ||
70 | if (meshConfig == null) | ||
71 | return; | ||
72 | |||
73 | m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene pScene) | ||
77 | { | ||
78 | m_scene = pScene; | ||
79 | } | ||
80 | |||
81 | public void RemoveRegion(Scene scene) | ||
82 | { | 54 | { |
83 | 55 | m_assetService = assService; | |
84 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
85 | m_scene = null; | ||
86 | } | 56 | } |
87 | 57 | ||
88 | public void RegionLoaded(Scene scene) | ||
89 | { | ||
90 | |||
91 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | ||
92 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
93 | } | ||
94 | |||
95 | #endregion | ||
96 | |||
97 | |||
98 | #region IRegionModule Members | ||
99 | |||
100 | |||
101 | |||
102 | public void Close() { } | ||
103 | |||
104 | public string Name { get { return "GetMeshModule"; } } | ||
105 | |||
106 | |||
107 | public void RegisterCaps(UUID agentID, Caps caps) | ||
108 | { | ||
109 | if(!m_enabled) | ||
110 | return; | ||
111 | |||
112 | UUID capID = UUID.Random(); | ||
113 | |||
114 | // m_log.Info("[GETMESH]: /CAPS/" + capID); | ||
115 | |||
116 | caps.RegisterHandler("GetMesh", | ||
117 | new RestHTTPHandler("GET", "/CAPS/" + capID, | ||
118 | delegate(Hashtable m_dhttpMethod) | ||
119 | { | ||
120 | return ProcessGetMesh(m_dhttpMethod, agentID, caps); | ||
121 | })); | ||
122 | } | ||
123 | |||
124 | #endregion | ||
125 | |||
126 | public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) | 58 | public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) |
127 | { | 59 | { |
128 | 60 | ||
diff --git a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs new file mode 100644 index 0000000..fa5f755 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs | |||
@@ -0,0 +1,79 @@ | |||
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 Nini.Config; | ||
31 | using OpenSim.Server.Base; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | ||
34 | using OpenSim.Server.Handlers.Base; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Capabilities.Handlers | ||
41 | { | ||
42 | public class GetMeshServerConnector : ServiceConnector | ||
43 | { | ||
44 | private IAssetService m_AssetService; | ||
45 | private string m_ConfigName = "CapsService"; | ||
46 | |||
47 | public GetMeshServerConnector(IConfigSource config, IHttpServer server, string configName) : | ||
48 | base(config, server, configName) | ||
49 | { | ||
50 | if (configName != String.Empty) | ||
51 | m_ConfigName = configName; | ||
52 | |||
53 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
54 | if (serverConfig == null) | ||
55 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | ||
56 | |||
57 | string assetService = serverConfig.GetString("AssetService", String.Empty); | ||
58 | |||
59 | if (assetService == String.Empty) | ||
60 | throw new Exception("No AssetService in config file"); | ||
61 | |||
62 | Object[] args = new Object[] { config }; | ||
63 | m_AssetService = | ||
64 | ServerUtils.LoadPlugin<IAssetService>(assetService, args); | ||
65 | |||
66 | if (m_AssetService == null) | ||
67 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); | ||
68 | |||
69 | GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService); | ||
70 | IRequestHandler reqHandler = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), | ||
71 | delegate(Hashtable m_dhttpMethod) | ||
72 | { | ||
73 | return gmeshHandler.ProcessGetMesh(m_dhttpMethod, UUID.Zero, null); | ||
74 | }); | ||
75 | server.AddStreamHandler(reqHandler); | ||
76 | } | ||
77 | |||
78 | } | ||
79 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index df4d561..00ff3d0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | |||
@@ -42,39 +42,16 @@ using OpenSim.Framework; | |||
42 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Framework.Servers.HttpServer; | 43 | using OpenSim.Framework.Servers.HttpServer; |
44 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Region.Framework.Scenes; | ||
46 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
47 | using Caps = OpenSim.Framework.Capabilities.Caps; | 46 | using Caps = OpenSim.Framework.Capabilities.Caps; |
48 | 47 | ||
49 | namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps | 48 | namespace OpenSim.Capabilities.Handlers |
50 | { | 49 | { |
51 | #region Stream Handler | ||
52 | 50 | ||
53 | public delegate byte[] StreamHandlerCallback(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse); | 51 | public class GetTextureHandler : BaseStreamHandler |
54 | |||
55 | public class StreamHandler : BaseStreamHandler | ||
56 | { | ||
57 | StreamHandlerCallback m_callback; | ||
58 | |||
59 | public StreamHandler(string httpMethod, string path, StreamHandlerCallback callback) | ||
60 | : base(httpMethod, path) | ||
61 | { | ||
62 | m_callback = callback; | ||
63 | } | ||
64 | |||
65 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
66 | { | ||
67 | return m_callback(path, request, httpRequest, httpResponse); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | #endregion Stream Handler | ||
72 | |||
73 | public class GetTextureModule : IRegionModule | ||
74 | { | 52 | { |
75 | private static readonly ILog m_log = | 53 | private static readonly ILog m_log = |
76 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | private Scene m_scene; | ||
78 | private IAssetService m_assetService; | 55 | private IAssetService m_assetService; |
79 | 56 | ||
80 | public const string DefaultFormat = "x-j2c"; | 57 | public const string DefaultFormat = "x-j2c"; |
@@ -82,44 +59,22 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps | |||
82 | // TODO: Change this to a config option | 59 | // TODO: Change this to a config option |
83 | const string REDIRECT_URL = null; | 60 | const string REDIRECT_URL = null; |
84 | 61 | ||
85 | 62 | public GetTextureHandler(string path, IAssetService assService) : | |
86 | #region IRegionModule Members | 63 | base("GET", path) |
87 | |||
88 | public void Initialise(Scene pScene, IConfigSource pSource) | ||
89 | { | ||
90 | m_scene = pScene; | ||
91 | } | ||
92 | |||
93 | public void PostInitialise() | ||
94 | { | 64 | { |
95 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | 65 | m_assetService = assService; |
96 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
97 | } | 66 | } |
98 | 67 | ||
99 | public void Close() { } | 68 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
100 | |||
101 | public string Name { get { return "GetTextureModule"; } } | ||
102 | public bool IsSharedModule { get { return false; } } | ||
103 | |||
104 | public void RegisterCaps(UUID agentID, Caps caps) | ||
105 | { | ||
106 | UUID capID = UUID.Random(); | ||
107 | |||
108 | // m_log.InfoFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | ||
109 | caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | ||
110 | } | ||
111 | |||
112 | #endregion | ||
113 | |||
114 | private byte[] ProcessGetTexture(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
115 | { | 69 | { |
116 | //m_log.DebugFormat("[GETTEXTURE]: called in {0}", m_scene.RegionInfo.RegionName); | ||
117 | 70 | ||
118 | // Try to parse the texture ID from the request URL | 71 | // Try to parse the texture ID from the request URL |
119 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | 72 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); |
120 | string textureStr = query.GetOne("texture_id"); | 73 | string textureStr = query.GetOne("texture_id"); |
121 | string format = query.GetOne("format"); | 74 | string format = query.GetOne("format"); |
122 | 75 | ||
76 | m_log.DebugFormat("[GETTEXTURE]: called {0}", textureStr); | ||
77 | |||
123 | if (m_assetService == null) | 78 | if (m_assetService == null) |
124 | { | 79 | { |
125 | m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service"); | 80 | m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service"); |
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs new file mode 100644 index 0000000..0d072f7 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs | |||
@@ -0,0 +1,69 @@ | |||
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 Nini.Config; | ||
30 | using OpenSim.Server.Base; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | using OpenSim.Server.Handlers.Base; | ||
34 | using OpenMetaverse; | ||
35 | |||
36 | namespace OpenSim.Capabilities.Handlers | ||
37 | { | ||
38 | public class GetTextureServerConnector : ServiceConnector | ||
39 | { | ||
40 | private IAssetService m_AssetService; | ||
41 | private string m_ConfigName = "CapsService"; | ||
42 | |||
43 | public GetTextureServerConnector(IConfigSource config, IHttpServer server, string configName) : | ||
44 | base(config, server, configName) | ||
45 | { | ||
46 | if (configName != String.Empty) | ||
47 | m_ConfigName = configName; | ||
48 | |||
49 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
50 | if (serverConfig == null) | ||
51 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | ||
52 | |||
53 | string assetService = serverConfig.GetString("AssetService", String.Empty); | ||
54 | |||
55 | if (assetService == String.Empty) | ||
56 | throw new Exception("No AssetService in config file"); | ||
57 | |||
58 | Object[] args = new Object[] { config }; | ||
59 | m_AssetService = | ||
60 | ServerUtils.LoadPlugin<IAssetService>(assetService, args); | ||
61 | |||
62 | if (m_AssetService == null) | ||
63 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); | ||
64 | |||
65 | server.AddStreamHandler(new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService)); | ||
66 | } | ||
67 | |||
68 | } | ||
69 | } | ||
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs new file mode 100644 index 0000000..6fd7946 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | |||
@@ -0,0 +1,299 @@ | |||
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.Reflection; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Capabilities; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
42 | |||
43 | namespace OpenSim.Capabilities.Handlers | ||
44 | { | ||
45 | |||
46 | public class WebFetchInvDescHandler | ||
47 | { | ||
48 | private static readonly ILog m_log = | ||
49 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IInventoryService m_InventoryService; | ||
52 | private ILibraryService m_LibraryService; | ||
53 | private object m_fetchLock = new Object(); | ||
54 | |||
55 | public WebFetchInvDescHandler(IInventoryService invService, ILibraryService libService) | ||
56 | { | ||
57 | m_InventoryService = invService; | ||
58 | m_LibraryService = libService; | ||
59 | } | ||
60 | |||
61 | public string FetchInventoryDescendentsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
62 | { | ||
63 | // nasty temporary hack here, the linden client falsely | ||
64 | // identifies the uuid 00000000-0000-0000-0000-000000000000 | ||
65 | // as a string which breaks us | ||
66 | // | ||
67 | // correctly mark it as a uuid | ||
68 | // | ||
69 | request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); | ||
70 | |||
71 | // another hack <integer>1</integer> results in a | ||
72 | // System.ArgumentException: Object type System.Int32 cannot | ||
73 | // be converted to target type: System.Boolean | ||
74 | // | ||
75 | request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); | ||
76 | request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); | ||
77 | |||
78 | Hashtable hash = new Hashtable(); | ||
79 | try | ||
80 | { | ||
81 | hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
82 | } | ||
83 | catch (LLSD.LLSDParseException pe) | ||
84 | { | ||
85 | m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); | ||
86 | m_log.Error("Request: " + request.ToString()); | ||
87 | } | ||
88 | |||
89 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | ||
90 | |||
91 | string response = ""; | ||
92 | lock (m_fetchLock) | ||
93 | { | ||
94 | for (int i = 0; i < foldersrequested.Count; i++) | ||
95 | { | ||
96 | string inventoryitemstr = ""; | ||
97 | Hashtable inventoryhash = (Hashtable)foldersrequested[i]; | ||
98 | |||
99 | LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); | ||
100 | |||
101 | try | ||
102 | { | ||
103 | LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); | ||
104 | } | ||
105 | catch (Exception e) | ||
106 | { | ||
107 | m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); | ||
108 | } | ||
109 | LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); | ||
110 | |||
111 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); | ||
112 | inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); | ||
113 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | ||
114 | |||
115 | response += inventoryitemstr; | ||
116 | } | ||
117 | |||
118 | |||
119 | if (response.Length == 0) | ||
120 | { | ||
121 | // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. | ||
122 | // Therefore, I'm concluding that the client only has so many threads available to do requests | ||
123 | // and when a thread stalls.. is stays stalled. | ||
124 | // Therefore we need to return something valid | ||
125 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
130 | } | ||
131 | |||
132 | //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); | ||
133 | //m_log.Debug("[CAPS] "+response); | ||
134 | |||
135 | } | ||
136 | return response; | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// Construct an LLSD reply packet to a CAPS inventory request | ||
141 | /// </summary> | ||
142 | /// <param name="invFetch"></param> | ||
143 | /// <returns></returns> | ||
144 | private LLSDInventoryDescendents FetchInventoryReply(LLSDFetchInventoryDescendents invFetch) | ||
145 | { | ||
146 | LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); | ||
147 | LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); | ||
148 | contents.agent_id = invFetch.owner_id; | ||
149 | contents.owner_id = invFetch.owner_id; | ||
150 | contents.folder_id = invFetch.folder_id; | ||
151 | |||
152 | reply.folders.Array.Add(contents); | ||
153 | InventoryCollection inv = new InventoryCollection(); | ||
154 | inv.Folders = new List<InventoryFolderBase>(); | ||
155 | inv.Items = new List<InventoryItemBase>(); | ||
156 | int version = 0; | ||
157 | |||
158 | inv = Fetch(invFetch.owner_id, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); | ||
159 | |||
160 | if (inv.Folders != null) | ||
161 | { | ||
162 | foreach (InventoryFolderBase invFolder in inv.Folders) | ||
163 | { | ||
164 | contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | if (inv.Items != null) | ||
169 | { | ||
170 | foreach (InventoryItemBase invItem in inv.Items) | ||
171 | { | ||
172 | contents.items.Array.Add(ConvertInventoryItem(invItem)); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | contents.descendents = contents.items.Array.Count + contents.categories.Array.Count; | ||
177 | contents.version = version; | ||
178 | |||
179 | return reply; | ||
180 | } | ||
181 | |||
182 | public InventoryCollection Fetch(UUID agentID, UUID folderID, UUID ownerID, | ||
183 | bool fetchFolders, bool fetchItems, int sortOrder, out int version) | ||
184 | { | ||
185 | m_log.DebugFormat( | ||
186 | "[WEBFETCHINVENTORYDESCENDANTS]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", | ||
187 | fetchFolders, fetchItems, folderID, agentID); | ||
188 | |||
189 | version = 0; | ||
190 | InventoryFolderImpl fold; | ||
191 | if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner) | ||
192 | if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) | ||
193 | { | ||
194 | InventoryCollection ret = new InventoryCollection(); | ||
195 | ret.Folders = new List<InventoryFolderBase>(); | ||
196 | ret.Items = fold.RequestListOfItems(); | ||
197 | |||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | InventoryCollection contents = new InventoryCollection(); | ||
202 | |||
203 | if (folderID != UUID.Zero) | ||
204 | { | ||
205 | contents = m_InventoryService.GetFolderContent(agentID, folderID); | ||
206 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | ||
207 | containingFolder.ID = folderID; | ||
208 | containingFolder.Owner = agentID; | ||
209 | containingFolder = m_InventoryService.GetFolder(containingFolder); | ||
210 | if (containingFolder != null) | ||
211 | version = containingFolder.Version; | ||
212 | } | ||
213 | else | ||
214 | { | ||
215 | // Lost itemsm don't really need a version | ||
216 | version = 1; | ||
217 | } | ||
218 | |||
219 | return contents; | ||
220 | |||
221 | } | ||
222 | /// <summary> | ||
223 | /// Convert an internal inventory folder object into an LLSD object. | ||
224 | /// </summary> | ||
225 | /// <param name="invFolder"></param> | ||
226 | /// <returns></returns> | ||
227 | private LLSDInventoryFolder ConvertInventoryFolder(InventoryFolderBase invFolder) | ||
228 | { | ||
229 | LLSDInventoryFolder llsdFolder = new LLSDInventoryFolder(); | ||
230 | llsdFolder.folder_id = invFolder.ID; | ||
231 | llsdFolder.parent_id = invFolder.ParentID; | ||
232 | llsdFolder.name = invFolder.Name; | ||
233 | if (invFolder.Type < 0 || invFolder.Type >= TaskInventoryItem.Types.Length) | ||
234 | llsdFolder.type = "-1"; | ||
235 | else | ||
236 | llsdFolder.type = TaskInventoryItem.Types[invFolder.Type]; | ||
237 | llsdFolder.preferred_type = "-1"; | ||
238 | |||
239 | return llsdFolder; | ||
240 | } | ||
241 | |||
242 | /// <summary> | ||
243 | /// Convert an internal inventory item object into an LLSD object. | ||
244 | /// </summary> | ||
245 | /// <param name="invItem"></param> | ||
246 | /// <returns></returns> | ||
247 | private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) | ||
248 | { | ||
249 | LLSDInventoryItem llsdItem = new LLSDInventoryItem(); | ||
250 | llsdItem.asset_id = invItem.AssetID; | ||
251 | llsdItem.created_at = invItem.CreationDate; | ||
252 | llsdItem.desc = invItem.Description; | ||
253 | llsdItem.flags = (int)invItem.Flags; | ||
254 | llsdItem.item_id = invItem.ID; | ||
255 | llsdItem.name = invItem.Name; | ||
256 | llsdItem.parent_id = invItem.Folder; | ||
257 | try | ||
258 | { | ||
259 | // TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions. | ||
260 | llsdItem.type = TaskInventoryItem.Types[invItem.AssetType]; | ||
261 | llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType]; | ||
262 | } | ||
263 | catch (Exception e) | ||
264 | { | ||
265 | m_log.ErrorFormat("[CAPS]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}", invItem.AssetType, invItem.InvType, invItem.Name, e.Message); | ||
266 | } | ||
267 | llsdItem.permissions = new LLSDPermissions(); | ||
268 | llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; | ||
269 | llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; | ||
270 | llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; | ||
271 | llsdItem.permissions.group_id = invItem.GroupID; | ||
272 | llsdItem.permissions.group_mask = (int)invItem.GroupPermissions; | ||
273 | llsdItem.permissions.is_owner_group = invItem.GroupOwned; | ||
274 | llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; | ||
275 | llsdItem.permissions.owner_id = invItem.Owner; | ||
276 | llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; | ||
277 | llsdItem.sale_info = new LLSDSaleInfo(); | ||
278 | llsdItem.sale_info.sale_price = invItem.SalePrice; | ||
279 | switch (invItem.SaleType) | ||
280 | { | ||
281 | default: | ||
282 | llsdItem.sale_info.sale_type = "not"; | ||
283 | break; | ||
284 | case 1: | ||
285 | llsdItem.sale_info.sale_type = "original"; | ||
286 | break; | ||
287 | case 2: | ||
288 | llsdItem.sale_info.sale_type = "copy"; | ||
289 | break; | ||
290 | case 3: | ||
291 | llsdItem.sale_info.sale_type = "contents"; | ||
292 | break; | ||
293 | } | ||
294 | |||
295 | return llsdItem; | ||
296 | } | ||
297 | |||
298 | } | ||
299 | } | ||
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescServerConnector.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescServerConnector.cs new file mode 100644 index 0000000..92eeb14 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescServerConnector.cs | |||
@@ -0,0 +1,76 @@ | |||
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 Nini.Config; | ||
30 | using OpenSim.Server.Base; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | using OpenSim.Server.Handlers.Base; | ||
34 | using OpenMetaverse; | ||
35 | |||
36 | namespace OpenSim.Capabilities.Handlers | ||
37 | { | ||
38 | public class WebFetchInvDescServerConnector : ServiceConnector | ||
39 | { | ||
40 | private IInventoryService m_InventoryService; | ||
41 | private ILibraryService m_LibraryService; | ||
42 | private string m_ConfigName = "CapsService"; | ||
43 | |||
44 | public WebFetchInvDescServerConnector(IConfigSource config, IHttpServer server, string configName) : | ||
45 | base(config, server, configName) | ||
46 | { | ||
47 | if (configName != String.Empty) | ||
48 | m_ConfigName = configName; | ||
49 | |||
50 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
51 | if (serverConfig == null) | ||
52 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | ||
53 | |||
54 | string invService = serverConfig.GetString("InventoryService", String.Empty); | ||
55 | |||
56 | if (invService == String.Empty) | ||
57 | throw new Exception("No InventoryService in config file"); | ||
58 | |||
59 | Object[] args = new Object[] { config }; | ||
60 | m_InventoryService = | ||
61 | ServerUtils.LoadPlugin<IInventoryService>(invService, args); | ||
62 | |||
63 | if (m_InventoryService == null) | ||
64 | throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName)); | ||
65 | |||
66 | string libService = serverConfig.GetString("LibraryService", String.Empty); | ||
67 | m_LibraryService = | ||
68 | ServerUtils.LoadPlugin<ILibraryService>(libService, args); | ||
69 | |||
70 | WebFetchInvDescHandler webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); | ||
71 | IRequestHandler reqHandler = new RestStreamHandler("POST", "/CAPS/WebFetchInvDesc/" /*+ UUID.Random()*/, webFetchHandler.FetchInventoryDescendentsRequest); | ||
72 | server.AddStreamHandler(reqHandler); | ||
73 | } | ||
74 | |||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/Framework/Capabilities/LLSD.cs b/OpenSim/Capabilities/LLSD.cs index eec9e61..eec9e61 100644 --- a/OpenSim/Framework/Capabilities/LLSD.cs +++ b/OpenSim/Capabilities/LLSD.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDArray.cs b/OpenSim/Capabilities/LLSDArray.cs index 3459e49..3459e49 100644 --- a/OpenSim/Framework/Capabilities/LLSDArray.cs +++ b/OpenSim/Capabilities/LLSDArray.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs index ab6cee5..ab6cee5 100644 --- a/OpenSim/Framework/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs index 6e66f0a..6e66f0a 100644 --- a/OpenSim/Framework/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs index 0d6f7f9..0d6f7f9 100644 --- a/OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDCapEvent.cs b/OpenSim/Capabilities/LLSDCapEvent.cs index 63abd62..63abd62 100644 --- a/OpenSim/Framework/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Capabilities/LLSDCapEvent.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDEmpty.cs b/OpenSim/Capabilities/LLSDEmpty.cs index f94fcba..f94fcba 100644 --- a/OpenSim/Framework/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Capabilities/LLSDEmpty.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDHelpers.cs b/OpenSim/Capabilities/LLSDHelpers.cs index 8f1a40e..8f1a40e 100644 --- a/OpenSim/Framework/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Capabilities/LLSDHelpers.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDInventoryFolder.cs b/OpenSim/Capabilities/LLSDInventoryFolder.cs index 3c216e9..3c216e9 100644 --- a/OpenSim/Framework/Capabilities/LLSDInventoryFolder.cs +++ b/OpenSim/Capabilities/LLSDInventoryFolder.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDInventoryItem.cs b/OpenSim/Capabilities/LLSDInventoryItem.cs index cce18d7..cce18d7 100644 --- a/OpenSim/Framework/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Capabilities/LLSDInventoryItem.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDItemUpdate.cs b/OpenSim/Capabilities/LLSDItemUpdate.cs index 96e2b61..96e2b61 100644 --- a/OpenSim/Framework/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Capabilities/LLSDItemUpdate.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDMapLayer.cs b/OpenSim/Capabilities/LLSDMapLayer.cs index 4aeb1ff..4aeb1ff 100644 --- a/OpenSim/Framework/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Capabilities/LLSDMapLayer.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Capabilities/LLSDMapLayerResponse.cs index 839e34c..839e34c 100644 --- a/OpenSim/Framework/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Capabilities/LLSDMapLayerResponse.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDMapRequest.cs b/OpenSim/Capabilities/LLSDMapRequest.cs index debf387..debf387 100644 --- a/OpenSim/Framework/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Capabilities/LLSDMapRequest.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDMethod.cs b/OpenSim/Capabilities/LLSDMethod.cs index cd2574d..cd2574d 100644 --- a/OpenSim/Framework/Capabilities/LLSDMethod.cs +++ b/OpenSim/Capabilities/LLSDMethod.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDMethodString.cs b/OpenSim/Capabilities/LLSDMethodString.cs index 38700d5..38700d5 100644 --- a/OpenSim/Framework/Capabilities/LLSDMethodString.cs +++ b/OpenSim/Capabilities/LLSDMethodString.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Capabilities/LLSDParcelVoiceInfoResponse.cs index b34a668..b34a668 100644 --- a/OpenSim/Framework/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Capabilities/LLSDParcelVoiceInfoResponse.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Capabilities/LLSDRemoteParcelResponse.cs index 13d69d3..13d69d3 100644 --- a/OpenSim/Framework/Capabilities/LLSDRemoteParcelResponse.cs +++ b/OpenSim/Capabilities/LLSDRemoteParcelResponse.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs b/OpenSim/Capabilities/LLSDStreamHandler.cs index 7aaa994..7aaa994 100644 --- a/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Capabilities/LLSDStreamHandler.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Capabilities/LLSDTaskInventoryUploadComplete.cs index 47fdaca..47fdaca 100644 --- a/OpenSim/Framework/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Capabilities/LLSDTaskInventoryUploadComplete.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Capabilities/LLSDTaskScriptUpdate.cs index 9d7c17f..9d7c17f 100644 --- a/OpenSim/Framework/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Capabilities/LLSDTaskScriptUpdate.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDTaskScriptUploadComplete.cs b/OpenSim/Capabilities/LLSDTaskScriptUploadComplete.cs index d308831..d308831 100644 --- a/OpenSim/Framework/Capabilities/LLSDTaskScriptUploadComplete.cs +++ b/OpenSim/Capabilities/LLSDTaskScriptUploadComplete.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDTest.cs b/OpenSim/Capabilities/LLSDTest.cs index 5f77c3d..5f77c3d 100644 --- a/OpenSim/Framework/Capabilities/LLSDTest.cs +++ b/OpenSim/Capabilities/LLSDTest.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDType.cs b/OpenSim/Capabilities/LLSDType.cs index d5ca1ab..d5ca1ab 100644 --- a/OpenSim/Framework/Capabilities/LLSDType.cs +++ b/OpenSim/Capabilities/LLSDType.cs | |||
diff --git a/OpenSim/Framework/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Capabilities/LLSDVoiceAccountResponse.cs index 53c11e7..53c11e7 100644 --- a/OpenSim/Framework/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Capabilities/LLSDVoiceAccountResponse.cs | |||