aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs165
1 files changed, 165 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs
new file mode 100644
index 0000000..3fe922d
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs
@@ -0,0 +1,165 @@
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.IO;
30using System.Reflection;
31using System.Text;
32using System.Collections.Generic;
33using System.Threading;
34using OpenMetaverse;
35using OpenMetaverse.StructuredData;
36using OpenSim;
37using OpenSim.Region;
38using OpenSim.Region.Framework;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Framework;
42//using OpenSim.Framework.Capabilities;
43using OpenSim.Framework.Servers;
44using OpenSim.Framework.Servers.HttpServer;
45using Nini.Config;
46using log4net;
47using Mono.Addins;
48using OSDMap = OpenMetaverse.StructuredData.OSDMap;
49using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
50
51namespace OpenSim.Region.OptionalModules.ViewerSupport
52{
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SpecialUI")]
54 public class SpecialUIModule : INonSharedRegionModule
55 {
56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 private const string VIEWER_SUPPORT_DIR = "ViewerSupport";
58
59 private Scene m_scene;
60 private SimulatorFeaturesHelper m_Helper;
61 private bool m_Enabled;
62 private int m_UserLevel;
63
64 public string Name
65 {
66 get { return "SpecialUIModule"; }
67 }
68
69 public Type ReplaceableInterface
70 {
71 get { return null; }
72 }
73
74 public void Initialise(IConfigSource config)
75 {
76 IConfig moduleConfig = config.Configs["SpecialUIModule"];
77 if (moduleConfig != null)
78 {
79 m_Enabled = moduleConfig.GetBoolean("enabled", false);
80 if (m_Enabled)
81 {
82 m_UserLevel = moduleConfig.GetInt("UserLevel", 0);
83 m_log.Info("[SPECIAL UI]: SpecialUIModule enabled");
84 }
85
86 }
87 }
88
89 public void Close()
90 {
91 }
92
93 public void AddRegion(Scene scene)
94 {
95 if (m_Enabled)
96 {
97 m_scene = scene;
98 }
99 }
100
101 public void RegionLoaded(Scene scene)
102 {
103 if (m_Enabled)
104 {
105 IEntityTransferModule et = m_scene.RequestModuleInterface<IEntityTransferModule>();
106 m_Helper = new SimulatorFeaturesHelper(scene, et);
107
108 ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>();
109 if (featuresModule != null)
110 featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
111 }
112 }
113
114 public void RemoveRegion(Scene scene)
115 {
116 }
117
118 private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features)
119 {
120 m_log.DebugFormat("[SPECIAL UI]: OnSimulatorFeaturesRequest in {0}", m_scene.RegionInfo.RegionName);
121 if (m_Helper.ShouldSend(agentID) && m_Helper.UserLevel(agentID) <= m_UserLevel)
122 {
123 OSDMap extrasMap;
124 OSDMap specialUI = new OSDMap();
125 using (StreamReader s = new StreamReader(Path.Combine(VIEWER_SUPPORT_DIR, "panel_toolbar.xml")))
126 {
127 if (features.ContainsKey("OpenSimExtras"))
128 extrasMap = (OSDMap)features["OpenSimExtras"];
129 else
130 {
131 extrasMap = new OSDMap();
132 features["OpenSimExtras"] = extrasMap;
133 }
134
135 specialUI["toolbar"] = OSDMap.FromString(s.ReadToEnd());
136 extrasMap["special-ui"] = specialUI;
137 }
138 m_log.DebugFormat("[SPECIAL UI]: Sending panel_toolbar.xml in {0}", m_scene.RegionInfo.RegionName);
139
140 if (Directory.Exists(Path.Combine(VIEWER_SUPPORT_DIR, "Floaters")))
141 {
142 OSDMap floaters = new OSDMap();
143 uint n = 0;
144 foreach (String name in Directory.GetFiles(Path.Combine(VIEWER_SUPPORT_DIR, "Floaters"), "*.xml"))
145 {
146 using (StreamReader s = new StreamReader(name))
147 {
148 string simple_name = Path.GetFileNameWithoutExtension(name);
149 OSDMap floater = new OSDMap();
150 floaters[simple_name] = OSDMap.FromString(s.ReadToEnd());
151 n++;
152 }
153 }
154 specialUI["floaters"] = floaters;
155 m_log.DebugFormat("[SPECIAL UI]: Sending {0} floaters", n);
156 }
157 }
158 else
159 m_log.DebugFormat("[SPECIAL UI]: NOT Sending panel_toolbar.xml in {0}", m_scene.RegionInfo.RegionName);
160
161 }
162
163 }
164
165}