aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Base/CommandManager.cs10
-rw-r--r--OpenSim/Server/Base/PluginManager.cs557
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs5
-rw-r--r--OpenSim/Server/Handlers/Base/ServerConnector.cs8
4 files changed, 16 insertions, 564 deletions
diff --git a/OpenSim/Server/Base/CommandManager.cs b/OpenSim/Server/Base/CommandManager.cs
index 45652b3..88aac00 100644
--- a/OpenSim/Server/Base/CommandManager.cs
+++ b/OpenSim/Server/Base/CommandManager.cs
@@ -33,15 +33,21 @@ using System.Collections;
33using System.Collections.Generic; 33using System.Collections.Generic;
34using System.Collections.ObjectModel; 34using System.Collections.ObjectModel;
35using Mono.Addins; 35using Mono.Addins;
36using Mono.Addins.Setup; 36// using Mono.Addins.Setup;
37using Mono.Addins.Description; 37using Mono.Addins.Description;
38using OpenSim.Framework; 38using OpenSim.Framework;
39 39
40namespace OpenSim.Server.Base 40namespace OpenSim.Server.Base
41{ 41{
42 /// <summary>
43 /// Command manager -
44 /// Wrapper for OpenSim.Framework.PluginManager to allow
45 /// us to add commands to the console to perform operations
46 /// on our repos and plugins
47 /// </summary>
42 public class CommandManager 48 public class CommandManager
43 { 49 {
44 protected AddinRegistry PluginRegistry; 50 public AddinRegistry PluginRegistry;
45 protected PluginManager PluginManager; 51 protected PluginManager PluginManager;
46 52
47 public CommandManager(AddinRegistry registry) 53 public CommandManager(AddinRegistry registry)
diff --git a/OpenSim/Server/Base/PluginManager.cs b/OpenSim/Server/Base/PluginManager.cs
deleted file mode 100644
index d2cf668..0000000
--- a/OpenSim/Server/Base/PluginManager.cs
+++ /dev/null
@@ -1,557 +0,0 @@
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
30using System;
31using System.Text;
32using System.Linq;
33using System.Collections;
34using System.Collections.Generic;
35using System.Collections.ObjectModel;
36using Mono.Addins;
37using Mono.Addins.Setup;
38using Mono.Addins.Description;
39using OpenSim.Framework;
40
41namespace 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 PluginRegistry.Rebuild(null);
250
251 return true;
252 }
253
254 /// <summary>
255 /// Gets the repository.
256 /// </summary>
257 public void GetRepository()
258 {
259 Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false));
260 }
261
262 // Remove a repository from the list
263 /// <summary>
264 /// Removes the repository.
265 /// </summary>
266 /// <param name='args'>
267 /// Arguments.
268 /// </param>
269 public void RemoveRepository(string[] args)
270 {
271 AddinRepository[] reps = Repositories.GetRepositories();
272 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
273 if (reps.Length == 0)
274 {
275 MainConsole.Instance.Output("No repositories have been registered.");
276 return;
277 }
278
279 int n = Convert.ToInt16(args[2]);
280 if (n > (reps.Length -1))
281 {
282 MainConsole.Instance.Output("Selection out of range");
283 return;
284 }
285
286 AddinRepository rep = reps[n];
287 Repositories.RemoveRepository(rep.Url);
288 return;
289 }
290
291 // Enable repository
292 /// <summary>
293 /// Enables the repository.
294 /// </summary>
295 /// <param name='args'>
296 /// Arguments.
297 /// </param>
298 public void EnableRepository(string[] args)
299 {
300 AddinRepository[] reps = Repositories.GetRepositories();
301 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
302 if (reps.Length == 0)
303 {
304 MainConsole.Instance.Output("No repositories have been registered.");
305 return;
306 }
307
308 int n = Convert.ToInt16(args[2]);
309 if (n > (reps.Length -1))
310 {
311 MainConsole.Instance.Output("Selection out of range");
312 return;
313 }
314
315 AddinRepository rep = reps[n];
316 Repositories.SetRepositoryEnabled(rep.Url, true);
317 return;
318 }
319
320 // Disable a repository
321 /// <summary>
322 /// Disables the repository.
323 /// </summary>
324 /// <param name='args'>
325 /// Arguments.
326 /// </param>
327 public void DisableRepository(string[] args)
328 {
329 AddinRepository[] reps = Repositories.GetRepositories();
330 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
331 if (reps.Length == 0)
332 {
333 MainConsole.Instance.Output("No repositories have been registered.");
334 return;
335 }
336
337 int n = Convert.ToInt16(args[2]);
338 if (n > (reps.Length -1))
339 {
340 MainConsole.Instance.Output("Selection out of range");
341 return;
342 }
343
344 AddinRepository rep = reps[n];
345 Repositories.SetRepositoryEnabled(rep.Url, false);
346 return;
347 }
348
349 // List registered repositories
350 /// <summary>
351 /// Lists the repositories.
352 /// </summary>
353 /// <param name='result'>
354 /// Result.
355 /// </param>
356 public void ListRepositories(out Dictionary<string, object> result)
357 {
358 Dictionary<string, object> res = new Dictionary<string, object>();
359 result = res;
360
361 AddinRepository[] reps = GetSortedAddinRepo();
362 if (reps.Length == 0)
363 {
364 MainConsole.Instance.Output("No repositories have been registered.");
365 return;
366 }
367
368 int count = 0;
369 foreach (AddinRepository rep in reps)
370 {
371 Dictionary<string, object> r = new Dictionary<string, object>();
372 r["enabled"] = rep.Enabled == true ? true : false;
373 r["name"] = rep.Name;
374 r["url"] = rep.Url;
375
376 res.Add(count.ToString(), r);
377 count++;
378 }
379 return;
380 }
381
382 /// <summary>
383 /// Updates the registry.
384 /// </summary>
385 public void UpdateRegistry()
386 {
387 PluginRegistry.Update();
388 }
389
390 // Show plugin info
391 /// <summary>
392 /// Addins the info.
393 /// </summary>
394 /// <returns>
395 /// The info.
396 /// </returns>
397 /// <param name='args'>
398 /// Arguments.
399 /// </param>
400 public bool AddinInfo(int ndx, out Dictionary<string, object> result)
401 {
402 Dictionary<string, object> res = new Dictionary<string, object>();
403 result = res;
404
405 Addin[] addins = GetSortedAddinList("RobustPlugin");
406
407 if (ndx > (addins.Length - 1))
408 {
409 MainConsole.Instance.Output("Selection out of range");
410 return false;
411 }
412 // author category description
413 Addin addin = addins[ndx];
414
415 res["author"] = addin.Description.Author;
416 res["category"] = addin.Description.Category;
417 res["description"] = addin.Description.Description;
418 res["name"] = addin.Name;
419 res["url"] = addin.Description.Url;
420 res["file_name"] = addin.Description.FileName;
421
422 result = res;
423 return true;
424 }
425
426 // Disable a plugin
427 /// <summary>
428 /// Disables the plugin.
429 /// </summary>
430 /// <param name='args'>
431 /// Arguments.
432 /// </param>
433 public void DisablePlugin(string[] args)
434 {
435 Addin[] addins = GetSortedAddinList("RobustPlugin");
436
437 int n = Convert.ToInt16(args[2]);
438 if (n > (addins.Length -1))
439 {
440 MainConsole.Instance.Output("Selection out of range");
441 return;
442 }
443
444 Addin addin = addins[n];
445 AddinManager.Registry.DisableAddin(addin.Id);
446 addin.Enabled = false;
447 return;
448 }
449
450 // Enable plugin
451 /// <summary>
452 /// Enables the plugin.
453 /// </summary>
454 /// <param name='args'>
455 /// Arguments.
456 /// </param>
457 public void EnablePlugin(string[] args)
458 {
459 Addin[] addins = GetSortedAddinList("RobustPlugin");
460
461 int n = Convert.ToInt16(args[2]);
462 if (n > (addins.Length -1))
463 {
464 MainConsole.Instance.Output("Selection out of range");
465 return;
466 }
467
468 Addin addin = addins[n];
469
470 addin.Enabled = true;
471 AddinManager.Registry.EnableAddin(addin.Id);
472 // AddinManager.Registry.Update();
473 if(PluginRegistry.IsAddinEnabled(addin.Id))
474 {
475 ConsoleProgressStatus ps = new ConsoleProgressStatus(false);
476 if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id))
477 {
478 AddinManager.Registry.Rebuild(ps);
479 AddinManager.AddinEngine.LoadAddin(ps, addin.Id);
480 }
481 }
482 else
483 {
484 MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name);
485 }
486 return;
487 }
488
489
490
491 #region Util
492 private void Testing()
493 {
494 Addin[] list = Registry.GetAddins();
495
496 var addins = list.Where( a => a.Description.Category == "RobustPlugin");
497
498 foreach (Addin addin in addins)
499 {
500 MainConsole.Instance.OutputFormat("Addin {0}", addin.Name);
501 }
502 }
503
504 // These will let us deal with numbered lists instead
505 // of needing to type in the full ids
506 private AddinRepositoryEntry[] GetSortedAvailbleAddins()
507 {
508 ArrayList list = new ArrayList();
509 list.AddRange(Repositories.GetAvailableAddins());
510
511 AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[];
512
513 Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id));
514
515 return addins;
516 }
517
518 private AddinRepository[] GetSortedAddinRepo()
519 {
520 ArrayList list = new ArrayList();
521 list.AddRange(Repositories.GetRepositories());
522
523 AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[];
524 Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name));
525
526 return repos;
527 }
528
529 private Addin[] GetSortedAddinList(string category)
530 {
531
532 ArrayList xlist = new ArrayList();
533 ArrayList list = new ArrayList();
534 try
535 {
536 list.AddRange(PluginRegistry.GetAddins());
537 }
538 catch(Exception e)
539 {
540 Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[];
541 return x;
542 }
543
544 foreach (Addin addin in list)
545 {
546 if (addin.Description.Category == category)
547 xlist.Add(addin);
548 }
549
550 Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[];
551 Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id));
552
553 return addins;
554 }
555 #endregion Util
556 }
557} \ No newline at end of file
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 8ecf3d3..31b0446 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -111,17 +111,18 @@ namespace OpenSim.Server.Base
111 case ExtensionChange.Add: 111 case ExtensionChange.Add:
112 if (a.AddinFile.Contains(Registry.DefaultAddinsFolder)) 112 if (a.AddinFile.Contains(Registry.DefaultAddinsFolder))
113 { 113 {
114 m_log.InfoFormat("[SERVER]: Adding {0}", a.Name); 114 m_log.InfoFormat("[SERVER]: Adding {0} from registry", a.Name);
115 connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.')); 115 connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.'));
116 } 116 }
117 else 117 else
118 { 118 {
119 m_log.InfoFormat("[SERVER]: Removing {0}", a.Name); 119 m_log.InfoFormat("[SERVER]: Adding {0} from ./bin", a.Name);
120 connector.PluginPath = a.AddinFile; 120 connector.PluginPath = a.AddinFile;
121 } 121 }
122 LoadPlugin(connector); 122 LoadPlugin(connector);
123 break; 123 break;
124 case ExtensionChange.Remove: 124 case ExtensionChange.Remove:
125 m_log.InfoFormat("[SERVER]: Removing {0}", a.Name);
125 UnloadPlugin(connector); 126 UnloadPlugin(connector);
126 break; 127 break;
127 } 128 }
diff --git a/OpenSim/Server/Handlers/Base/ServerConnector.cs b/OpenSim/Server/Handlers/Base/ServerConnector.cs
index 067fd2a..72014db 100644
--- a/OpenSim/Server/Handlers/Base/ServerConnector.cs
+++ b/OpenSim/Server/Handlers/Base/ServerConnector.cs
@@ -41,8 +41,7 @@ namespace OpenSim.Server.Handlers.Base
41 { 41 {
42 public virtual string ConfigURL 42 public virtual string ConfigURL
43 { 43 {
44 get; 44 get { return String.Empty; }
45 protected set;
46 } 45 }
47 46
48 public virtual string ConfigName 47 public virtual string ConfigName
@@ -95,7 +94,10 @@ namespace OpenSim.Server.Handlers.Base
95 return config; 94 return config;
96 } 95 }
97 96
98 // We get our remote initial configuration for bootstrapping 97 // We get our remote initial configuration for bootstrapping in case
98 // we have no configuration in our main file or in an existing
99 // modular config file. This is the last resort to bootstrap the
100 // configuration, likely a new plugin loading for the first time.
99 private IConfigSource GetConfigSource() 101 private IConfigSource GetConfigSource()
100 { 102 {
101 IConfigSource source = null; 103 IConfigSource source = null;