aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps
diff options
context:
space:
mode:
authorfly-man-2018-09-26 15:06:04 +0200
committerUbitUmarov2018-12-16 19:17:18 +0000
commited039a5fe068847bc6774c84cd452f1aaefc5c5a (patch)
tree7ca9e9fcb6b0af1c4ffb2ec6867f991f69413feb /OpenSim/Region/ClientStack/Linden/Caps
parentMerge branch 'master' of opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-ed039a5fe068847bc6774c84cd452f1aaefc5c5a.zip
opensim-SC-ed039a5fe068847bc6774c84cd452f1aaefc5c5a.tar.gz
opensim-SC-ed039a5fe068847bc6774c84cd452f1aaefc5c5a.tar.bz2
opensim-SC-ed039a5fe068847bc6774c84cd452f1aaefc5c5a.tar.xz
Enables the buildin Caps ServerReleaseNotes
~ Dedicated to Quill Littlefeather ~ Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs165
1 files changed, 165 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs
new file mode 100644
index 0000000..500798d
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.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.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenMetaverse.StructuredData;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using Caps = OpenSim.Framework.Capabilities.Caps;
41
42namespace OpenSim.Region.ClientStack.LindenCaps
43{
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ServerReleaseNotesModule")]
45 class ServerReleaseNotesModule : ISharedRegionModule
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private Dictionary<string, Scene> m_Scenes = new Dictionary<string, Scene>();
50 private Scene m_scene;
51
52 private bool m_enabled;
53 private static string m_ServerReleaseNotesURL = string.Empty;
54
55 public string Name { get { return "ServerReleaseNotesModule"; } }
56
57 public Type ReplaceableInterface
58 {
59 get { return null; }
60 }
61
62 public void AddRegion(Scene scene)
63 {
64 if (!m_enabled)
65 return;
66
67 m_scene = scene;
68
69 if (m_enabled == true)
70 {
71 if (m_Scenes.ContainsKey(scene.RegionInfo.RegionName))
72 {
73 lock (m_Scenes)
74 {
75 m_Scenes[scene.RegionInfo.RegionName] = scene;
76 }
77 }
78 }
79 else
80 {
81 lock (m_Scenes)
82 {
83 m_Scenes.Add(scene.RegionInfo.RegionName, scene);
84 }
85 }
86
87 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
88 }
89
90 public void Close() { }
91
92 public void Initialise(IConfigSource source)
93 {
94 IConfig ServerReleaseNote = source.Configs["ServerReleaseNotes"];
95 m_ServerReleaseNotesURL = ServerReleaseNote.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
96 m_enabled = ServerReleaseNote.GetBoolean("enabled", false);
97
98 if (m_ServerReleaseNotesURL == null)
99 {
100 m_enabled = false;
101 m_log.Info("[ServerReleaseNotes]: No Configuration Found, module has been disabled");
102 return;
103 }
104
105 if (m_enabled == false)
106 {
107 m_log.InfoFormat("[ServerReleaseNotes]: Module is disabled");
108 }
109 }
110
111 public void PostInitialise() { }
112
113 public void RegionLoaded(Scene scene)
114 {
115 if (!m_enabled)
116 {
117 return;
118 }
119 }
120
121 public void RemoveRegion(Scene scene)
122 {
123 if (!m_enabled)
124 {
125 return;
126 }
127 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
128 }
129
130 public void RegisterCaps(UUID agentID, Caps caps)
131 {
132 UUID capId = UUID.Random();
133
134 IRequestHandler ServerReleaseNote
135 = new RestHTTPHandler(
136 "GET", "/CAPS/" + capId + "/",
137 delegate (Hashtable request)
138 {
139 return ProcessServerReleaseNotes(request, agentID, capId);
140 });
141 caps.RegisterHandler("ServerReleaseNotes", ServerReleaseNote);
142 }
143
144 private Hashtable ProcessServerReleaseNotes(Hashtable request, UUID agentID, UUID capUUID)
145 {
146 Hashtable responsedata = new Hashtable();
147 responsedata["int_response_code"] = 301;
148 responsedata["str_redirect_location"] = m_ServerReleaseNotesURL;
149 responsedata["content_type"] = "text/plain";
150 responsedata["keepalive"] = false;
151
152 OSDMap osd = new OSDMap();
153 osd.Add("ServerReleaseNotes", new OSDString(GetServerReleaseNotesURL()));
154
155 string response = OSDParser.SerializeLLSDXmlString(osd);
156 responsedata["str_response_string"] = response;
157 return responsedata;
158 }
159
160 private string GetServerReleaseNotesURL()
161 {
162 return "Set the ReleaseNotesUrl in OpenSim.ini under [ServerReleaseNotesURL] section";
163 }
164 }
165}