diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs new file mode 100644 index 0000000..c9d7ae1 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs | |||
@@ -0,0 +1,149 @@ | |||
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.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using Mono.Addins; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
42 | |||
43 | namespace OpenSim.Region.ClientStack.Linden | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// MeshUploadFlag capability. This is required for uploading Mesh. | ||
47 | /// </summary> | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
49 | public class MeshUploadFlagModule : INonSharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = | ||
52 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | /// <summary> | ||
55 | /// Is this module enabled? | ||
56 | /// </summary> | ||
57 | public bool Enabled { get; private set; } | ||
58 | |||
59 | private Scene m_scene; | ||
60 | private UUID m_agentID; | ||
61 | |||
62 | #region ISharedRegionModule Members | ||
63 | |||
64 | public MeshUploadFlagModule() | ||
65 | { | ||
66 | Enabled = true; | ||
67 | } | ||
68 | |||
69 | public void Initialise(IConfigSource source) | ||
70 | { | ||
71 | IConfig config = source.Configs["Mesh"]; | ||
72 | if (config == null) | ||
73 | { | ||
74 | return; | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | Enabled = config.GetBoolean("AllowMeshUpload", Enabled); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void AddRegion(Scene s) | ||
83 | { | ||
84 | if (!Enabled) | ||
85 | return; | ||
86 | |||
87 | m_scene = s; | ||
88 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
89 | } | ||
90 | |||
91 | public void RemoveRegion(Scene s) | ||
92 | { | ||
93 | if (!Enabled) | ||
94 | return; | ||
95 | |||
96 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
97 | } | ||
98 | |||
99 | public void RegionLoaded(Scene s) | ||
100 | { | ||
101 | } | ||
102 | |||
103 | public void PostInitialise() | ||
104 | { | ||
105 | } | ||
106 | |||
107 | public void Close() { } | ||
108 | |||
109 | public string Name { get { return "MeshUploadFlagModule"; } } | ||
110 | |||
111 | public Type ReplaceableInterface | ||
112 | { | ||
113 | get { return null; } | ||
114 | } | ||
115 | |||
116 | #endregion | ||
117 | |||
118 | public void RegisterCaps(UUID agentID, Caps caps) | ||
119 | { | ||
120 | IRequestHandler reqHandler = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), MeshUploadFlag); | ||
121 | caps.RegisterHandler("MeshUploadFlag", reqHandler); | ||
122 | m_agentID = agentID; | ||
123 | } | ||
124 | |||
125 | private Hashtable MeshUploadFlag(Hashtable mDhttpMethod) | ||
126 | { | ||
127 | m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: MeshUploadFlag request"); | ||
128 | |||
129 | OSDMap data = new OSDMap(); | ||
130 | ScenePresence sp = m_scene.GetScenePresence(m_agentID); | ||
131 | data["username"] = sp.Firstname + "." + sp.Lastname; | ||
132 | data["display_name_next_update"] = new OSDDate(DateTime.Now); | ||
133 | data["legacy_first_name"] = sp.Firstname; | ||
134 | data["mesh_upload_status"] = "valid"; | ||
135 | data["display_name"] = sp.Firstname + " " + sp.Lastname; | ||
136 | data["legacy_last_name"] = sp.Lastname; | ||
137 | data["id"] = m_agentID; | ||
138 | data["is_display_name_default"] = true; | ||
139 | |||
140 | //Send back data | ||
141 | Hashtable responsedata = new Hashtable(); | ||
142 | responsedata["int_response_code"] = 200; | ||
143 | responsedata["content_type"] = "text/plain"; | ||
144 | responsedata["keepalive"] = false; | ||
145 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(data); | ||
146 | return responsedata; | ||
147 | } | ||
148 | } | ||
149 | } \ No newline at end of file | ||