diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Grid/GridExtraFeaturesHandlers.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridExtraFeaturesHandlers.cs | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Grid/GridExtraFeaturesHandlers.cs b/OpenSim/Server/Handlers/Grid/GridExtraFeaturesHandlers.cs new file mode 100644 index 0000000..8b9890c --- /dev/null +++ b/OpenSim/Server/Handlers/Grid/GridExtraFeaturesHandlers.cs | |||
@@ -0,0 +1,118 @@ | |||
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.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Security; | ||
34 | using System.Text; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using Nwc.XmlRpc; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | |||
42 | |||
43 | namespace OpenSim.Server.Handlers.Grid | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// Grid extra features handlers. | ||
47 | /// <para>Allows grid level configuration of OpenSimExtra items.</para> | ||
48 | /// <para>Option to control region override of these settings.</para> | ||
49 | /// </summary> | ||
50 | public class GridExtraFeaturesHandlers | ||
51 | { | ||
52 | private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | private Hashtable m_ExtraFeatures = new Hashtable(); | ||
54 | private bool m_AllowRegionOverride = true; | ||
55 | |||
56 | public GridExtraFeaturesHandlers(IConfigSource configSource) | ||
57 | { | ||
58 | try | ||
59 | { | ||
60 | IConfig featuresCfg = configSource.Configs["GridExtraFeatures"]; | ||
61 | |||
62 | foreach( string key in featuresCfg.GetKeys()) | ||
63 | { | ||
64 | if(key != "AllowRegionOverride") | ||
65 | { | ||
66 | string value = featuresCfg.GetString(key); | ||
67 | |||
68 | // map the value to the viewer supported extra features | ||
69 | // add additional ones here as support is added in the viewer | ||
70 | // and place the configuration option in [GridExtraFeatures]. | ||
71 | switch(key) | ||
72 | { | ||
73 | case "SearchServerURI": | ||
74 | m_ExtraFeatures["search-server-url"] = value; | ||
75 | break; | ||
76 | case "MapImageServerURI": | ||
77 | m_ExtraFeatures["map-server-url"] = value; | ||
78 | break; | ||
79 | case "DestinationGuideURI": | ||
80 | m_ExtraFeatures["destination-guide-url"] = value; | ||
81 | break; | ||
82 | case "ExportSupported": | ||
83 | m_ExtraFeatures["ExportSupported"] = value; | ||
84 | break; | ||
85 | default: | ||
86 | m_Log.InfoFormat("{0} not yet supported."); | ||
87 | break; | ||
88 | } | ||
89 | } | ||
90 | else | ||
91 | m_AllowRegionOverride = featuresCfg.GetBoolean(key); | ||
92 | } | ||
93 | } | ||
94 | catch (Exception) | ||
95 | { | ||
96 | m_Log.Warn("[GRID EXTRA FEATURES SERVICE]: Cannot get grid features from config source, allowing region override"); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public bool JsonGetGridFeaturesMethod(OSDMap json, ref JsonRpcResponse response) | ||
101 | { | ||
102 | OSDMap features = new OSDMap(); | ||
103 | OSDMap json_map = new OSDMap(); | ||
104 | |||
105 | foreach (string key in m_ExtraFeatures.Keys) | ||
106 | { | ||
107 | features[key] = OSD.FromString(m_ExtraFeatures[key].ToString()); | ||
108 | } | ||
109 | |||
110 | json_map["extra_features"] = features; | ||
111 | json_map["region_override"] = m_AllowRegionOverride.ToString(); | ||
112 | |||
113 | response.Result = json_map; | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | } | ||
118 | } \ No newline at end of file | ||