33 using System.Collections;
34 using System.Collections.Generic;
35 using System.Collections.ObjectModel;
37 using Mono.Addins.Setup;
38 using Mono.Addins.Description;
39 using OpenSim.Framework;
42 namespace OpenSim.Framework
53 PluginRegistry = registry;
66 public bool InstallPlugin(
int ndx, out Dictionary<string, object> result)
68 Dictionary<string, object> res =
new Dictionary<string, object>();
70 PackageCollection pack =
new PackageCollection();
71 PackageCollection toUninstall;
72 DependencyCollection unresolved;
74 IProgressStatus ps =
new ConsoleProgressStatus(
false);
76 AddinRepositoryEntry[] available = GetSortedAvailbleAddins();
78 if (ndx > (available.Length - 1))
80 MainConsole.Instance.Output(
"Selection out of range");
85 AddinRepositoryEntry aentry = available[ndx];
87 Package p = Package.FromRepository(aentry);
90 ResolveDependencies(ps, pack, out toUninstall, out unresolved);
93 if (Install(ps, pack) ==
true)
95 MainConsole.Instance.Output(
"Ignore the following error...");
96 PluginRegistry.Update(ps);
97 Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id);
98 PluginRegistry.DisableAddin(addin.Id);
99 addin.Enabled =
false;
101 MainConsole.Instance.Output(
"Installation Success");
102 ListInstalledAddins(out res);
108 MainConsole.Instance.Output(
"Installation Failed");
123 Addin[] addins = GetSortedAddinList(
"RobustPlugin");
125 if (ndx > (addins.Length -1))
127 MainConsole.Instance.Output(
"Selection out of range");
131 Addin addin = addins[ndx];
132 MainConsole.Instance.OutputFormat(
"Uninstalling plugin {0}", addin.Id);
133 AddinManager.Registry.DisableAddin(addin.Id);
134 addin.Enabled =
false;
135 IProgressStatus ps =
new ConsoleProgressStatus(
false);
136 Uninstall(ps, addin.Id);
137 MainConsole.Instance.Output(
"Uninstall Success - restart to complete operation");
149 return "CheckInstall";
160 Dictionary<string, object> res =
new Dictionary<string, object>();
162 Addin[] addins = GetSortedAddinList(
"RobustPlugin");
163 if(addins.Count() < 1)
165 MainConsole.Instance.Output(
"Error!");
168 foreach (Addin addin
in addins)
170 Dictionary<string, object> r =
new Dictionary<string, object>();
171 r[
"enabled"] = addin.Enabled ==
true ?
true :
false;
172 r[
"name"] = addin.LocalId;
173 r[
"version"] = addin.Version;
175 res.Add(count.ToString(), r);
192 Dictionary<string, object> res =
new Dictionary<string, object>();
194 AddinRepositoryEntry[] addins = GetSortedAvailbleAddins();
197 foreach (AddinRepositoryEntry addin
in addins)
199 Dictionary<string, object> r =
new Dictionary<string, object>();
200 r[
"name"] = addin.Addin.Name;
201 r[
"version"] = addin.Addin.Version;
202 r[
"repository"] = addin.RepositoryName;
204 res.Add(count.ToString(), r);
217 IProgressStatus ps =
new ConsoleProgressStatus(
true);
218 Console.WriteLine (
"Looking for updates...");
219 Repositories.UpdateAllRepositories (ps);
220 Console.WriteLine (
"Available add-in updates:");
222 AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates();
224 foreach (AddinRepositoryEntry entry
in entries)
226 Console.WriteLine(String.Format(
"{0}",entry.Addin.Id));
236 IProgressStatus ps =
new ConsoleProgressStatus(
true);
237 Repositories.UpdateAllRepositories(ps);
253 Repositories.RegisterRepository(null, repo,
true);
254 PluginRegistry.Rebuild(null);
264 Repositories.UpdateAllRepositories(
new ConsoleProgressStatus(
false));
276 AddinRepository[] reps = Repositories.GetRepositories();
277 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
278 if (reps.Length == 0)
280 MainConsole.Instance.Output(
"No repositories have been registered.");
284 int n = Convert.ToInt16(args[2]);
285 if (n > (reps.Length -1))
287 MainConsole.Instance.Output(
"Selection out of range");
291 AddinRepository rep = reps[n];
292 Repositories.RemoveRepository(rep.Url);
305 AddinRepository[] reps = Repositories.GetRepositories();
306 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
307 if (reps.Length == 0)
309 MainConsole.Instance.Output(
"No repositories have been registered.");
313 int n = Convert.ToInt16(args[2]);
314 if (n > (reps.Length -1))
316 MainConsole.Instance.Output(
"Selection out of range");
320 AddinRepository rep = reps[n];
321 Repositories.SetRepositoryEnabled(rep.Url,
true);
334 AddinRepository[] reps = Repositories.GetRepositories();
335 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
336 if (reps.Length == 0)
338 MainConsole.Instance.Output(
"No repositories have been registered.");
342 int n = Convert.ToInt16(args[2]);
343 if (n > (reps.Length -1))
345 MainConsole.Instance.Output(
"Selection out of range");
349 AddinRepository rep = reps[n];
350 Repositories.SetRepositoryEnabled(rep.Url,
false);
363 Dictionary<string, object> res =
new Dictionary<string, object>();
366 AddinRepository[] reps = GetSortedAddinRepo();
367 if (reps.Length == 0)
369 MainConsole.Instance.Output(
"No repositories have been registered.");
374 foreach (AddinRepository rep
in reps)
376 Dictionary<string, object> r =
new Dictionary<string, object>();
377 r[
"enabled"] = rep.Enabled ==
true ?
true :
false;
378 r[
"name"] = rep.Name;
381 res.Add(count.ToString(), r);
392 PluginRegistry.Update();
405 public bool AddinInfo(
int ndx, out Dictionary<string, object> result)
407 Dictionary<string, object> res =
new Dictionary<string, object>();
410 Addin[] addins = GetSortedAddinList(
"RobustPlugin");
412 if (ndx > (addins.Length - 1))
414 MainConsole.Instance.Output(
"Selection out of range");
418 Addin addin = addins[ndx];
420 res[
"author"] = addin.Description.Author;
421 res[
"category"] = addin.Description.Category;
422 res[
"description"] = addin.Description.Description;
423 res[
"name"] = addin.Name;
424 res[
"url"] = addin.Description.Url;
425 res[
"file_name"] = addin.Description.FileName;
440 Addin[] addins = GetSortedAddinList(
"RobustPlugin");
442 int n = Convert.ToInt16(args[2]);
443 if (n > (addins.Length -1))
445 MainConsole.Instance.Output(
"Selection out of range");
449 Addin addin = addins[n];
450 AddinManager.Registry.DisableAddin(addin.Id);
451 addin.Enabled =
false;
464 Addin[] addins = GetSortedAddinList(
"RobustPlugin");
466 int n = Convert.ToInt16(args[2]);
467 if (n > (addins.Length -1))
469 MainConsole.Instance.Output(
"Selection out of range");
473 Addin addin = addins[n];
475 addin.Enabled =
true;
476 AddinManager.Registry.EnableAddin(addin.Id);
478 if(PluginRegistry.IsAddinEnabled(addin.Id))
480 ConsoleProgressStatus ps =
new ConsoleProgressStatus(
false);
481 if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id))
483 MainConsole.Instance.Output(
"Ignore the following error...");
484 AddinManager.Registry.Rebuild(ps);
485 AddinManager.AddinEngine.LoadAddin(ps, addin.Id);
490 MainConsole.Instance.OutputFormat(
"Not Enabled in this domain {0}", addin.Name);
498 private void Testing()
500 Addin[] list = Registry.GetAddins();
502 var addins = list.Where( a => a.Description.Category ==
"RobustPlugin");
504 foreach (Addin addin
in addins)
506 MainConsole.Instance.OutputFormat(
"Addin {0}", addin.Name);
512 private AddinRepositoryEntry[] GetSortedAvailbleAddins()
514 ArrayList list =
new ArrayList();
515 list.AddRange(Repositories.GetAvailableAddins());
517 AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[];
519 Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id));
524 private AddinRepository[] GetSortedAddinRepo()
526 ArrayList list =
new ArrayList();
527 list.AddRange(Repositories.GetRepositories());
529 AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[];
530 Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name));
535 private Addin[] GetSortedAddinList(
string category)
538 ArrayList xlist =
new ArrayList();
539 ArrayList list =
new ArrayList();
542 list.AddRange(PluginRegistry.GetAddins());
546 Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[];
550 foreach (Addin addin
in list)
552 if (addin.Description.Category == category)
556 Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[];
557 Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id));
bool AddRepository(string repo)
Register a repository with our server.
void ListRepositories(out Dictionary< string, object > result)
Lists the repositories.
string Update()
Update this instance.
void ListUpdates()
Lists the updates.
void EnablePlugin(string[] args)
Enables the plugin.
void DisableRepository(string[] args)
Disables the repository.
void RemoveRepository(string[] args)
Removes the repository.
PluginManager(AddinRegistry registry)
string CheckInstalled()
Checks the installed.
bool AddinInfo(int ndx, out Dictionary< string, object > result)
Addins the info.
void GetRepository()
Gets the repository.
void EnableRepository(string[] args)
Enables the repository.
AddinRegistry PluginRegistry
void DisablePlugin(string[] args)
Disables the plugin.
void ListAvailable(out Dictionary< string, object > result)
Lists the available.
void UnInstall(int ndx)
Uns the install.
bool InstallPlugin(int ndx, out Dictionary< string, object > result)
Installs the plugin.
void ListInstalledAddins(out Dictionary< string, object > result)
Lists the installed addins.
void UpdateRegistry()
Updates the registry.
Manager for registries and plugins