aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs145
1 files changed, 145 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
new file mode 100644
index 0000000..b406b37
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -0,0 +1,145 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Collections.Specialized;
32using System.Drawing;
33using System.Drawing.Imaging;
34using System.Reflection;
35using System.IO;
36using System.Web;
37using log4net;
38using Nini.Config;
39using Mono.Addins;
40using OpenMetaverse;
41using OpenMetaverse.StructuredData;
42using OpenMetaverse.Imaging;
43using OpenSim.Framework;
44using OpenSim.Framework.Servers;
45using OpenSim.Framework.Servers.HttpServer;
46using OpenSim.Region.Framework.Interfaces;
47using OpenSim.Region.Framework.Scenes;
48using OpenSim.Services.Interfaces;
49using Caps = OpenSim.Framework.Capabilities.Caps;
50using OpenSim.Capabilities.Handlers;
51
52namespace OpenSim.Region.ClientStack.Linden
53{
54 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")]
55 public class UploadBakedTextureModule : INonSharedRegionModule
56 {
57 private static readonly ILog m_log =
58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59
60 /// <summary>
61 /// For historical reasons this is fixed, but there
62 /// </summary>
63 private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
64
65 private Scene m_scene;
66
67 private string m_URL;
68
69 public void Initialise(IConfigSource source)
70 {
71 IConfig config = source.Configs["ClientStack.LindenCaps"];
72 if (config == null)
73 return;
74
75 m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty);
76
77// IConfig appearanceConfig = source.Configs["Appearance"];
78 }
79
80 public void AddRegion(Scene s)
81 {
82 m_scene = s;
83 }
84
85 public void RemoveRegion(Scene s)
86 {
87 s.EventManager.OnRegisterCaps -= RegisterCaps;
88 s.EventManager.OnNewPresence -= RegisterNewPresence;
89 s.EventManager.OnRemovePresence -= DeRegisterPresence;
90 m_scene = null;
91 }
92
93 public void RegionLoaded(Scene s)
94 {
95 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
96 m_scene.EventManager.OnNewPresence += RegisterNewPresence;
97 m_scene.EventManager.OnRemovePresence += DeRegisterPresence;
98 }
99
100 private void DeRegisterPresence(UUID agentId)
101 {
102 }
103
104 private void RegisterNewPresence(ScenePresence presence)
105 {
106 }
107
108 public void PostInitialise()
109 {
110 }
111
112 public void Close() { }
113
114 public string Name { get { return "UploadBakedTextureModule"; } }
115
116 public Type ReplaceableInterface
117 {
118 get { return null; }
119 }
120
121 public void RegisterCaps(UUID agentID, Caps caps)
122 {
123 //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
124 if (m_URL == "localhost")
125 {
126 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler(
127 caps, m_scene.AssetService);
128
129 caps.RegisterHandler(
130 "UploadBakedTexture",
131 new RestStreamHandler(
132 "POST",
133 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath,
134 avatarhandler.UploadBakedTexture,
135 "UploadBakedTexture",
136 agentID.ToString()));
137
138 }
139 else
140 {
141 caps.RegisterHandler("UploadBakedTexture", m_URL);
142 }
143 }
144 }
145}