diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs (renamed from OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs) | 61 |
1 files changed, 8 insertions, 53 deletions
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"); |