aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorDiva Canto2015-09-05 17:37:07 -0700
committerDiva Canto2015-09-05 17:37:07 -0700
commit3cf07564b6d4e72f6193f5affdcb0dc14624991a (patch)
tree26ce3f3327e27a454df0f4fa501d14e3aac957f9 /OpenSim/Framework
parentDeleted unused file. (diff)
downloadopensim-SC-3cf07564b6d4e72f6193f5affdcb0dc14624991a.zip
opensim-SC-3cf07564b6d4e72f6193f5affdcb0dc14624991a.tar.gz
opensim-SC-3cf07564b6d4e72f6193f5affdcb0dc14624991a.tar.bz2
opensim-SC-3cf07564b6d4e72f6193f5affdcb0dc14624991a.tar.xz
Moved the two region loaders into the RegionLoaderPlugin dll, therefore eliminating 2 top-level dlls that didn't make much sense.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/IRegionLoader.cs37
-rw-r--r--OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs116
-rw-r--r--OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs147
3 files changed, 0 insertions, 300 deletions
diff --git a/OpenSim/Framework/IRegionLoader.cs b/OpenSim/Framework/IRegionLoader.cs
deleted file mode 100644
index c566fc7..0000000
--- a/OpenSim/Framework/IRegionLoader.cs
+++ /dev/null
@@ -1,37 +0,0 @@
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 Nini.Config;
29
30namespace OpenSim.Framework
31{
32 public interface IRegionLoader
33 {
34 void SetIniConfigSource(IConfigSource configSource);
35 RegionInfo[] LoadRegions();
36 }
37} \ No newline at end of file
diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
deleted file mode 100644
index 8332c14..0000000
--- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
+++ /dev/null
@@ -1,116 +0,0 @@
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 log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34
35namespace OpenSim.Framework.RegionLoader.Filesystem
36{
37 public class RegionLoaderFileSystem : IRegionLoader
38 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
41 private IConfigSource m_configSource;
42
43 public void SetIniConfigSource(IConfigSource configSource)
44 {
45 m_configSource = configSource;
46 }
47
48 public RegionInfo[] LoadRegions()
49 {
50 string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
51 bool allowRegionless = false;
52
53 try
54 {
55 IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"];
56 regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim();
57 allowRegionless = startupConfig.GetBoolean("allow_regionless", false);
58 }
59 catch (Exception)
60 {
61 // No INI setting recorded.
62 }
63
64 if (!Directory.Exists(regionConfigPath))
65 {
66 Directory.CreateDirectory(regionConfigPath);
67 }
68
69 string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
70 string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
71
72 // Create an empty Regions.ini if there are no existing config files.
73 if (!allowRegionless && configFiles.Length == 0 && iniFiles.Length == 0)
74 {
75 new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource);
76 iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
77 }
78
79 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath);
80
81 List<RegionInfo> regionInfos = new List<RegionInfo>();
82
83 int i = 0;
84 foreach (string file in iniFiles)
85 {
86 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
87
88 IConfigSource source = new IniConfigSource(file);
89
90 foreach (IConfig config in source.Configs)
91 {
92 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name);
93 regionInfos.Add(regionInfo);
94
95 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName);
96
97 i++;
98 }
99 }
100
101 foreach (string file in configFiles)
102 {
103 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
104
105 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource);
106 regionInfos.Add(regionInfo);
107
108 m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName);
109
110 i++;
111 }
112
113 return regionInfos.ToArray();
114 }
115 }
116} \ No newline at end of file
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
deleted file mode 100644
index f60bb12..0000000
--- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
+++ /dev/null
@@ -1,147 +0,0 @@
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.IO;
30using System.Net;
31using System.Reflection;
32using System.Xml;
33using log4net;
34using Nini.Config;
35
36namespace OpenSim.Framework.RegionLoader.Web
37{
38 public class RegionLoaderWebServer : IRegionLoader
39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 private IConfigSource m_configSource;
43
44 public void SetIniConfigSource(IConfigSource configSource)
45 {
46 m_configSource = configSource;
47 }
48
49 public RegionInfo[] LoadRegions()
50 {
51 if (m_configSource == null)
52 {
53 m_log.Error("[WEBLOADER]: Unable to load configuration source!");
54 return null;
55 }
56 else
57 {
58 IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"];
59 string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim();
60 bool allowRegionless = startupConfig.GetBoolean("allow_regionless", false);
61
62 if (url == String.Empty)
63 {
64 m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty.");
65 return null;
66 }
67 else
68 {
69 RegionInfo[] regionInfos = new RegionInfo[] {};
70 int regionCount = 0;
71 HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
72 webRequest.Timeout = 30000; //30 Second Timeout
73 m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url);
74
75 try
76 {
77 string xmlSource = String.Empty;
78
79 using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse())
80 {
81 m_log.Debug("[WEBLOADER]: Downloading region information...");
82
83 using (Stream s = webResponse.GetResponseStream())
84 {
85 using (StreamReader reader = new StreamReader(s))
86 {
87 string tempStr = reader.ReadLine();
88 while (tempStr != null)
89 {
90 xmlSource = xmlSource + tempStr;
91 tempStr = reader.ReadLine();
92 }
93 }
94 }
95 }
96
97 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
98 xmlSource.Length);
99 XmlDocument xmlDoc = new XmlDocument();
100 xmlDoc.LoadXml(xmlSource);
101 if (xmlDoc.FirstChild.Name == "Nini")
102 {
103 regionCount = xmlDoc.FirstChild.ChildNodes.Count;
104
105 if (regionCount > 0)
106 {
107 regionInfos = new RegionInfo[regionCount];
108 int i;
109 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
110 {
111 m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
112 regionInfos[i] =
113 new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource);
114 }
115 }
116 }
117 }
118 catch (WebException ex)
119 {
120 using (HttpWebResponse response = (HttpWebResponse)ex.Response)
121 {
122 if (response.StatusCode == HttpStatusCode.NotFound)
123 {
124 if (!allowRegionless)
125 throw ex;
126 }
127 else
128 {
129 throw ex;
130 }
131 }
132 }
133
134 if (regionCount > 0 | allowRegionless)
135 {
136 return regionInfos;
137 }
138 else
139 {
140 m_log.Error("[WEBLOADER]: No region configs were available.");
141 return null;
142 }
143 }
144 }
145 }
146 }
147}