diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Server/Base/CommandManager.cs | 353 | ||||
-rw-r--r-- | OpenSim/Server/Base/PluginManager.cs | 555 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServerUtils.cs | 144 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 8 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Base/ServerConnector.cs | 65 | ||||
-rw-r--r-- | OpenSim/Server/ServerMain.cs | 11 |
6 files changed, 1136 insertions, 0 deletions
diff --git a/OpenSim/Server/Base/CommandManager.cs b/OpenSim/Server/Base/CommandManager.cs new file mode 100644 index 0000000..45652b3 --- /dev/null +++ b/OpenSim/Server/Base/CommandManager.cs | |||
@@ -0,0 +1,353 @@ | |||
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 | |||
29 | using System; | ||
30 | using System.Text; | ||
31 | using System.Linq; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using System.Collections.ObjectModel; | ||
35 | using Mono.Addins; | ||
36 | using Mono.Addins.Setup; | ||
37 | using Mono.Addins.Description; | ||
38 | using OpenSim.Framework; | ||
39 | |||
40 | namespace OpenSim.Server.Base | ||
41 | { | ||
42 | public class CommandManager | ||
43 | { | ||
44 | protected AddinRegistry PluginRegistry; | ||
45 | protected PluginManager PluginManager; | ||
46 | |||
47 | public CommandManager(AddinRegistry registry) | ||
48 | { | ||
49 | PluginRegistry = registry; | ||
50 | PluginManager = new PluginManager(PluginRegistry); | ||
51 | AddManagementCommands(); | ||
52 | } | ||
53 | |||
54 | private void AddManagementCommands() | ||
55 | { | ||
56 | // add plugin | ||
57 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
58 | "plugin add", "plugin add \"plugin index\"", | ||
59 | "Install plugin from repository.", | ||
60 | HandleConsoleInstallPlugin); | ||
61 | |||
62 | // remove plugin | ||
63 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
64 | "plugin remove", "plugin remove \"plugin index\"", | ||
65 | "Remove plugin from repository", | ||
66 | HandleConsoleUnInstallPlugin); | ||
67 | |||
68 | // list installed plugins | ||
69 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
70 | "plugin list installed", | ||
71 | "plugin list installed","List install plugins", | ||
72 | HandleConsoleListInstalledPlugin); | ||
73 | |||
74 | // list plugins available from registered repositories | ||
75 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
76 | "plugin list available", | ||
77 | "plugin list available","List available plugins", | ||
78 | HandleConsoleListAvailablePlugin); | ||
79 | // List available updates | ||
80 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
81 | "plugin updates", "plugin updates","List availble updates", | ||
82 | HandleConsoleListUpdates); | ||
83 | |||
84 | // Update plugin | ||
85 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
86 | "plugin update", "plugin update \"plugin index\"","Update the plugin", | ||
87 | HandleConsoleUpdatePlugin); | ||
88 | |||
89 | // Add repository | ||
90 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
91 | "repo add", "repo add \"url\"","Add repository", | ||
92 | HandleConsoleAddRepo); | ||
93 | |||
94 | // Refresh repo | ||
95 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
96 | "repo refresh", "repo refresh \"url\"", "Sync with a registered repository", | ||
97 | HandleConsoleGetRepo); | ||
98 | |||
99 | // Remove repository from registry | ||
100 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
101 | "repo remove", | ||
102 | "repo remove \"[url | index]\"", | ||
103 | "Remove repository from registry", | ||
104 | HandleConsoleRemoveRepo); | ||
105 | |||
106 | // Enable repo | ||
107 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
108 | "repo enable", "repo enable \"[url | index]\"", | ||
109 | "Enable registered repository", | ||
110 | HandleConsoleEnableRepo); | ||
111 | |||
112 | // Disable repo | ||
113 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
114 | "repo disable", "repo disable\"[url | index]\"", | ||
115 | "Disable registered repository", | ||
116 | HandleConsoleDisableRepo); | ||
117 | |||
118 | // List registered repositories | ||
119 | MainConsole.Instance.Commands.AddCommand("Repository", true, | ||
120 | "repo list", "repo list", | ||
121 | "List registered repositories", | ||
122 | HandleConsoleListRepos); | ||
123 | |||
124 | // * | ||
125 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
126 | "plugin info", "plugin info \"plugin index\"","Show detailed information for plugin", | ||
127 | HandleConsoleShowAddinInfo); | ||
128 | |||
129 | // Plugin disable | ||
130 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
131 | "plugin disable", "plugin disable \"plugin index\"", | ||
132 | "Disable a plugin", | ||
133 | HandleConsoleDisablePlugin); | ||
134 | |||
135 | // Enable plugin | ||
136 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | ||
137 | "plugin enable", "plugin enable \"plugin index\"", | ||
138 | "Enable the selected plugin plugin", | ||
139 | HandleConsoleEnablePlugin); | ||
140 | } | ||
141 | |||
142 | #region console handlers | ||
143 | // Handle our console commands | ||
144 | // | ||
145 | // Install plugin from registered repository | ||
146 | /// <summary> | ||
147 | /// Handles the console install plugin command. Attempts to install the selected plugin | ||
148 | /// and | ||
149 | /// </summary> | ||
150 | /// <param name='module'> | ||
151 | /// Module. | ||
152 | /// </param> | ||
153 | /// <param name='cmd'> | ||
154 | /// Cmd. | ||
155 | /// </param> | ||
156 | private void HandleConsoleInstallPlugin(string module, string[] cmd) | ||
157 | { | ||
158 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
159 | |||
160 | if (cmd.Length == 3) | ||
161 | { | ||
162 | int ndx = Convert.ToInt16(cmd[2]); | ||
163 | if (PluginManager.InstallPlugin(ndx, out result) == true) | ||
164 | { | ||
165 | ArrayList s = new ArrayList(); | ||
166 | s.AddRange(result.Keys); | ||
167 | s.Sort(); | ||
168 | |||
169 | var list = result.Keys.ToList(); | ||
170 | list.Sort(); | ||
171 | foreach (var k in list) | ||
172 | { | ||
173 | Dictionary<string, object> plugin = (Dictionary<string, object>)result[k]; | ||
174 | bool enabled = (bool)plugin["enabled"]; | ||
175 | MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}", | ||
176 | k, | ||
177 | enabled == true ? "[ ]" : "[X]", | ||
178 | plugin["name"], plugin["version"]); | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | return; | ||
183 | } | ||
184 | |||
185 | // Remove installed plugin | ||
186 | private void HandleConsoleUnInstallPlugin(string module, string[] cmd) | ||
187 | { | ||
188 | if (cmd.Length == 3) | ||
189 | { | ||
190 | int ndx = Convert.ToInt16(cmd[2]); | ||
191 | PluginManager.UnInstall(ndx); | ||
192 | } | ||
193 | return; | ||
194 | } | ||
195 | |||
196 | // List installed plugins | ||
197 | private void HandleConsoleListInstalledPlugin(string module, string[] cmd) | ||
198 | { | ||
199 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
200 | PluginManager.ListInstalledAddins(out result); | ||
201 | |||
202 | ArrayList s = new ArrayList(); | ||
203 | s.AddRange(result.Keys); | ||
204 | s.Sort(); | ||
205 | |||
206 | var list = result.Keys.ToList(); | ||
207 | list.Sort(); | ||
208 | foreach (var k in list) | ||
209 | { | ||
210 | Dictionary<string, object> plugin = (Dictionary<string, object>)result[k]; | ||
211 | bool enabled = (bool)plugin["enabled"]; | ||
212 | MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}", | ||
213 | k, | ||
214 | enabled == true ? "[ ]" : "[X]", | ||
215 | plugin["name"], plugin["version"]); | ||
216 | } | ||
217 | return; | ||
218 | } | ||
219 | |||
220 | // List available plugins on registered repositories | ||
221 | private void HandleConsoleListAvailablePlugin(string module, string[] cmd) | ||
222 | { | ||
223 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
224 | PluginManager.ListAvailable(out result); | ||
225 | |||
226 | var list = result.Keys.ToList(); | ||
227 | list.Sort(); | ||
228 | foreach (var k in list) | ||
229 | { | ||
230 | // name, version, repository | ||
231 | Dictionary<string, object> plugin = (Dictionary<string, object>)result[k]; | ||
232 | MainConsole.Instance.OutputFormat("{0}) {1} rev. {2} {3}", | ||
233 | k, | ||
234 | plugin["name"], | ||
235 | plugin["version"], | ||
236 | plugin["repository"]); | ||
237 | } | ||
238 | return; | ||
239 | } | ||
240 | |||
241 | // List available updates **not ready | ||
242 | private void HandleConsoleListUpdates(string module, string[] cmd) | ||
243 | { | ||
244 | PluginManager.ListUpdates(); | ||
245 | return; | ||
246 | } | ||
247 | |||
248 | // Update plugin **not ready | ||
249 | private void HandleConsoleUpdatePlugin(string module, string[] cmd) | ||
250 | { | ||
251 | MainConsole.Instance.Output(PluginManager.Update()); | ||
252 | return; | ||
253 | } | ||
254 | |||
255 | // Register repository | ||
256 | private void HandleConsoleAddRepo(string module, string[] cmd) | ||
257 | { | ||
258 | if ( cmd.Length == 3) | ||
259 | { | ||
260 | PluginManager.AddRepository(cmd[2]); | ||
261 | } | ||
262 | return; | ||
263 | } | ||
264 | |||
265 | // Get repository status **not working | ||
266 | private void HandleConsoleGetRepo(string module, string[] cmd) | ||
267 | { | ||
268 | PluginManager.GetRepository(); | ||
269 | return; | ||
270 | } | ||
271 | |||
272 | // Remove registered repository | ||
273 | private void HandleConsoleRemoveRepo(string module, string[] cmd) | ||
274 | { | ||
275 | if (cmd.Length == 3) | ||
276 | PluginManager.RemoveRepository(cmd); | ||
277 | return; | ||
278 | } | ||
279 | |||
280 | // Enable repository | ||
281 | private void HandleConsoleEnableRepo(string module, string[] cmd) | ||
282 | { | ||
283 | PluginManager.EnableRepository(cmd); | ||
284 | return; | ||
285 | } | ||
286 | |||
287 | // Disable repository | ||
288 | private void HandleConsoleDisableRepo(string module, string[] cmd) | ||
289 | { | ||
290 | PluginManager.DisableRepository(cmd); | ||
291 | return; | ||
292 | } | ||
293 | |||
294 | // List repositories | ||
295 | private void HandleConsoleListRepos(string module, string[] cmd) | ||
296 | { | ||
297 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
298 | PluginManager.ListRepositories(out result); | ||
299 | |||
300 | var list = result.Keys.ToList(); | ||
301 | list.Sort(); | ||
302 | foreach (var k in list) | ||
303 | { | ||
304 | Dictionary<string, object> repo = (Dictionary<string, object>)result[k]; | ||
305 | bool enabled = (bool)repo["enabled"]; | ||
306 | MainConsole.Instance.OutputFormat("{0}) {1} {2}", | ||
307 | k, | ||
308 | enabled == true ? "[ ]" : "[X]", | ||
309 | repo["name"], repo["url"]); | ||
310 | } | ||
311 | |||
312 | return; | ||
313 | } | ||
314 | |||
315 | // Show description information | ||
316 | private void HandleConsoleShowAddinInfo(string module, string[] cmd) | ||
317 | { | ||
318 | if (cmd.Length >= 3) | ||
319 | { | ||
320 | |||
321 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
322 | |||
323 | int ndx = Convert.ToInt16(cmd[2]); | ||
324 | PluginManager.AddinInfo(ndx, out result); | ||
325 | |||
326 | MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\nFile: {2}\nAuthor: {3}\nCategory: {4}\nDesc: {5}", | ||
327 | result["name"], | ||
328 | result["url"], | ||
329 | result["file_name"], | ||
330 | result["author"], | ||
331 | result["category"], | ||
332 | result["description"]); | ||
333 | |||
334 | return; | ||
335 | } | ||
336 | } | ||
337 | |||
338 | // Disable plugin | ||
339 | private void HandleConsoleDisablePlugin(string module, string[] cmd) | ||
340 | { | ||
341 | PluginManager.DisablePlugin(cmd); | ||
342 | return; | ||
343 | } | ||
344 | |||
345 | // Enable plugin | ||
346 | private void HandleConsoleEnablePlugin(string module, string[] cmd) | ||
347 | { | ||
348 | PluginManager.EnablePlugin(cmd); | ||
349 | return; | ||
350 | } | ||
351 | #endregion | ||
352 | } | ||
353 | } \ No newline at end of file | ||
diff --git a/OpenSim/Server/Base/PluginManager.cs b/OpenSim/Server/Base/PluginManager.cs new file mode 100644 index 0000000..6248e74 --- /dev/null +++ b/OpenSim/Server/Base/PluginManager.cs | |||
@@ -0,0 +1,555 @@ | |||
1 | |||
2 | /* | ||
3 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
4 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions are met: | ||
8 | * * Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the OpenSimulator Project nor the | ||
14 | * names of its contributors may be used to endorse or promote products | ||
15 | * derived from this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
20 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | */ | ||
28 | |||
29 | |||
30 | using System; | ||
31 | using System.Text; | ||
32 | using System.Linq; | ||
33 | using System.Collections; | ||
34 | using System.Collections.Generic; | ||
35 | using System.Collections.ObjectModel; | ||
36 | using Mono.Addins; | ||
37 | using Mono.Addins.Setup; | ||
38 | using Mono.Addins.Description; | ||
39 | using OpenSim.Framework; | ||
40 | |||
41 | namespace OpenSim.Server.Base | ||
42 | { | ||
43 | public class PluginManager : SetupService | ||
44 | { | ||
45 | protected AddinRegistry PluginRegistry; | ||
46 | |||
47 | internal PluginManager(AddinRegistry registry): base (registry) | ||
48 | { | ||
49 | PluginRegistry = registry; | ||
50 | |||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// Installs the plugin. | ||
55 | /// </summary> | ||
56 | /// <returns> | ||
57 | /// The plugin. | ||
58 | /// </returns> | ||
59 | /// <param name='args'> | ||
60 | /// Arguments. | ||
61 | /// </param> | ||
62 | public bool InstallPlugin(int ndx, out Dictionary<string, object> result) | ||
63 | { | ||
64 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
65 | |||
66 | PackageCollection pack = new PackageCollection(); | ||
67 | PackageCollection toUninstall; | ||
68 | DependencyCollection unresolved; | ||
69 | |||
70 | IProgressStatus ps = new ConsoleProgressStatus(false); | ||
71 | |||
72 | AddinRepositoryEntry[] available = GetSortedAvailbleAddins(); | ||
73 | |||
74 | if (ndx > (available.Length - 1)) | ||
75 | { | ||
76 | MainConsole.Instance.Output("Selection out of range"); | ||
77 | result = res; | ||
78 | return false; | ||
79 | } | ||
80 | |||
81 | AddinRepositoryEntry aentry = available[ndx]; | ||
82 | |||
83 | Package p = Package.FromRepository(aentry); | ||
84 | pack.Add(p); | ||
85 | |||
86 | ResolveDependencies(ps, pack, out toUninstall, out unresolved); | ||
87 | |||
88 | // Attempt to install the plugin disabled | ||
89 | if (Install(ps, pack) == true) | ||
90 | { | ||
91 | PluginRegistry.Update(ps); | ||
92 | Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id); | ||
93 | PluginRegistry.DisableAddin(addin.Id); | ||
94 | addin.Enabled = false; | ||
95 | |||
96 | MainConsole.Instance.Output("Installation Success"); | ||
97 | ListInstalledAddins(out res); | ||
98 | result = res; | ||
99 | return true; | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | MainConsole.Instance.Output("Installation Failed"); | ||
104 | result = res; | ||
105 | return false; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | // Remove plugin | ||
110 | /// <summary> | ||
111 | /// Uns the install. | ||
112 | /// </summary> | ||
113 | /// <param name='args'> | ||
114 | /// Arguments. | ||
115 | /// </param> | ||
116 | public void UnInstall(int ndx) | ||
117 | { | ||
118 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
119 | |||
120 | if (ndx > (addins.Length -1)) | ||
121 | { | ||
122 | MainConsole.Instance.Output("Selection out of range"); | ||
123 | return; | ||
124 | } | ||
125 | |||
126 | Addin addin = addins[ndx]; | ||
127 | MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id); | ||
128 | AddinManager.Registry.DisableAddin(addin.Id); | ||
129 | addin.Enabled = false; | ||
130 | IProgressStatus ps = new ConsoleProgressStatus(false); | ||
131 | Uninstall(ps, addin.Id); | ||
132 | MainConsole.Instance.Output("Uninstall Success - restart to complete operation"); | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Checks the installed. | ||
138 | /// </summary> | ||
139 | /// <returns> | ||
140 | /// The installed. | ||
141 | /// </returns> | ||
142 | public string CheckInstalled() | ||
143 | { | ||
144 | return "CheckInstall"; | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// Lists the installed addins. | ||
149 | /// </summary> | ||
150 | /// <param name='result'> | ||
151 | /// Result. | ||
152 | /// </param> | ||
153 | public void ListInstalledAddins(out Dictionary<string, object> result) | ||
154 | { | ||
155 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
156 | |||
157 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
158 | if(addins.Count() < 1) | ||
159 | { | ||
160 | MainConsole.Instance.Output("Error!"); | ||
161 | } | ||
162 | int count = 0; | ||
163 | foreach (Addin addin in addins) | ||
164 | { | ||
165 | Dictionary<string, object> r = new Dictionary<string, object>(); | ||
166 | r["enabled"] = addin.Enabled == true ? true : false; | ||
167 | r["name"] = addin.LocalId; | ||
168 | r["version"] = addin.Version; | ||
169 | |||
170 | res.Add(count.ToString(), r); | ||
171 | |||
172 | count++; | ||
173 | } | ||
174 | result = res; | ||
175 | return; | ||
176 | } | ||
177 | |||
178 | // List compatible plugins in registered repositories | ||
179 | /// <summary> | ||
180 | /// Lists the available. | ||
181 | /// </summary> | ||
182 | /// <param name='result'> | ||
183 | /// Result. | ||
184 | /// </param> | ||
185 | public void ListAvailable(out Dictionary<string, object> result) | ||
186 | { | ||
187 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
188 | |||
189 | AddinRepositoryEntry[] addins = GetSortedAvailbleAddins(); | ||
190 | |||
191 | int count = 0; | ||
192 | foreach (AddinRepositoryEntry addin in addins) | ||
193 | { | ||
194 | Dictionary<string, object> r = new Dictionary<string, object>(); | ||
195 | r["name"] = addin.Addin.Name; | ||
196 | r["version"] = addin.Addin.Version; | ||
197 | r["repository"] = addin.RepositoryName; | ||
198 | |||
199 | res.Add(count.ToString(), r); | ||
200 | count++; | ||
201 | } | ||
202 | result = res; | ||
203 | return; | ||
204 | } | ||
205 | |||
206 | // List available updates ** 1 | ||
207 | /// <summary> | ||
208 | /// Lists the updates. | ||
209 | /// </summary> | ||
210 | public void ListUpdates() | ||
211 | { | ||
212 | IProgressStatus ps = new ConsoleProgressStatus(true); | ||
213 | Console.WriteLine ("Looking for updates..."); | ||
214 | Repositories.UpdateAllRepositories (ps); | ||
215 | Console.WriteLine ("Available add-in updates:"); | ||
216 | bool found = false; | ||
217 | AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates(); | ||
218 | |||
219 | foreach (AddinRepositoryEntry entry in entries) | ||
220 | { | ||
221 | Console.WriteLine(String.Format("{0}",entry.Addin.Id)); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | // Sync to repositories | ||
226 | /// <summary> | ||
227 | /// Update this instance. | ||
228 | /// </summary> | ||
229 | public string Update() | ||
230 | { | ||
231 | IProgressStatus ps = new ConsoleProgressStatus(true); | ||
232 | Repositories.UpdateAllRepositories(ps); | ||
233 | return "Update"; | ||
234 | } | ||
235 | |||
236 | // Register a repository | ||
237 | /// <summary> | ||
238 | /// Register a repository with our server. | ||
239 | /// </summary> | ||
240 | /// <returns> | ||
241 | /// result of the action | ||
242 | /// </returns> | ||
243 | /// <param name='repo'> | ||
244 | /// The URL of the repository we want to add | ||
245 | /// </param> | ||
246 | public bool AddRepository(string repo) | ||
247 | { | ||
248 | Repositories.RegisterRepository(null, repo, true); | ||
249 | return true; | ||
250 | } | ||
251 | |||
252 | /// <summary> | ||
253 | /// Gets the repository. | ||
254 | /// </summary> | ||
255 | public void GetRepository() | ||
256 | { | ||
257 | Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false)); | ||
258 | } | ||
259 | |||
260 | // Remove a repository from the list | ||
261 | /// <summary> | ||
262 | /// Removes the repository. | ||
263 | /// </summary> | ||
264 | /// <param name='args'> | ||
265 | /// Arguments. | ||
266 | /// </param> | ||
267 | public void RemoveRepository(string[] args) | ||
268 | { | ||
269 | AddinRepository[] reps = Repositories.GetRepositories(); | ||
270 | Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); | ||
271 | if (reps.Length == 0) | ||
272 | { | ||
273 | MainConsole.Instance.Output("No repositories have been registered."); | ||
274 | return; | ||
275 | } | ||
276 | |||
277 | int n = Convert.ToInt16(args[2]); | ||
278 | if (n > (reps.Length -1)) | ||
279 | { | ||
280 | MainConsole.Instance.Output("Selection out of range"); | ||
281 | return; | ||
282 | } | ||
283 | |||
284 | AddinRepository rep = reps[n]; | ||
285 | Repositories.RemoveRepository(rep.Url); | ||
286 | return; | ||
287 | } | ||
288 | |||
289 | // Enable repository | ||
290 | /// <summary> | ||
291 | /// Enables the repository. | ||
292 | /// </summary> | ||
293 | /// <param name='args'> | ||
294 | /// Arguments. | ||
295 | /// </param> | ||
296 | public void EnableRepository(string[] args) | ||
297 | { | ||
298 | AddinRepository[] reps = Repositories.GetRepositories(); | ||
299 | Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); | ||
300 | if (reps.Length == 0) | ||
301 | { | ||
302 | MainConsole.Instance.Output("No repositories have been registered."); | ||
303 | return; | ||
304 | } | ||
305 | |||
306 | int n = Convert.ToInt16(args[2]); | ||
307 | if (n > (reps.Length -1)) | ||
308 | { | ||
309 | MainConsole.Instance.Output("Selection out of range"); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | AddinRepository rep = reps[n]; | ||
314 | Repositories.SetRepositoryEnabled(rep.Url, true); | ||
315 | return; | ||
316 | } | ||
317 | |||
318 | // Disable a repository | ||
319 | /// <summary> | ||
320 | /// Disables the repository. | ||
321 | /// </summary> | ||
322 | /// <param name='args'> | ||
323 | /// Arguments. | ||
324 | /// </param> | ||
325 | public void DisableRepository(string[] args) | ||
326 | { | ||
327 | AddinRepository[] reps = Repositories.GetRepositories(); | ||
328 | Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); | ||
329 | if (reps.Length == 0) | ||
330 | { | ||
331 | MainConsole.Instance.Output("No repositories have been registered."); | ||
332 | return; | ||
333 | } | ||
334 | |||
335 | int n = Convert.ToInt16(args[2]); | ||
336 | if (n > (reps.Length -1)) | ||
337 | { | ||
338 | MainConsole.Instance.Output("Selection out of range"); | ||
339 | return; | ||
340 | } | ||
341 | |||
342 | AddinRepository rep = reps[n]; | ||
343 | Repositories.SetRepositoryEnabled(rep.Url, false); | ||
344 | return; | ||
345 | } | ||
346 | |||
347 | // List registered repositories | ||
348 | /// <summary> | ||
349 | /// Lists the repositories. | ||
350 | /// </summary> | ||
351 | /// <param name='result'> | ||
352 | /// Result. | ||
353 | /// </param> | ||
354 | public void ListRepositories(out Dictionary<string, object> result) | ||
355 | { | ||
356 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
357 | result = res; | ||
358 | |||
359 | AddinRepository[] reps = GetSortedAddinRepo(); | ||
360 | if (reps.Length == 0) | ||
361 | { | ||
362 | MainConsole.Instance.Output("No repositories have been registered."); | ||
363 | return; | ||
364 | } | ||
365 | |||
366 | int count = 0; | ||
367 | foreach (AddinRepository rep in reps) | ||
368 | { | ||
369 | Dictionary<string, object> r = new Dictionary<string, object>(); | ||
370 | r["enabled"] = rep.Enabled == true ? true : false; | ||
371 | r["name"] = rep.Name; | ||
372 | r["url"] = rep.Url; | ||
373 | |||
374 | res.Add(count.ToString(), r); | ||
375 | count++; | ||
376 | } | ||
377 | return; | ||
378 | } | ||
379 | |||
380 | /// <summary> | ||
381 | /// Updates the registry. | ||
382 | /// </summary> | ||
383 | public void UpdateRegistry() | ||
384 | { | ||
385 | PluginRegistry.Update(); | ||
386 | } | ||
387 | |||
388 | // Show plugin info | ||
389 | /// <summary> | ||
390 | /// Addins the info. | ||
391 | /// </summary> | ||
392 | /// <returns> | ||
393 | /// The info. | ||
394 | /// </returns> | ||
395 | /// <param name='args'> | ||
396 | /// Arguments. | ||
397 | /// </param> | ||
398 | public bool AddinInfo(int ndx, out Dictionary<string, object> result) | ||
399 | { | ||
400 | Dictionary<string, object> res = new Dictionary<string, object>(); | ||
401 | result = res; | ||
402 | |||
403 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
404 | |||
405 | if (ndx > (addins.Length - 1)) | ||
406 | { | ||
407 | MainConsole.Instance.Output("Selection out of range"); | ||
408 | return false; | ||
409 | } | ||
410 | // author category description | ||
411 | Addin addin = addins[ndx]; | ||
412 | |||
413 | res["author"] = addin.Description.Author; | ||
414 | res["category"] = addin.Description.Category; | ||
415 | res["description"] = addin.Description.Description; | ||
416 | res["name"] = addin.Name; | ||
417 | res["url"] = addin.Description.Url; | ||
418 | res["file_name"] = addin.Description.FileName; | ||
419 | |||
420 | result = res; | ||
421 | return true; | ||
422 | } | ||
423 | |||
424 | // Disable a plugin | ||
425 | /// <summary> | ||
426 | /// Disables the plugin. | ||
427 | /// </summary> | ||
428 | /// <param name='args'> | ||
429 | /// Arguments. | ||
430 | /// </param> | ||
431 | public void DisablePlugin(string[] args) | ||
432 | { | ||
433 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
434 | |||
435 | int n = Convert.ToInt16(args[2]); | ||
436 | if (n > (addins.Length -1)) | ||
437 | { | ||
438 | MainConsole.Instance.Output("Selection out of range"); | ||
439 | return; | ||
440 | } | ||
441 | |||
442 | Addin addin = addins[n]; | ||
443 | AddinManager.Registry.DisableAddin(addin.Id); | ||
444 | addin.Enabled = false; | ||
445 | return; | ||
446 | } | ||
447 | |||
448 | // Enable plugin | ||
449 | /// <summary> | ||
450 | /// Enables the plugin. | ||
451 | /// </summary> | ||
452 | /// <param name='args'> | ||
453 | /// Arguments. | ||
454 | /// </param> | ||
455 | public void EnablePlugin(string[] args) | ||
456 | { | ||
457 | Addin[] addins = GetSortedAddinList("RobustPlugin"); | ||
458 | |||
459 | int n = Convert.ToInt16(args[2]); | ||
460 | if (n > (addins.Length -1)) | ||
461 | { | ||
462 | MainConsole.Instance.Output("Selection out of range"); | ||
463 | return; | ||
464 | } | ||
465 | |||
466 | Addin addin = addins[n]; | ||
467 | |||
468 | addin.Enabled = true; | ||
469 | AddinManager.Registry.EnableAddin(addin.Id); | ||
470 | // AddinManager.Registry.Update(); | ||
471 | if(PluginRegistry.IsAddinEnabled(addin.Id)) | ||
472 | { | ||
473 | ConsoleProgressStatus ps = new ConsoleProgressStatus(false); | ||
474 | if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id)) | ||
475 | { | ||
476 | AddinManager.Registry.Rebuild(ps); | ||
477 | AddinManager.AddinEngine.LoadAddin(ps, addin.Id); | ||
478 | } | ||
479 | } | ||
480 | else | ||
481 | { | ||
482 | MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name); | ||
483 | } | ||
484 | return; | ||
485 | } | ||
486 | |||
487 | |||
488 | |||
489 | #region Util | ||
490 | private void Testing() | ||
491 | { | ||
492 | Addin[] list = Registry.GetAddins(); | ||
493 | |||
494 | var addins = list.Where( a => a.Description.Category == "RobustPlugin"); | ||
495 | |||
496 | foreach (Addin addin in addins) | ||
497 | { | ||
498 | MainConsole.Instance.OutputFormat("Addin {0}", addin.Name); | ||
499 | } | ||
500 | } | ||
501 | |||
502 | // These will let us deal with numbered lists instead | ||
503 | // of needing to type in the full ids | ||
504 | private AddinRepositoryEntry[] GetSortedAvailbleAddins() | ||
505 | { | ||
506 | ArrayList list = new ArrayList(); | ||
507 | list.AddRange(Repositories.GetAvailableAddins()); | ||
508 | |||
509 | AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[]; | ||
510 | |||
511 | Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id)); | ||
512 | |||
513 | return addins; | ||
514 | } | ||
515 | |||
516 | private AddinRepository[] GetSortedAddinRepo() | ||
517 | { | ||
518 | ArrayList list = new ArrayList(); | ||
519 | list.AddRange(Repositories.GetRepositories()); | ||
520 | |||
521 | AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[]; | ||
522 | Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name)); | ||
523 | |||
524 | return repos; | ||
525 | } | ||
526 | |||
527 | private Addin[] GetSortedAddinList(string category) | ||
528 | { | ||
529 | |||
530 | ArrayList xlist = new ArrayList(); | ||
531 | ArrayList list = new ArrayList(); | ||
532 | try | ||
533 | { | ||
534 | list.AddRange(PluginRegistry.GetAddins()); | ||
535 | } | ||
536 | catch(Exception e) | ||
537 | { | ||
538 | Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[]; | ||
539 | return x; | ||
540 | } | ||
541 | |||
542 | foreach (Addin addin in list) | ||
543 | { | ||
544 | if (addin.Description.Category == category) | ||
545 | xlist.Add(addin); | ||
546 | } | ||
547 | |||
548 | Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[]; | ||
549 | Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id)); | ||
550 | |||
551 | return addins; | ||
552 | } | ||
553 | #endregion Util | ||
554 | } | ||
555 | } \ No newline at end of file | ||
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 42c82cf..6c6af62 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -33,11 +33,118 @@ using System.Xml.Serialization; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Collections.Generic; | 34 | using System.Collections.Generic; |
35 | using log4net; | 35 | using log4net; |
36 | using Nini.Config; | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using Mono.Addins; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Framework.Servers; | ||
38 | 42 | ||
43 | |||
44 | [assembly:AddinRoot("Robust", "0.1")] | ||
39 | namespace OpenSim.Server.Base | 45 | namespace OpenSim.Server.Base |
40 | { | 46 | { |
47 | [TypeExtensionPoint(Path="/Robust/Connector", Name="RobustConnector")] | ||
48 | public interface IRobustConnector | ||
49 | { | ||
50 | string ConfigName | ||
51 | { | ||
52 | get; | ||
53 | } | ||
54 | |||
55 | bool Enabled | ||
56 | { | ||
57 | get; | ||
58 | } | ||
59 | |||
60 | string PluginPath | ||
61 | { | ||
62 | get; | ||
63 | set; | ||
64 | } | ||
65 | |||
66 | uint Configure(IConfigSource config); | ||
67 | void Initialize(IHttpServer server); | ||
68 | } | ||
69 | |||
70 | public class PluginLoader | ||
71 | { | ||
72 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
73 | |||
74 | public AddinRegistry Registry | ||
75 | { | ||
76 | get; | ||
77 | private set; | ||
78 | } | ||
79 | |||
80 | public IConfigSource Config | ||
81 | { | ||
82 | get; | ||
83 | private set; | ||
84 | } | ||
85 | |||
86 | public PluginLoader(IConfigSource config, string registryPath) | ||
87 | { | ||
88 | Config = config; | ||
89 | |||
90 | Registry = new AddinRegistry(registryPath, "."); | ||
91 | AddinManager.Initialize(registryPath); | ||
92 | AddinManager.Registry.Update(); | ||
93 | CommandManager commandmanager = new CommandManager(Registry); | ||
94 | AddinManager.AddExtensionNodeHandler("/Robust/Connector", OnExtensionChanged); | ||
95 | } | ||
96 | |||
97 | private void OnExtensionChanged(object s, ExtensionNodeEventArgs args) | ||
98 | { | ||
99 | IRobustConnector connector = (IRobustConnector)args.ExtensionObject; | ||
100 | |||
101 | Addin a = Registry.GetAddin(args.ExtensionNode.Addin.Id); | ||
102 | m_log.InfoFormat("[SERVER]: Extension Change: {0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); | ||
103 | |||
104 | switch(args.Change) | ||
105 | { | ||
106 | case ExtensionChange.Add: | ||
107 | connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); | ||
108 | LoadPlugin(connector); | ||
109 | break; | ||
110 | case ExtensionChange.Remove: | ||
111 | UnloadPlugin(connector); | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | private void LoadPlugin(IRobustConnector connector) | ||
117 | { | ||
118 | IHttpServer server = null; | ||
119 | uint port = connector.Configure(Config); | ||
120 | |||
121 | if(connector.Enabled) | ||
122 | { | ||
123 | server = GetServer(connector, port); | ||
124 | m_log.InfoFormat("[SERVER]: Path is {0}", connector.PluginPath); | ||
125 | connector.Initialize(server); | ||
126 | } | ||
127 | else | ||
128 | m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName); | ||
129 | } | ||
130 | |||
131 | private void UnloadPlugin(IRobustConnector connector) | ||
132 | { | ||
133 | } | ||
134 | |||
135 | private IHttpServer GetServer(IRobustConnector connector, uint port) | ||
136 | { | ||
137 | IHttpServer server; | ||
138 | |||
139 | if(port != 0) | ||
140 | server = MainServer.GetHttpServer(port); | ||
141 | else | ||
142 | server = MainServer.Instance; | ||
143 | |||
144 | return server; | ||
145 | } | ||
146 | } | ||
147 | |||
41 | public static class ServerUtils | 148 | public static class ServerUtils |
42 | { | 149 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 150 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -333,5 +440,42 @@ namespace OpenSim.Server.Base | |||
333 | 440 | ||
334 | return ret; | 441 | return ret; |
335 | } | 442 | } |
443 | |||
444 | public static IConfig GetConfig(string configFile, string configName) | ||
445 | { | ||
446 | IConfig config; | ||
447 | |||
448 | if (File.Exists(configFile)) | ||
449 | { | ||
450 | IConfigSource configsource = new IniConfigSource(configFile); | ||
451 | config = configsource.Configs[configName]; | ||
452 | } | ||
453 | else | ||
454 | config = null; | ||
455 | |||
456 | return config; | ||
457 | } | ||
458 | |||
459 | public static IConfigSource LoadInitialConfig(string url) | ||
460 | { | ||
461 | IConfigSource source = new XmlConfigSource(); | ||
462 | m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url); | ||
463 | |||
464 | // The ini file path is a http URI | ||
465 | // Try to read it | ||
466 | try | ||
467 | { | ||
468 | XmlReader r = XmlReader.Create(url); | ||
469 | IConfigSource cs = new XmlConfigSource(r); | ||
470 | source.Merge(cs); | ||
471 | } | ||
472 | catch (Exception e) | ||
473 | { | ||
474 | m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url); | ||
475 | Environment.Exit(1); | ||
476 | } | ||
477 | |||
478 | return source; | ||
479 | } | ||
336 | } | 480 | } |
337 | } | 481 | } |
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 0cff6ed..2f12288 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -64,6 +64,12 @@ namespace OpenSim.Server.Base | |||
64 | get { return m_Config; } | 64 | get { return m_Config; } |
65 | } | 65 | } |
66 | 66 | ||
67 | public string ConfigDirectory | ||
68 | { | ||
69 | get; | ||
70 | private set; | ||
71 | } | ||
72 | |||
67 | // Run flag | 73 | // Run flag |
68 | // | 74 | // |
69 | private bool m_Running = true; | 75 | private bool m_Running = true; |
@@ -153,6 +159,8 @@ namespace OpenSim.Server.Base | |||
153 | startupConfig = m_Config.Configs["Startup"]; | 159 | startupConfig = m_Config.Configs["Startup"]; |
154 | } | 160 | } |
155 | 161 | ||
162 | ConfigDirectory = startupConfig.GetString("ConfigDirectory", "."); | ||
163 | |||
156 | prompt = startupConfig.GetString("Prompt", prompt); | 164 | prompt = startupConfig.GetString("Prompt", prompt); |
157 | 165 | ||
158 | // Allow derived classes to load config before the console is | 166 | // Allow derived classes to load config before the console is |
diff --git a/OpenSim/Server/Handlers/Base/ServerConnector.cs b/OpenSim/Server/Handlers/Base/ServerConnector.cs index 71876da..067fd2a 100644 --- a/OpenSim/Server/Handlers/Base/ServerConnector.cs +++ b/OpenSim/Server/Handlers/Base/ServerConnector.cs | |||
@@ -39,8 +39,73 @@ namespace OpenSim.Server.Handlers.Base | |||
39 | 39 | ||
40 | public class ServiceConnector : IServiceConnector | 40 | public class ServiceConnector : IServiceConnector |
41 | { | 41 | { |
42 | public virtual string ConfigURL | ||
43 | { | ||
44 | get; | ||
45 | protected set; | ||
46 | } | ||
47 | |||
48 | public virtual string ConfigName | ||
49 | { | ||
50 | get; | ||
51 | protected set; | ||
52 | } | ||
53 | |||
54 | public virtual string ConfigFile | ||
55 | { | ||
56 | get; | ||
57 | protected set; | ||
58 | } | ||
59 | |||
60 | public virtual IConfigSource Config | ||
61 | { | ||
62 | get; | ||
63 | protected set; | ||
64 | } | ||
65 | |||
66 | public ServiceConnector() | ||
67 | { | ||
68 | } | ||
69 | |||
42 | public ServiceConnector(IConfigSource config, IHttpServer server, string configName) | 70 | public ServiceConnector(IConfigSource config, IHttpServer server, string configName) |
43 | { | 71 | { |
44 | } | 72 | } |
73 | |||
74 | // We call this from our plugin module to get our configuration | ||
75 | public IConfig GetConfig() | ||
76 | { | ||
77 | IConfig config = null; | ||
78 | config = ServerUtils.GetConfig(ConfigFile, ConfigName); | ||
79 | |||
80 | // Our file is not here? We can get one to bootstrap our plugin module | ||
81 | if ( config == null ) | ||
82 | { | ||
83 | IConfigSource remotesource = GetConfigSource(); | ||
84 | |||
85 | if (remotesource != null) | ||
86 | { | ||
87 | IniConfigSource initialconfig = new IniConfigSource(); | ||
88 | initialconfig.Merge (remotesource); | ||
89 | initialconfig.Save(ConfigFile); | ||
90 | } | ||
91 | |||
92 | config = remotesource.Configs[ConfigName]; | ||
93 | } | ||
94 | |||
95 | return config; | ||
96 | } | ||
97 | |||
98 | // We get our remote initial configuration for bootstrapping | ||
99 | private IConfigSource GetConfigSource() | ||
100 | { | ||
101 | IConfigSource source = null; | ||
102 | |||
103 | source = ServerUtils.LoadInitialConfig(ConfigURL); | ||
104 | |||
105 | if (source == null) | ||
106 | System.Console.WriteLine(String.Format ("Config Url: {0} Not found!", ConfigURL)); | ||
107 | |||
108 | return source; | ||
109 | } | ||
45 | } | 110 | } |
46 | } | 111 | } |
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs index 45c13fb..be12f8a 100644 --- a/OpenSim/Server/ServerMain.cs +++ b/OpenSim/Server/ServerMain.cs | |||
@@ -34,6 +34,7 @@ using OpenSim.Framework.Servers; | |||
34 | using OpenSim.Framework.Servers.HttpServer; | 34 | using OpenSim.Framework.Servers.HttpServer; |
35 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
36 | using OpenSim.Server.Handlers.Base; | 36 | using OpenSim.Server.Handlers.Base; |
37 | using Mono.Addins; | ||
37 | 38 | ||
38 | namespace OpenSim.Server | 39 | namespace OpenSim.Server |
39 | { | 40 | { |
@@ -48,9 +49,13 @@ namespace OpenSim.Server | |||
48 | protected static List<IServiceConnector> m_ServiceConnectors = | 49 | protected static List<IServiceConnector> m_ServiceConnectors = |
49 | new List<IServiceConnector>(); | 50 | new List<IServiceConnector>(); |
50 | 51 | ||
52 | protected static PluginLoader loader; | ||
53 | |||
51 | public static int Main(string[] args) | 54 | public static int Main(string[] args) |
52 | { | 55 | { |
53 | m_Server = new HttpServerBase("R.O.B.U.S.T.", args); | 56 | m_Server = new HttpServerBase("R.O.B.U.S.T.", args); |
57 | |||
58 | string registryLocation; | ||
54 | 59 | ||
55 | IConfig serverConfig = m_Server.Config.Configs["Startup"]; | 60 | IConfig serverConfig = m_Server.Config.Configs["Startup"]; |
56 | if (serverConfig == null) | 61 | if (serverConfig == null) |
@@ -60,6 +65,8 @@ namespace OpenSim.Server | |||
60 | } | 65 | } |
61 | 66 | ||
62 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); | 67 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); |
68 | |||
69 | registryLocation = serverConfig.GetString("RegistryLocation","."); | ||
63 | 70 | ||
64 | IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; | 71 | IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; |
65 | if (servicesConfig != null) | 72 | if (servicesConfig != null) |
@@ -79,6 +86,7 @@ namespace OpenSim.Server | |||
79 | } | 86 | } |
80 | 87 | ||
81 | string[] conns = connList.Split(new char[] {',', ' ', '\n', '\r', '\t'}); | 88 | string[] conns = connList.Split(new char[] {',', ' ', '\n', '\r', '\t'}); |
89 | >>>>>>> master | ||
82 | 90 | ||
83 | // int i = 0; | 91 | // int i = 0; |
84 | foreach (string c in conns) | 92 | foreach (string c in conns) |
@@ -141,6 +149,9 @@ namespace OpenSim.Server | |||
141 | m_log.InfoFormat("[SERVER]: Failed to load {0}", conn); | 149 | m_log.InfoFormat("[SERVER]: Failed to load {0}", conn); |
142 | } | 150 | } |
143 | } | 151 | } |
152 | |||
153 | loader = new PluginLoader(m_Server.Config, registryLocation); | ||
154 | |||
144 | int res = m_Server.Run(); | 155 | int res = m_Server.Run(); |
145 | 156 | ||
146 | Environment.Exit(res); | 157 | Environment.Exit(res); |