32 using System.Collections;
33 using System.Collections.Generic;
34 using System.Collections.ObjectModel;
35 using Mono.Addins.Setup;
37 using Mono.Addins.Description;
38 using OpenSim.Framework;
55 PluginRegistry = registry;
57 AddManagementCommands();
60 private void AddManagementCommands()
63 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
64 "plugin add",
"plugin add \"plugin index\"",
65 "Install plugin from repository.",
66 HandleConsoleInstallPlugin);
69 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
70 "plugin remove",
"plugin remove \"plugin index\"",
71 "Remove plugin from repository",
72 HandleConsoleUnInstallPlugin);
75 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
76 "plugin list installed",
77 "plugin list installed",
"List install plugins",
78 HandleConsoleListInstalledPlugin);
81 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
82 "plugin list available",
83 "plugin list available",
"List available plugins",
84 HandleConsoleListAvailablePlugin);
86 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
87 "plugin updates",
"plugin updates",
"List availble updates",
88 HandleConsoleListUpdates);
91 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
92 "plugin update",
"plugin update \"plugin index\"",
"Update the plugin",
93 HandleConsoleUpdatePlugin);
96 MainConsole.Instance.Commands.AddCommand(
"Repository",
true,
97 "repo add",
"repo add \"url\"",
"Add repository",
98 HandleConsoleAddRepo);
101 MainConsole.Instance.Commands.AddCommand(
"Repository",
true,
102 "repo refresh",
"repo refresh \"url\"",
"Sync with a registered repository",
103 HandleConsoleGetRepo);
106 MainConsole.Instance.Commands.AddCommand(
"Repository",
true,
108 "repo remove \"[url | index]\"",
109 "Remove repository from registry",
110 HandleConsoleRemoveRepo);
113 MainConsole.Instance.Commands.AddCommand(
"Repository",
true,
114 "repo enable",
"repo enable \"[url | index]\"",
115 "Enable registered repository",
116 HandleConsoleEnableRepo);
119 MainConsole.Instance.Commands.AddCommand(
"Repository",
true,
120 "repo disable",
"repo disable\"[url | index]\"",
121 "Disable registered repository",
122 HandleConsoleDisableRepo);
125 MainConsole.Instance.Commands.AddCommand(
"Repository",
true,
126 "repo list",
"repo list",
127 "List registered repositories",
128 HandleConsoleListRepos);
131 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
132 "plugin info",
"plugin info \"plugin index\"",
"Show detailed information for plugin",
133 HandleConsoleShowAddinInfo);
136 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
137 "plugin disable",
"plugin disable \"plugin index\"",
139 HandleConsoleDisablePlugin);
142 MainConsole.Instance.Commands.AddCommand(
"Plugin",
true,
143 "plugin enable",
"plugin enable \"plugin index\"",
144 "Enable the selected plugin plugin",
145 HandleConsoleEnablePlugin);
148 #region console handlers
162 private void HandleConsoleInstallPlugin(
string module,
string[] cmd)
164 Dictionary<string, object> result =
new Dictionary<string, object>();
168 int ndx = Convert.ToInt16(cmd[2]);
171 ArrayList s =
new ArrayList();
172 s.AddRange(result.Keys);
175 var list = result.Keys.ToList();
177 foreach (var k
in list)
179 Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
180 bool enabled = (bool)plugin[
"enabled"];
181 MainConsole.Instance.OutputFormat(
"{0}) {1} {2} rev. {3}",
183 enabled ==
true ?
"[ ]" :
"[X]",
184 plugin[
"name"], plugin[
"version"]);
192 private void HandleConsoleUnInstallPlugin(
string module,
string[] cmd)
196 int ndx = Convert.ToInt16(cmd[2]);
197 PluginManager.UnInstall(ndx);
203 private void HandleConsoleListInstalledPlugin(
string module,
string[] cmd)
205 Dictionary<string, object> result =
new Dictionary<string, object>();
206 PluginManager.ListInstalledAddins(out result);
208 ArrayList s =
new ArrayList();
209 s.AddRange(result.Keys);
212 var list = result.Keys.ToList();
214 foreach (var k
in list)
216 Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
217 bool enabled = (bool)plugin[
"enabled"];
218 MainConsole.Instance.OutputFormat(
"{0}) {1} {2} rev. {3}",
220 enabled ==
true ?
"[ ]" :
"[X]",
221 plugin[
"name"], plugin[
"version"]);
227 private void HandleConsoleListAvailablePlugin(
string module,
string[] cmd)
229 Dictionary<string, object> result =
new Dictionary<string, object>();
230 PluginManager.ListAvailable(out result);
232 var list = result.Keys.ToList();
234 foreach (var k
in list)
237 Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
238 MainConsole.Instance.OutputFormat(
"{0}) {1} rev. {2} {3}",
242 plugin[
"repository"]);
248 private void HandleConsoleListUpdates(
string module,
string[] cmd)
250 PluginManager.ListUpdates();
255 private void HandleConsoleUpdatePlugin(
string module,
string[] cmd)
257 MainConsole.Instance.Output(PluginManager.Update());
262 private void HandleConsoleAddRepo(
string module,
string[] cmd)
264 if ( cmd.Length == 3)
266 PluginManager.AddRepository(cmd[2]);
272 private void HandleConsoleGetRepo(
string module,
string[] cmd)
274 PluginManager.GetRepository();
279 private void HandleConsoleRemoveRepo(
string module,
string[] cmd)
282 PluginManager.RemoveRepository(cmd);
287 private void HandleConsoleEnableRepo(
string module,
string[] cmd)
289 PluginManager.EnableRepository(cmd);
294 private void HandleConsoleDisableRepo(
string module,
string[] cmd)
296 PluginManager.DisableRepository(cmd);
301 private void HandleConsoleListRepos(
string module,
string[] cmd)
303 Dictionary<string, object> result =
new Dictionary<string, object>();
304 PluginManager.ListRepositories(out result);
306 var list = result.Keys.ToList();
308 foreach (var k
in list)
310 Dictionary<string, object> repo = (Dictionary<string, object>)result[k];
311 bool enabled = (bool)repo[
"enabled"];
312 MainConsole.Instance.OutputFormat(
"{0}) {1} {2}",
314 enabled ==
true ?
"[ ]" :
"[X]",
315 repo[
"name"], repo[
"url"]);
322 private void HandleConsoleShowAddinInfo(
string module,
string[] cmd)
327 Dictionary<string, object> result =
new Dictionary<string, object>();
329 int ndx = Convert.ToInt16(cmd[2]);
330 PluginManager.AddinInfo(ndx, out result);
332 MainConsole.Instance.OutputFormat(
"Name: {0}\nURL: {1}\nFile: {2}\nAuthor: {3}\nCategory: {4}\nDesc: {5}",
338 result[
"description"]);
345 private void HandleConsoleDisablePlugin(
string module,
string[] cmd)
347 PluginManager.DisablePlugin(cmd);
352 private void HandleConsoleEnablePlugin(
string module,
string[] cmd)
354 PluginManager.EnablePlugin(cmd);
AddinRegistry PluginRegistry
Command manager - Wrapper for OpenSim.Framework.PluginManager to allow us to add commands to the cons...
PluginManager PluginManager
CommandManager(AddinRegistry registry)
bool InstallPlugin(int ndx, out Dictionary< string, object > result)
Installs the plugin.
Interactive OpenSim region server
Manager for registries and plugins