several changes to last patch

0.9.1.0-post-fixes
UbitUmarov 2018-12-16 20:18:26 +00:00
parent ed039a5fe0
commit 921364e877
2 changed files with 43 additions and 84 deletions

View File

@ -25,6 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
// Dedicated to Quill Littlefeather
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -46,11 +48,8 @@ namespace OpenSim.Region.ClientStack.LindenCaps
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<string, Scene> m_Scenes = new Dictionary<string, Scene>();
private Scene m_scene;
private bool m_enabled; private bool m_enabled;
private static string m_ServerReleaseNotesURL = string.Empty; private string m_ServerReleaseNotesURL;
public string Name { get { return "ServerReleaseNotesModule"; } } public string Name { get { return "ServerReleaseNotesModule"; } }
@ -59,107 +58,70 @@ namespace OpenSim.Region.ClientStack.LindenCaps
get { return null; } get { return null; }
} }
public void Initialise(IConfigSource source)
{
m_enabled = false; // whatever
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
return;
string capURL = config.GetString("Cap_ServerReleaseNotes", string.Empty);
if (string.IsNullOrEmpty(capURL) || capURL != "localhost")
return;
config = source.Configs["ServerReleaseNotes"];
if (config == null)
return;
m_ServerReleaseNotesURL = config.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
if (string.IsNullOrEmpty(m_ServerReleaseNotesURL))
return;
m_enabled = true;
}
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
if (!m_enabled) if (!m_enabled)
return; return;
m_scene = scene; scene.EventManager.OnRegisterCaps += RegisterCaps;
if (m_enabled == true)
{
if (m_Scenes.ContainsKey(scene.RegionInfo.RegionName))
{
lock (m_Scenes)
{
m_Scenes[scene.RegionInfo.RegionName] = scene;
}
}
}
else
{
lock (m_Scenes)
{
m_Scenes.Add(scene.RegionInfo.RegionName, scene);
}
}
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
} }
public void Close() { } public void RegionLoaded(Scene scene) { }
public void Initialise(IConfigSource source)
{
IConfig ServerReleaseNote = source.Configs["ServerReleaseNotes"];
m_ServerReleaseNotesURL = ServerReleaseNote.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
m_enabled = ServerReleaseNote.GetBoolean("enabled", false);
if (m_ServerReleaseNotesURL == null)
{
m_enabled = false;
m_log.Info("[ServerReleaseNotes]: No Configuration Found, module has been disabled");
return;
}
if (m_enabled == false)
{
m_log.InfoFormat("[ServerReleaseNotes]: Module is disabled");
}
}
public void PostInitialise() { }
public void RegionLoaded(Scene scene)
{
if (!m_enabled)
{
return;
}
}
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{ {
if (!m_enabled) if (!m_enabled)
{
return; return;
}
m_scene.EventManager.OnRegisterCaps -= RegisterCaps; scene.EventManager.OnRegisterCaps -= RegisterCaps;
} }
public void PostInitialise() { }
public void Close() { }
public void RegisterCaps(UUID agentID, Caps caps) public void RegisterCaps(UUID agentID, Caps caps)
{ {
UUID capId = UUID.Random(); string capUrl = "/CAPS/" + UUID.Random() + "/";
IRequestHandler ServerReleaseNote IRequestHandler ServerReleaseNote = new RestHTTPHandler("GET", capUrl,
= new RestHTTPHandler( delegate (Hashtable request)
"GET", "/CAPS/" + capId + "/", {
delegate (Hashtable request) return ProcessServerReleaseNotes(request, agentID);
{ });
return ProcessServerReleaseNotes(request, agentID, capId);
});
caps.RegisterHandler("ServerReleaseNotes", ServerReleaseNote); caps.RegisterHandler("ServerReleaseNotes", ServerReleaseNote);
} }
private Hashtable ProcessServerReleaseNotes(Hashtable request, UUID agentID, UUID capUUID) private Hashtable ProcessServerReleaseNotes(Hashtable request, UUID agentID)
{ {
Hashtable responsedata = new Hashtable(); Hashtable responsedata = new Hashtable();
responsedata["int_response_code"] = 301; responsedata["int_response_code"] = 301;
responsedata["str_redirect_location"] = m_ServerReleaseNotesURL; responsedata["str_redirect_location"] = m_ServerReleaseNotesURL;
responsedata["content_type"] = "text/plain"; responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
OSDMap osd = new OSDMap();
osd.Add("ServerReleaseNotes", new OSDString(GetServerReleaseNotesURL()));
string response = OSDParser.SerializeLLSDXmlString(osd);
responsedata["str_response_string"] = response;
return responsedata; return responsedata;
} }
private string GetServerReleaseNotesURL()
{
return "Set the ReleaseNotesUrl in OpenSim.ini under [ServerReleaseNotesURL] section";
}
} }
} }

View File

@ -816,7 +816,7 @@
Cap_SendPostcard = "" Cap_SendPostcard = ""
Cap_SendUserReport = "" Cap_SendUserReport = ""
Cap_SendUserReportWithScreenshot = "" Cap_SendUserReportWithScreenshot = ""
Cap_ServerReleaseNotes = "" Cap_ServerReleaseNotes = "localhost"
Cap_SimConsole = "" Cap_SimConsole = ""
Cap_SimulatorFeatures = "" Cap_SimulatorFeatures = ""
Cap_SetDisplayName = "" Cap_SetDisplayName = ""
@ -2270,11 +2270,8 @@
DwellModule = DefaultDwellModule DwellModule = DefaultDwellModule
[ServerReleaseNotes] [ServerReleaseNotes]
;; This enabled the build in Server Release Notes ;; Comment to disable
Enabled = false ServerReleaseNotesURL = http://opensimulator.org/wiki/0.9.0.1_Release
;; Set this to the URL of your Release Notes
;; {ServerReleaseNotesURL} {} {Set this to the URL of your Release Notes} {}
ServerReleaseNotesURL = http://localhost/ReleaseNotes.html
[Modules] [Modules]
Include-modules = "addon-modules/*/config/*.ini" Include-modules = "addon-modules/*/config/*.ini"