diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/GridInfo')
-rw-r--r-- | OpenSim/ApplicationPlugins/GridInfo/GridInfoPlugin.cs | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/GridInfo/GridInfoPlugin.cs b/OpenSim/ApplicationPlugins/GridInfo/GridInfoPlugin.cs new file mode 100644 index 0000000..d8575d0b --- /dev/null +++ b/OpenSim/ApplicationPlugins/GridInfo/GridInfoPlugin.cs | |||
@@ -0,0 +1,121 @@ | |||
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 OpenSim 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.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Timers; | ||
34 | using libsecondlife; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using Nwc.XmlRpc; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Servers; | ||
40 | using OpenSim.Region.Environment.Modules.World.Terrain; | ||
41 | using OpenSim.Region.Environment.Scenes; | ||
42 | |||
43 | namespace OpenSim.ApplicationPlugins.GridInfo | ||
44 | { | ||
45 | public class GridInfoPlugin : IApplicationPlugin | ||
46 | { | ||
47 | private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private OpenSimBase _app; | ||
50 | private BaseHttpServer _httpd; | ||
51 | |||
52 | private string _name = "GridInfoPlugin"; | ||
53 | private string _version = "0.1"; | ||
54 | private Hashtable _info = new Hashtable(); | ||
55 | |||
56 | public string Version { get { return _version; } } | ||
57 | public string Name { get { return _name; } } | ||
58 | |||
59 | public void Initialise() | ||
60 | { | ||
61 | _log.Info("[GridInfo]: " + Name + " cannot be default-initialized!"); | ||
62 | throw new PluginNotInitialisedException (Name); | ||
63 | } | ||
64 | |||
65 | public void Initialise(OpenSimBase openSim) | ||
66 | { | ||
67 | try | ||
68 | { | ||
69 | _log.Info("[GridInfo]: Grid Info Plugin Enabled"); | ||
70 | |||
71 | _app = openSim; | ||
72 | _httpd = openSim.HttpServer; | ||
73 | |||
74 | IConfig startupConfig = _app.ConfigSource.Source.Configs["Startup"]; | ||
75 | if (!startupConfig.GetBoolean("gridmode", false)) | ||
76 | { | ||
77 | _info["mode"] = "standalone"; | ||
78 | } | ||
79 | else | ||
80 | { | ||
81 | _info["mode"] = "grid"; | ||
82 | } | ||
83 | _info["platform"] = "OpenSim"; | ||
84 | |||
85 | IConfig gridInfoConfig = _app.ConfigSource.Source.Configs["GridInfo"]; | ||
86 | foreach (string k in gridInfoConfig.GetKeys()) | ||
87 | { | ||
88 | _info[k] = gridInfoConfig.GetString(k); | ||
89 | } | ||
90 | |||
91 | _httpd.AddXmlRPCHandler("get_grid_info", XmlRpcGridInfoMethod); | ||
92 | } | ||
93 | catch (NullReferenceException) | ||
94 | { | ||
95 | // Ignore. | ||
96 | } | ||
97 | } | ||
98 | |||
99 | |||
100 | |||
101 | public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) | ||
102 | { | ||
103 | XmlRpcResponse response = new XmlRpcResponse(); | ||
104 | Hashtable responseData = new Hashtable(); | ||
105 | |||
106 | _log.Info("[GridInfo]: Request for grid info"); | ||
107 | |||
108 | foreach (string k in _info.Keys) | ||
109 | { | ||
110 | responseData[k] = _info[k]; | ||
111 | } | ||
112 | response.Value = responseData; | ||
113 | |||
114 | return response; | ||
115 | } | ||
116 | |||
117 | public void Dispose() | ||
118 | { | ||
119 | } | ||
120 | } | ||
121 | } | ||