aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs108
1 files changed, 35 insertions, 73 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs
index 500798d..380bae5 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs
@@ -25,6 +25,8 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28// Dedicated to Quill Littlefeather
29
28using System; 30using System;
29using System.Collections; 31using System.Collections;
30using System.Collections.Generic; 32using System.Collections.Generic;
@@ -46,11 +48,8 @@ namespace OpenSim.Region.ClientStack.LindenCaps
46 { 48 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 50
49 private Dictionary<string, Scene> m_Scenes = new Dictionary<string, Scene>();
50 private Scene m_scene;
51
52 private bool m_enabled; 51 private bool m_enabled;
53 private static string m_ServerReleaseNotesURL = string.Empty; 52 private string m_ServerReleaseNotesURL;
54 53
55 public string Name { get { return "ServerReleaseNotesModule"; } } 54 public string Name { get { return "ServerReleaseNotesModule"; } }
56 55
@@ -59,107 +58,70 @@ namespace OpenSim.Region.ClientStack.LindenCaps
59 get { return null; } 58 get { return null; }
60 } 59 }
61 60
62 public void AddRegion(Scene scene) 61 public void Initialise(IConfigSource source)
63 { 62 {
64 if (!m_enabled) 63 m_enabled = false; // whatever
64 IConfig config = source.Configs["ClientStack.LindenCaps"];
65 if (config == null)
65 return; 66 return;
66 67
67 m_scene = scene; 68 string capURL = config.GetString("Cap_ServerReleaseNotes", string.Empty);
68 69 if (string.IsNullOrEmpty(capURL) || capURL != "localhost")
69 if (m_enabled == true) 70 return;
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 71
90 public void Close() { } 72 config = source.Configs["ServerReleaseNotes"];
73 if (config == null)
74 return;
91 75
92 public void Initialise(IConfigSource source) 76 m_ServerReleaseNotesURL = config.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
93 { 77 if (string.IsNullOrEmpty(m_ServerReleaseNotesURL))
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; 78 return;
103 }
104 79
105 if (m_enabled == false) 80 m_enabled = true;
106 {
107 m_log.InfoFormat("[ServerReleaseNotes]: Module is disabled");
108 }
109 } 81 }
110 82
111 public void PostInitialise() { } 83 public void AddRegion(Scene scene)
112
113 public void RegionLoaded(Scene scene)
114 { 84 {
115 if (!m_enabled) 85 if (!m_enabled)
116 {
117 return; 86 return;
118 } 87
88 scene.EventManager.OnRegisterCaps += RegisterCaps;
119 } 89 }
120 90
91 public void RegionLoaded(Scene scene) { }
92
121 public void RemoveRegion(Scene scene) 93 public void RemoveRegion(Scene scene)
122 { 94 {
123 if (!m_enabled) 95 if (!m_enabled)
124 {
125 return; 96 return;
126 } 97
127 m_scene.EventManager.OnRegisterCaps -= RegisterCaps; 98 scene.EventManager.OnRegisterCaps -= RegisterCaps;
128 } 99 }
129 100
101 public void PostInitialise() { }
102
103 public void Close() { }
104
130 public void RegisterCaps(UUID agentID, Caps caps) 105 public void RegisterCaps(UUID agentID, Caps caps)
131 { 106 {
132 UUID capId = UUID.Random(); 107 string capUrl = "/CAPS/" + UUID.Random() + "/";
133 108
134 IRequestHandler ServerReleaseNote 109 IRequestHandler ServerReleaseNote = new RestHTTPHandler("GET", capUrl,
135 = new RestHTTPHandler( 110 delegate (Hashtable request)
136 "GET", "/CAPS/" + capId + "/", 111 {
137 delegate (Hashtable request) 112 return ProcessServerReleaseNotes(request, agentID);
138 { 113 });
139 return ProcessServerReleaseNotes(request, agentID, capId);
140 });
141 caps.RegisterHandler("ServerReleaseNotes", ServerReleaseNote); 114 caps.RegisterHandler("ServerReleaseNotes", ServerReleaseNote);
142 } 115 }
143 116
144 private Hashtable ProcessServerReleaseNotes(Hashtable request, UUID agentID, UUID capUUID) 117 private Hashtable ProcessServerReleaseNotes(Hashtable request, UUID agentID)
145 { 118 {
146 Hashtable responsedata = new Hashtable(); 119 Hashtable responsedata = new Hashtable();
147 responsedata["int_response_code"] = 301; 120 responsedata["int_response_code"] = 301;
148 responsedata["str_redirect_location"] = m_ServerReleaseNotesURL; 121 responsedata["str_redirect_location"] = m_ServerReleaseNotesURL;
149 responsedata["content_type"] = "text/plain"; 122 responsedata["content_type"] = "text/plain";
150 responsedata["keepalive"] = false;
151
152 OSDMap osd = new OSDMap();
153 osd.Add("ServerReleaseNotes", new OSDString(GetServerReleaseNotesURL()));
154 123
155 string response = OSDParser.SerializeLLSDXmlString(osd);
156 responsedata["str_response_string"] = response;
157 return responsedata; 124 return responsedata;
158 } 125 }
159
160 private string GetServerReleaseNotesURL()
161 {
162 return "Set the ReleaseNotesUrl in OpenSim.ini under [ServerReleaseNotesURL] section";
163 }
164 } 126 }
165} 127}