diff options
author | Diva Canto | 2014-11-10 19:03:06 -0800 |
---|---|---|
committer | Diva Canto | 2014-11-10 19:03:06 -0800 |
commit | 5e34727b7e2796e6eb621cdc3ede48ab796c198e (patch) | |
tree | 4a47c34bc3a80e7d020de4a89984b18ab9a9f258 /OpenSim/Region/OptionalModules | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-5e34727b7e2796e6eb621cdc3ede48ab796c198e.zip opensim-SC-5e34727b7e2796e6eb621cdc3ede48ab796c198e.tar.gz opensim-SC-5e34727b7e2796e6eb621cdc3ede48ab796c198e.tar.bz2 opensim-SC-5e34727b7e2796e6eb621cdc3ede48ab796c198e.tar.xz |
Add additional viewer support modules that allow certain viewers to modify their UI on the fly.
Diffstat (limited to 'OpenSim/Region/OptionalModules')
3 files changed, 494 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs new file mode 100644 index 0000000..c56e029 --- /dev/null +++ b/OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs | |||
@@ -0,0 +1,173 @@ | |||
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.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Threading; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | using OpenSim; | ||
38 | using OpenSim.Region; | ||
39 | using OpenSim.Region.Framework; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Framework; | ||
43 | //using OpenSim.Framework.Capabilities; | ||
44 | using OpenSim.Framework.Servers; | ||
45 | using OpenSim.Framework.Servers.HttpServer; | ||
46 | using Nini.Config; | ||
47 | using log4net; | ||
48 | using Mono.Addins; | ||
49 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
50 | using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; | ||
51 | |||
52 | namespace OpenSim.Region.OptionalModules.ViewerSupport | ||
53 | { | ||
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CameraOnlyMode")] | ||
55 | public class CameraOnlyModeModule : INonSharedRegionModule | ||
56 | { | ||
57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
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 "CameraOnlyModeModule"; } | ||
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["CameraOnlyModeModule"]; | ||
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("[CAMERA-ONLY MODE]: CameraOnlyModeModule 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 | IEntityTransferModule et = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
99 | m_Helper = new SimulatorFeaturesHelper(scene, et); | ||
100 | //m_scene.EventManager.OnMakeRootAgent += (OnMakeRootAgent); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | //private void OnMakeRootAgent(ScenePresence obj) | ||
105 | //{ | ||
106 | // throw new NotImplementedException(); | ||
107 | //} | ||
108 | |||
109 | public void RegionLoaded(Scene scene) | ||
110 | { | ||
111 | if (m_Enabled) | ||
112 | { | ||
113 | ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>(); | ||
114 | |||
115 | if (featuresModule != null && m_Enabled) | ||
116 | featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | public void RemoveRegion(Scene scene) | ||
121 | { | ||
122 | } | ||
123 | |||
124 | private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) | ||
125 | { | ||
126 | m_log.DebugFormat("[CAMERA-ONLY MODE]: OnSimulatorFeaturesRequest in {0}", m_scene.RegionInfo.RegionName); | ||
127 | if (m_Helper.ShouldSend(agentID) && m_Helper.UserLevel(agentID) <= m_UserLevel) | ||
128 | { | ||
129 | OSDMap extrasMap; | ||
130 | if (features.ContainsKey("OpenSimExtras")) | ||
131 | { | ||
132 | extrasMap = (OSDMap)features["OpenSimExtras"]; | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | extrasMap = new OSDMap(); | ||
137 | features["OpenSimExtras"] = extrasMap; | ||
138 | } | ||
139 | extrasMap["camera-only-mode"] = OSDMap.FromString("true"); | ||
140 | m_log.DebugFormat("[CAMERA-ONLY MODE]: Sent in {0}", m_scene.RegionInfo.RegionName); | ||
141 | Util.FireAndForget(delegate { DetachAttachments(agentID); }); | ||
142 | } | ||
143 | else | ||
144 | m_log.DebugFormat("[CAMERA-ONLY MODE]: NOT Sending camera-only-mode in {0}", m_scene.RegionInfo.RegionName); | ||
145 | } | ||
146 | |||
147 | private void DetachAttachments(UUID agentID) | ||
148 | { | ||
149 | ScenePresence sp = m_scene.GetScenePresence(agentID); | ||
150 | if ((sp.TeleportFlags & TeleportFlags.ViaLogin) != 0) | ||
151 | // Wait a little, cos there's weird stuff going on at login related to | ||
152 | // the Current Outfit Folder | ||
153 | Thread.Sleep(8000); | ||
154 | |||
155 | if (sp != null && m_scene.AttachmentsModule != null) | ||
156 | { | ||
157 | List<SceneObjectGroup> attachs = sp.GetAttachments(); | ||
158 | if (attachs != null && attachs.Count > 0) | ||
159 | { | ||
160 | foreach (SceneObjectGroup sog in attachs) | ||
161 | { | ||
162 | m_log.DebugFormat("[CAMERA-ONLY MODE]: Forcibly detaching attach {0} from {1} in {2}", | ||
163 | sog.Name, sp.Name, m_scene.RegionInfo.RegionName); | ||
164 | |||
165 | m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, sog); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | } | ||
172 | |||
173 | } | ||
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs b/OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs new file mode 100644 index 0000000..1900f31 --- /dev/null +++ b/OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs | |||
@@ -0,0 +1,174 @@ | |||
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.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Threading; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | using OpenSim; | ||
38 | using OpenSim.Region; | ||
39 | using OpenSim.Region.Framework; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Framework; | ||
43 | using OpenSim.Services.Interfaces; | ||
44 | //using OpenSim.Framework.Capabilities; | ||
45 | using Nini.Config; | ||
46 | using log4net; | ||
47 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
48 | using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; | ||
49 | |||
50 | namespace OpenSim.Region.OptionalModules.ViewerSupport | ||
51 | { | ||
52 | public class SimulatorFeaturesHelper | ||
53 | { | ||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | private IEntityTransferModule m_TransferModule; | ||
57 | private Scene m_scene; | ||
58 | |||
59 | private struct RegionSend { | ||
60 | public UUID region; | ||
61 | public bool send; | ||
62 | }; | ||
63 | // Using a static cache so that we don't have to perform the time-consuming tests | ||
64 | // in ShouldSend on Extra SimFeatures that go on the same response but come from | ||
65 | // different modules. | ||
66 | // This cached is indexed on the agentID and maps to a list of regions | ||
67 | private static ExpiringCache<UUID, List<RegionSend>> m_Cache = new ExpiringCache<UUID, List<RegionSend>>(); | ||
68 | private const double TIMEOUT = 1.0; // time in cache | ||
69 | |||
70 | public SimulatorFeaturesHelper(Scene scene, IEntityTransferModule et) | ||
71 | { | ||
72 | m_scene = scene; | ||
73 | m_TransferModule = et; | ||
74 | } | ||
75 | |||
76 | public bool ShouldSend(UUID agentID) | ||
77 | { | ||
78 | List<RegionSend> rsendlist; | ||
79 | RegionSend rsend; | ||
80 | if (m_Cache.TryGetValue(agentID, out rsendlist)) | ||
81 | { | ||
82 | rsend = rsendlist.Find(r => r.region == m_scene.RegionInfo.RegionID); | ||
83 | if (rsend.region != UUID.Zero) // Found it | ||
84 | { | ||
85 | return rsend.send; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | // Relatively complex logic for deciding whether to send the extra SimFeature or not. | ||
90 | // This is because the viewer calls this cap to all sims that it knows about, | ||
91 | // including the departing sims and non-neighbors (those that are cached). | ||
92 | rsend.region = m_scene.RegionInfo.RegionID; | ||
93 | rsend.send = false; | ||
94 | IClientAPI client = null; | ||
95 | int counter = 200; | ||
96 | |||
97 | // Let's wait a little to see if we get a client here | ||
98 | while (!m_scene.TryGetClient(agentID, out client) && counter-- > 0) | ||
99 | Thread.Sleep(50); | ||
100 | |||
101 | if (client != null) | ||
102 | { | ||
103 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
104 | if (sp == null) // Client is connected but SP still doesn't exist: this may happen on login | ||
105 | { | ||
106 | m_log.DebugFormat("[XXX]: SP is null"); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | // On the receiving region, the call to this cap may arrive before | ||
111 | // the agent is root. Make sure we only proceed from here when the agent | ||
112 | // has been made root | ||
113 | counter = 200; | ||
114 | while ((sp.IsInTransit || sp.IsChildAgent) && counter-- > 0) | ||
115 | { | ||
116 | Thread.Sleep(50); | ||
117 | } | ||
118 | |||
119 | // The viewer calls this cap on the departing sims too. Make sure | ||
120 | // that we only proceed after the agent is not in transit anymore. | ||
121 | // The agent must be root and not going anywhere | ||
122 | if (!sp.IsChildAgent && !m_TransferModule.IsInTransit(agentID)) | ||
123 | rsend.send = true; | ||
124 | else | ||
125 | m_log.DebugFormat("[XXX]: Child or in transit"); | ||
126 | } | ||
127 | } | ||
128 | else | ||
129 | m_log.DebugFormat("[XXX]: client is null"); | ||
130 | |||
131 | if (rsendlist == null) | ||
132 | { | ||
133 | rsendlist = new List<RegionSend>(); | ||
134 | m_Cache.AddOrUpdate(agentID, rsendlist, TIMEOUT); | ||
135 | } | ||
136 | rsendlist.Add(rsend); | ||
137 | |||
138 | return rsend.send; | ||
139 | } | ||
140 | |||
141 | public int UserLevel(UUID agentID) | ||
142 | { | ||
143 | int level = 0; | ||
144 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); | ||
145 | if (account != null) | ||
146 | level = account.UserLevel; | ||
147 | |||
148 | return level; | ||
149 | } | ||
150 | |||
151 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | ||
152 | { | ||
153 | int ntimes = 20; | ||
154 | ScenePresence sp = null; | ||
155 | while ((sp = m_scene.GetScenePresence(agentID)) == null && (ntimes-- > 0)) | ||
156 | Thread.Sleep(1000); | ||
157 | |||
158 | if (sp == null) | ||
159 | m_log.WarnFormat( | ||
160 | "[XXX]: Did not find presence with id {0} in {1} before timeout", | ||
161 | agentID, m_scene.RegionInfo.RegionName); | ||
162 | else | ||
163 | { | ||
164 | ntimes = 10; | ||
165 | while (sp.IsInTransit && (ntimes-- > 0)) | ||
166 | Thread.Sleep(1000); | ||
167 | } | ||
168 | |||
169 | return sp; | ||
170 | } | ||
171 | |||
172 | } | ||
173 | |||
174 | } | ||
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs new file mode 100644 index 0000000..6415c6c --- /dev/null +++ b/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs | |||
@@ -0,0 +1,147 @@ | |||
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.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Threading; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | using OpenSim; | ||
37 | using OpenSim.Region; | ||
38 | using OpenSim.Region.Framework; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Framework; | ||
42 | //using OpenSim.Framework.Capabilities; | ||
43 | using OpenSim.Framework.Servers; | ||
44 | using OpenSim.Framework.Servers.HttpServer; | ||
45 | using Nini.Config; | ||
46 | using log4net; | ||
47 | using Mono.Addins; | ||
48 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
49 | using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; | ||
50 | |||
51 | namespace 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 | IEntityTransferModule et = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
99 | m_Helper = new SimulatorFeaturesHelper(scene, et); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public void RegionLoaded(Scene scene) | ||
104 | { | ||
105 | if (m_Enabled) | ||
106 | { | ||
107 | ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>(); | ||
108 | |||
109 | if (featuresModule != null && m_Enabled) | ||
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 | using (StreamReader s = new StreamReader(Path.Combine(VIEWER_SUPPORT_DIR, "panel_toolbar.xml"))) | ||
124 | { | ||
125 | OSDMap extrasMap; | ||
126 | if (features.ContainsKey("OpenSimExtras")) | ||
127 | extrasMap = (OSDMap)features["OpenSimExtras"]; | ||
128 | else | ||
129 | { | ||
130 | extrasMap = new OSDMap(); | ||
131 | features["OpenSimExtras"] = extrasMap; | ||
132 | } | ||
133 | |||
134 | OSDMap specialUI = new OSDMap(); | ||
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 | else | ||
141 | m_log.DebugFormat("[SPECIAL UI]: NOT Sending panel_toolbar.xml in {0}", m_scene.RegionInfo.RegionName); | ||
142 | |||
143 | } | ||
144 | |||
145 | } | ||
146 | |||
147 | } | ||