aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-12-09 21:27:32 +0000
committerMelanie2012-12-09 21:27:32 +0000
commitf30d519bcc1e68deee0d5b3671766ceb39a37018 (patch)
treee082cd09c815191377d840b1c2936f5e558e45b0 /OpenSim
parentMerge branch 'master' into careminster (diff)
parentRestrict IPresenceData.VerifyAgent (diff)
downloadopensim-SC_OLD-f30d519bcc1e68deee0d5b3671766ceb39a37018.zip
opensim-SC_OLD-f30d519bcc1e68deee0d5b3671766ceb39a37018.tar.gz
opensim-SC_OLD-f30d519bcc1e68deee0d5b3671766ceb39a37018.tar.bz2
opensim-SC_OLD-f30d519bcc1e68deee0d5b3671766ceb39a37018.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/IPresenceData.cs1
-rw-r--r--OpenSim/Data/MSSQL/MSSQLPresenceData.cs13
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs14
-rw-r--r--OpenSim/Data/Null/NullPresenceData.cs8
-rw-r--r--OpenSim/Framework/PluginManager.cs561
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs138
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs11
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs30
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs15
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt8
-rw-r--r--OpenSim/Server/Base/CommandManager.cs359
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs163
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs10
-rw-r--r--OpenSim/Server/Handlers/Base/ServerConnector.cs67
-rw-r--r--OpenSim/Server/ServerMain.cs10
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs2
16 files changed, 1317 insertions, 93 deletions
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs
index b871f56..9ec48b0 100644
--- a/OpenSim/Data/IPresenceData.cs
+++ b/OpenSim/Data/IPresenceData.cs
@@ -53,5 +53,6 @@ namespace OpenSim.Data
53 bool ReportAgent(UUID sessionID, UUID regionID); 53 bool ReportAgent(UUID sessionID, UUID regionID);
54 PresenceData[] Get(string field, string data); 54 PresenceData[] Get(string field, string data);
55 bool Delete(string field, string val); 55 bool Delete(string field, string val);
56 bool VerifyAgent(UUID agentId, UUID secureSessionID);
56 } 57 }
57} 58}
diff --git a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs
index e7b3d9c..deff2ed 100644
--- a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs
@@ -100,5 +100,18 @@ namespace OpenSim.Data.MSSQL
100 return true; 100 return true;
101 } 101 }
102 102
103 public bool VerifyAgent(UUID agentId, UUID secureSessionID)
104 {
105 PresenceData[] ret = Get("SecureSessionID",
106 secureSessionID.ToString());
107
108 if (ret.Length == 0)
109 return false;
110
111 if(ret[0].UserID != agentId.ToString())
112 return false;
113
114 return true;
115 }
103 } 116 }
104} 117}
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs
index 7808060..3f90639 100644
--- a/OpenSim/Data/MySQL/MySQLPresenceData.cs
+++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs
@@ -95,5 +95,19 @@ namespace OpenSim.Data.MySQL
95 95
96 return true; 96 return true;
97 } 97 }
98
99 public bool VerifyAgent(UUID agentId, UUID secureSessionID)
100 {
101 PresenceData[] ret = Get("SecureSessionID",
102 secureSessionID.ToString());
103
104 if (ret.Length == 0)
105 return false;
106
107 if(ret[0].UserID != agentId.ToString())
108 return false;
109
110 return true;
111 }
98 } 112 }
99} \ No newline at end of file 113} \ No newline at end of file
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs
index c06c223..b85b95e 100644
--- a/OpenSim/Data/Null/NullPresenceData.cs
+++ b/OpenSim/Data/Null/NullPresenceData.cs
@@ -222,5 +222,13 @@ namespace OpenSim.Data.Null
222 return true; 222 return true;
223 } 223 }
224 224
225 public bool VerifyAgent(UUID agentId, UUID secureSessionID)
226 {
227 if (Instance != this)
228 return Instance.VerifyAgent(agentId, secureSessionID);
229
230 return false;
231 }
232
225 } 233 }
226} 234}
diff --git a/OpenSim/Framework/PluginManager.cs b/OpenSim/Framework/PluginManager.cs
new file mode 100644
index 0000000..23d5945
--- /dev/null
+++ b/OpenSim/Framework/PluginManager.cs
@@ -0,0 +1,561 @@
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
41
42namespace OpenSim.Framework
43{
44 /// <summary>
45 /// Manager for registries and plugins
46 /// </summary>
47 public class PluginManager : SetupService
48 {
49 public AddinRegistry PluginRegistry;
50
51 public PluginManager(AddinRegistry registry): base (registry)
52 {
53 PluginRegistry = registry;
54
55 }
56
57 /// <summary>
58 /// Installs the plugin.
59 /// </summary>
60 /// <returns>
61 /// The plugin.
62 /// </returns>
63 /// <param name='args'>
64 /// Arguments.
65 /// </param>
66 public bool InstallPlugin(int ndx, out Dictionary<string, object> result)
67 {
68 Dictionary<string, object> res = new Dictionary<string, object>();
69
70 PackageCollection pack = new PackageCollection();
71 PackageCollection toUninstall;
72 DependencyCollection unresolved;
73
74 IProgressStatus ps = new ConsoleProgressStatus(false);
75
76 AddinRepositoryEntry[] available = GetSortedAvailbleAddins();
77
78 if (ndx > (available.Length - 1))
79 {
80 MainConsole.Instance.Output("Selection out of range");
81 result = res;
82 return false;
83 }
84
85 AddinRepositoryEntry aentry = available[ndx];
86
87 Package p = Package.FromRepository(aentry);
88 pack.Add(p);
89
90 ResolveDependencies(ps, pack, out toUninstall, out unresolved);
91
92 // Attempt to install the plugin disabled
93 if (Install(ps, pack) == true)
94 {
95 PluginRegistry.Update(ps);
96 Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id);
97 PluginRegistry.DisableAddin(addin.Id);
98 addin.Enabled = false;
99
100 MainConsole.Instance.Output("Installation Success");
101 ListInstalledAddins(out res);
102 result = res;
103 return true;
104 }
105 else
106 {
107 MainConsole.Instance.Output("Installation Failed");
108 result = res;
109 return false;
110 }
111 }
112
113 // Remove plugin
114 /// <summary>
115 /// Uns the install.
116 /// </summary>
117 /// <param name='args'>
118 /// Arguments.
119 /// </param>
120 public void UnInstall(int ndx)
121 {
122 Addin[] addins = GetSortedAddinList("RobustPlugin");
123
124 if (ndx > (addins.Length -1))
125 {
126 MainConsole.Instance.Output("Selection out of range");
127 return;
128 }
129
130 Addin addin = addins[ndx];
131 MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id);
132 AddinManager.Registry.DisableAddin(addin.Id);
133 addin.Enabled = false;
134 IProgressStatus ps = new ConsoleProgressStatus(false);
135 Uninstall(ps, addin.Id);
136 MainConsole.Instance.Output("Uninstall Success - restart to complete operation");
137 return;
138 }
139
140 /// <summary>
141 /// Checks the installed.
142 /// </summary>
143 /// <returns>
144 /// The installed.
145 /// </returns>
146 public string CheckInstalled()
147 {
148 return "CheckInstall";
149 }
150
151 /// <summary>
152 /// Lists the installed addins.
153 /// </summary>
154 /// <param name='result'>
155 /// Result.
156 /// </param>
157 public void ListInstalledAddins(out Dictionary<string, object> result)
158 {
159 Dictionary<string, object> res = new Dictionary<string, object>();
160
161 Addin[] addins = GetSortedAddinList("RobustPlugin");
162 if(addins.Count() < 1)
163 {
164 MainConsole.Instance.Output("Error!");
165 }
166 int count = 0;
167 foreach (Addin addin in addins)
168 {
169 Dictionary<string, object> r = new Dictionary<string, object>();
170 r["enabled"] = addin.Enabled == true ? true : false;
171 r["name"] = addin.LocalId;
172 r["version"] = addin.Version;
173
174 res.Add(count.ToString(), r);
175
176 count++;
177 }
178 result = res;
179 return;
180 }
181
182 // List compatible plugins in registered repositories
183 /// <summary>
184 /// Lists the available.
185 /// </summary>
186 /// <param name='result'>
187 /// Result.
188 /// </param>
189 public void ListAvailable(out Dictionary<string, object> result)
190 {
191 Dictionary<string, object> res = new Dictionary<string, object>();
192
193 AddinRepositoryEntry[] addins = GetSortedAvailbleAddins();
194
195 int count = 0;
196 foreach (AddinRepositoryEntry addin in addins)
197 {
198 Dictionary<string, object> r = new Dictionary<string, object>();
199 r["name"] = addin.Addin.Name;
200 r["version"] = addin.Addin.Version;
201 r["repository"] = addin.RepositoryName;
202
203 res.Add(count.ToString(), r);
204 count++;
205 }
206 result = res;
207 return;
208 }
209
210 // List available updates ** 1
211 /// <summary>
212 /// Lists the updates.
213 /// </summary>
214 public void ListUpdates()
215 {
216 IProgressStatus ps = new ConsoleProgressStatus(true);
217 Console.WriteLine ("Looking for updates...");
218 Repositories.UpdateAllRepositories (ps);
219 Console.WriteLine ("Available add-in updates:");
220 bool found = false;
221 AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates();
222
223 foreach (AddinRepositoryEntry entry in entries)
224 {
225 Console.WriteLine(String.Format("{0}",entry.Addin.Id));
226 }
227 }
228
229 // Sync to repositories
230 /// <summary>
231 /// Update this instance.
232 /// </summary>
233 public string Update()
234 {
235 IProgressStatus ps = new ConsoleProgressStatus(true);
236 Repositories.UpdateAllRepositories(ps);
237 return "Update";
238 }
239
240 // Register a repository
241 /// <summary>
242 /// Register a repository with our server.
243 /// </summary>
244 /// <returns>
245 /// result of the action
246 /// </returns>
247 /// <param name='repo'>
248 /// The URL of the repository we want to add
249 /// </param>
250 public bool AddRepository(string repo)
251 {
252 Repositories.RegisterRepository(null, repo, true);
253 PluginRegistry.Rebuild(null);
254
255 return true;
256 }
257
258 /// <summary>
259 /// Gets the repository.
260 /// </summary>
261 public void GetRepository()
262 {
263 Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false));
264 }
265
266 // Remove a repository from the list
267 /// <summary>
268 /// Removes the repository.
269 /// </summary>
270 /// <param name='args'>
271 /// Arguments.
272 /// </param>
273 public void RemoveRepository(string[] args)
274 {
275 AddinRepository[] reps = Repositories.GetRepositories();
276 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
277 if (reps.Length == 0)
278 {
279 MainConsole.Instance.Output("No repositories have been registered.");
280 return;
281 }
282
283 int n = Convert.ToInt16(args[2]);
284 if (n > (reps.Length -1))
285 {
286 MainConsole.Instance.Output("Selection out of range");
287 return;
288 }
289
290 AddinRepository rep = reps[n];
291 Repositories.RemoveRepository(rep.Url);
292 return;
293 }
294
295 // Enable repository
296 /// <summary>
297 /// Enables the repository.
298 /// </summary>
299 /// <param name='args'>
300 /// Arguments.
301 /// </param>
302 public void EnableRepository(string[] args)
303 {
304 AddinRepository[] reps = Repositories.GetRepositories();
305 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
306 if (reps.Length == 0)
307 {
308 MainConsole.Instance.Output("No repositories have been registered.");
309 return;
310 }
311
312 int n = Convert.ToInt16(args[2]);
313 if (n > (reps.Length -1))
314 {
315 MainConsole.Instance.Output("Selection out of range");
316 return;
317 }
318
319 AddinRepository rep = reps[n];
320 Repositories.SetRepositoryEnabled(rep.Url, true);
321 return;
322 }
323
324 // Disable a repository
325 /// <summary>
326 /// Disables the repository.
327 /// </summary>
328 /// <param name='args'>
329 /// Arguments.
330 /// </param>
331 public void DisableRepository(string[] args)
332 {
333 AddinRepository[] reps = Repositories.GetRepositories();
334 Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
335 if (reps.Length == 0)
336 {
337 MainConsole.Instance.Output("No repositories have been registered.");
338 return;
339 }
340
341 int n = Convert.ToInt16(args[2]);
342 if (n > (reps.Length -1))
343 {
344 MainConsole.Instance.Output("Selection out of range");
345 return;
346 }
347
348 AddinRepository rep = reps[n];
349 Repositories.SetRepositoryEnabled(rep.Url, false);
350 return;
351 }
352
353 // List registered repositories
354 /// <summary>
355 /// Lists the repositories.
356 /// </summary>
357 /// <param name='result'>
358 /// Result.
359 /// </param>
360 public void ListRepositories(out Dictionary<string, object> result)
361 {
362 Dictionary<string, object> res = new Dictionary<string, object>();
363 result = res;
364
365 AddinRepository[] reps = GetSortedAddinRepo();
366 if (reps.Length == 0)
367 {
368 MainConsole.Instance.Output("No repositories have been registered.");
369 return;
370 }
371
372 int count = 0;
373 foreach (AddinRepository rep in reps)
374 {
375 Dictionary<string, object> r = new Dictionary<string, object>();
376 r["enabled"] = rep.Enabled == true ? true : false;
377 r["name"] = rep.Name;
378 r["url"] = rep.Url;
379
380 res.Add(count.ToString(), r);
381 count++;
382 }
383 return;
384 }
385
386 /// <summary>
387 /// Updates the registry.
388 /// </summary>
389 public void UpdateRegistry()
390 {
391 PluginRegistry.Update();
392 }
393
394 // Show plugin info
395 /// <summary>
396 /// Addins the info.
397 /// </summary>
398 /// <returns>
399 /// The info.
400 /// </returns>
401 /// <param name='args'>
402 /// Arguments.
403 /// </param>
404 public bool AddinInfo(int ndx, out Dictionary<string, object> result)
405 {
406 Dictionary<string, object> res = new Dictionary<string, object>();
407 result = res;
408
409 Addin[] addins = GetSortedAddinList("RobustPlugin");
410
411 if (ndx > (addins.Length - 1))
412 {
413 MainConsole.Instance.Output("Selection out of range");
414 return false;
415 }
416 // author category description
417 Addin addin = addins[ndx];
418
419 res["author"] = addin.Description.Author;
420 res["category"] = addin.Description.Category;
421 res["description"] = addin.Description.Description;
422 res["name"] = addin.Name;
423 res["url"] = addin.Description.Url;
424 res["file_name"] = addin.Description.FileName;
425
426 result = res;
427 return true;
428 }
429
430 // Disable a plugin
431 /// <summary>
432 /// Disables the plugin.
433 /// </summary>
434 /// <param name='args'>
435 /// Arguments.
436 /// </param>
437 public void DisablePlugin(string[] args)
438 {
439 Addin[] addins = GetSortedAddinList("RobustPlugin");
440
441 int n = Convert.ToInt16(args[2]);
442 if (n > (addins.Length -1))
443 {
444 MainConsole.Instance.Output("Selection out of range");
445 return;
446 }
447
448 Addin addin = addins[n];
449 AddinManager.Registry.DisableAddin(addin.Id);
450 addin.Enabled = false;
451 return;
452 }
453
454 // Enable plugin
455 /// <summary>
456 /// Enables the plugin.
457 /// </summary>
458 /// <param name='args'>
459 /// Arguments.
460 /// </param>
461 public void EnablePlugin(string[] args)
462 {
463 Addin[] addins = GetSortedAddinList("RobustPlugin");
464
465 int n = Convert.ToInt16(args[2]);
466 if (n > (addins.Length -1))
467 {
468 MainConsole.Instance.Output("Selection out of range");
469 return;
470 }
471
472 Addin addin = addins[n];
473
474 addin.Enabled = true;
475 AddinManager.Registry.EnableAddin(addin.Id);
476 // AddinManager.Registry.Update();
477 if(PluginRegistry.IsAddinEnabled(addin.Id))
478 {
479 ConsoleProgressStatus ps = new ConsoleProgressStatus(false);
480 if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id))
481 {
482 AddinManager.Registry.Rebuild(ps);
483 AddinManager.AddinEngine.LoadAddin(ps, addin.Id);
484 }
485 }
486 else
487 {
488 MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name);
489 }
490 return;
491 }
492
493
494
495 #region Util
496 private void Testing()
497 {
498 Addin[] list = Registry.GetAddins();
499
500 var addins = list.Where( a => a.Description.Category == "RobustPlugin");
501
502 foreach (Addin addin in addins)
503 {
504 MainConsole.Instance.OutputFormat("Addin {0}", addin.Name);
505 }
506 }
507
508 // These will let us deal with numbered lists instead
509 // of needing to type in the full ids
510 private AddinRepositoryEntry[] GetSortedAvailbleAddins()
511 {
512 ArrayList list = new ArrayList();
513 list.AddRange(Repositories.GetAvailableAddins());
514
515 AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[];
516
517 Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id));
518
519 return addins;
520 }
521
522 private AddinRepository[] GetSortedAddinRepo()
523 {
524 ArrayList list = new ArrayList();
525 list.AddRange(Repositories.GetRepositories());
526
527 AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[];
528 Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name));
529
530 return repos;
531 }
532
533 private Addin[] GetSortedAddinList(string category)
534 {
535
536 ArrayList xlist = new ArrayList();
537 ArrayList list = new ArrayList();
538 try
539 {
540 list.AddRange(PluginRegistry.GetAddins());
541 }
542 catch(Exception e)
543 {
544 Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[];
545 return x;
546 }
547
548 foreach (Addin addin in list)
549 {
550 if (addin.Description.Category == category)
551 xlist.Add(addin);
552 }
553
554 Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[];
555 Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id));
556
557 return addins;
558 }
559 #endregion Util
560 }
561}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 4cfa33d..ae58dfd 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -316,76 +316,74 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
316 } 316 }
317 } 317 }
318 318
319 // Disabled for now as it looks like http://opensimulator.org/mantis/view.php?id=6311 was fixed by fixes 319 // XXX: This code was placed here to try and accomodate RLV which moves given folders named #RLV/~<name>
320 // to inventory folder versioning allowing the viewer to move the received folder itself as happens on the 320 // to the requested folder, which in this case is #RLV. However, it is the viewer that appears to be
321 // LL grid. Doing it again server-side then wrongly does a second create and move 321 // response from renaming the #RLV/~example folder to ~example. For some reason this is not yet
322// // XXX: This code was placed here to try and accomdate RLV which moves given folders named #RLV/~<name> 322 // happening, possibly because we are not sending the correct inventory update messages with the correct
323// // to a folder called name in #RLV. However, this approach may not be ultimately correct - from analysis 323 // transaction IDs
324// // of Firestorm 4.2.2 on sending an InventoryOffered instead of TaskInventoryOffered (as was previously 324 else if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
325// // done), the viewer itself would appear to move and rename the folder, rather than the simulator doing it here. 325 {
326// else if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) 326 UUID destinationFolderID = UUID.Zero;
327// { 327
328// UUID destinationFolderID = UUID.Zero; 328 if (im.binaryBucket != null && im.binaryBucket.Length >= 16)
329// 329 {
330// if (im.binaryBucket != null && im.binaryBucket.Length >= 16) 330 destinationFolderID = new UUID(im.binaryBucket, 0);
331// { 331 }
332// destinationFolderID = new UUID(im.binaryBucket, 0); 332
333// } 333 if (destinationFolderID != UUID.Zero)
334// 334 {
335// if (destinationFolderID != UUID.Zero) 335 InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId);
336// { 336 if (destinationFolder == null)
337// InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId); 337 {
338// if (destinationFolder == null) 338 m_log.WarnFormat(
339// { 339 "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist",
340// m_log.WarnFormat( 340 client.Name, scene.Name, destinationFolderID);
341// "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist", 341
342// client.Name, scene.Name, destinationFolderID); 342 return;
343// 343 }
344// return; 344
345// } 345 IInventoryService invService = scene.InventoryService;
346// 346
347// IInventoryService invService = scene.InventoryService; 347 UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
348// 348
349// UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip 349 InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId);
350// 350 item = invService.GetItem(item);
351// InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); 351 InventoryFolderBase folder = null;
352// item = invService.GetItem(item); 352 UUID? previousParentFolderID = null;
353// InventoryFolderBase folder = null; 353
354// UUID? previousParentFolderID = null; 354 if (item != null) // It's an item
355// 355 {
356// if (item != null) // It's an item 356 previousParentFolderID = item.Folder;
357// { 357 item.Folder = destinationFolderID;
358// previousParentFolderID = item.Folder; 358
359// item.Folder = destinationFolderID; 359 invService.DeleteItems(item.Owner, new List<UUID>() { item.ID });
360// 360 scene.AddInventoryItem(client, item);
361// invService.DeleteItems(item.Owner, new List<UUID>() { item.ID }); 361 }
362// scene.AddInventoryItem(client, item); 362 else
363// } 363 {
364// else 364 folder = new InventoryFolderBase(inventoryID, client.AgentId);
365// { 365 folder = invService.GetFolder(folder);
366// folder = new InventoryFolderBase(inventoryID, client.AgentId); 366
367// folder = invService.GetFolder(folder); 367 if (folder != null) // It's a folder
368// 368 {
369// if (folder != null) // It's a folder 369 previousParentFolderID = folder.ParentID;
370// { 370 folder.ParentID = destinationFolderID;
371// previousParentFolderID = folder.ParentID; 371 invService.MoveFolder(folder);
372// folder.ParentID = destinationFolderID; 372 }
373// invService.MoveFolder(folder); 373 }
374// } 374
375// } 375 // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code).
376// 376 if (previousParentFolderID != null)
377// // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code). 377 {
378// if (previousParentFolderID != null) 378 InventoryFolderBase previousParentFolder
379// { 379 = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId);
380// InventoryFolderBase previousParentFolder 380 previousParentFolder = invService.GetFolder(previousParentFolder);
381// = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId); 381 scene.SendInventoryUpdate(client, previousParentFolder, true, true);
382// previousParentFolder = invService.GetFolder(previousParentFolder); 382
383// scene.SendInventoryUpdate(client, previousParentFolder, true, true); 383 scene.SendInventoryUpdate(client, destinationFolder, true, true);
384// 384 }
385// scene.SendInventoryUpdate(client, destinationFolder, true, true); 385 }
386// } 386 }
387// }
388// }
389 else if ( 387 else if (
390 im.dialog == (byte)InstantMessageDialog.InventoryDeclined 388 im.dialog == (byte)InstantMessageDialog.InventoryDeclined
391 || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined) 389 || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index b9c2cf9..1f7c398 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -59,7 +59,7 @@ public sealed class BSLinksetCompound : BSLinkset
59 // refresh will happen once after all the other taints are applied. 59 // refresh will happen once after all the other taints are applied.
60 public override void Refresh(BSPhysObject requestor) 60 public override void Refresh(BSPhysObject requestor)
61 { 61 {
62 // External request for Refresh (from BSPrim) is not necessary 62 // External request for Refresh (from BSPrim) doesn't need to do anything
63 // InternalRefresh(requestor); 63 // InternalRefresh(requestor);
64 } 64 }
65 65
@@ -86,7 +86,7 @@ public sealed class BSLinksetCompound : BSLinkset
86 DetailLog("{0},BSLinksetCompound.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); 86 DetailLog("{0},BSLinksetCompound.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child));
87 if (!IsRoot(child)) 87 if (!IsRoot(child))
88 { 88 {
89 // Physical children are removed from the world as the shape ofthe root compound 89 // The origional prims are removed from the world as the shape of the root compound
90 // shape takes over. 90 // shape takes over.
91 BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); 91 BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE);
92 BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION); 92 BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION);
@@ -118,7 +118,7 @@ public sealed class BSLinksetCompound : BSLinkset
118 // Called at taint-time!! 118 // Called at taint-time!!
119 public override void UpdateProperties(BSPhysObject updated) 119 public override void UpdateProperties(BSPhysObject updated)
120 { 120 {
121 // Nothing to do for constraints on property updates 121 // Nothing to do for compound linksets on property updates
122 } 122 }
123 123
124 // The children move around in relationship to the root. 124 // The children move around in relationship to the root.
@@ -257,6 +257,11 @@ public sealed class BSLinksetCompound : BSLinkset
257 BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, cPrim.PhysShape.ptr, displacementPos, displacementRot); 257 BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, cPrim.PhysShape.ptr, displacementPos, displacementRot);
258 } 258 }
259 } 259 }
260
261 // TODO: need to phantomize the child prims left behind.
262 // Maybe just destroy the children bodies and shapes and have them rebuild on unlink.
263 // Selection/deselection might cause way too many build/destructions esp. for LARGE linksets.
264
260 return false; // 'false' says to move onto the next child in the list 265 return false; // 'false' says to move onto the next child in the list
261 }); 266 });
262 267
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 62aaf80..4d203ff 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -190,12 +190,15 @@ public sealed class BSPrim : BSPhysObject
190 } 190 }
191 public override bool Selected { 191 public override bool Selected {
192 set { 192 set {
193 _isSelected = value; 193 if (value != _isSelected)
194 PhysicsScene.TaintedObject("BSPrim.setSelected", delegate()
195 { 194 {
196 DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); 195 _isSelected = value;
197 SetObjectDynamic(false); 196 PhysicsScene.TaintedObject("BSPrim.setSelected", delegate()
198 }); 197 {
198 DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected);
199 SetObjectDynamic(false);
200 });
201 }
199 } 202 }
200 } 203 }
201 public override void CrossingFailure() { return; } 204 public override void CrossingFailure() { return; }
@@ -678,8 +681,11 @@ public sealed class BSPrim : BSPhysObject
678 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); 681 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
679 // Stop all movement 682 // Stop all movement
680 ZeroMotion(true); 683 ZeroMotion(true);
681 // Center of mass is at the center of the object 684
682 // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody.ptr, _position, _orientation); 685 // Set various physical properties so other object interact properly
686 BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction);
687 BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution);
688
683 // Mass is zero which disables a bunch of physics stuff in Bullet 689 // Mass is zero which disables a bunch of physics stuff in Bullet
684 UpdatePhysicalMassProperties(0f); 690 UpdatePhysicalMassProperties(0f);
685 // Set collision detection parameters 691 // Set collision detection parameters
@@ -688,13 +694,15 @@ public sealed class BSPrim : BSPhysObject
688 BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, PhysicsScene.Params.ccdMotionThreshold); 694 BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, PhysicsScene.Params.ccdMotionThreshold);
689 BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); 695 BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius);
690 } 696 }
691 // There can be special things needed for implementing linksets 697
692 Linkset.MakeStatic(this);
693 // The activation state is 'disabled' so Bullet will not try to act on it. 698 // The activation state is 'disabled' so Bullet will not try to act on it.
694 // BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_SIMULATION); 699 // BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_SIMULATION);
695 // Start it out sleeping and physical actions could wake it up. 700 // Start it out sleeping and physical actions could wake it up.
696 BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING); 701 BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING);
697 702
703 // There can be special things needed for implementing linksets
704 Linkset.MakeStatic(this);
705
698 PhysBody.collisionGroup = CollisionFilterGroups.StaticObjectGroup; 706 PhysBody.collisionGroup = CollisionFilterGroups.StaticObjectGroup;
699 PhysBody.collisionMask = CollisionFilterGroups.StaticObjectMask; 707 PhysBody.collisionMask = CollisionFilterGroups.StaticObjectMask;
700 } 708 }
@@ -1326,7 +1334,7 @@ public sealed class BSPrim : BSPhysObject
1326 // Rebuild the geometry and object. 1334 // Rebuild the geometry and object.
1327 // This is called when the shape changes so we need to recreate the mesh/hull. 1335 // This is called when the shape changes so we need to recreate the mesh/hull.
1328 // Called at taint-time!!! 1336 // Called at taint-time!!!
1329 private void CreateGeomAndObject(bool forceRebuild) 1337 public void CreateGeomAndObject(bool forceRebuild)
1330 { 1338 {
1331 // If this prim is part of a linkset, we must remove and restore the physical 1339 // If this prim is part of a linkset, we must remove and restore the physical
1332 // links if the body is rebuilt. 1340 // links if the body is rebuilt.
@@ -1341,7 +1349,7 @@ public sealed class BSPrim : BSPhysObject
1341 { 1349 {
1342 // Called if the current prim body is about to be destroyed. 1350 // Called if the current prim body is about to be destroyed.
1343 // Remove all the physical dependencies on the old body. 1351 // Remove all the physical dependencies on the old body.
1344 // (Maybe someday make the changing of BSShape an event handled by BSLinkset.) 1352 // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...)
1345 needToRestoreLinkset = Linkset.RemoveBodyDependencies(this); 1353 needToRestoreLinkset = Linkset.RemoveBodyDependencies(this);
1346 needToRestoreVehicle = _vehicle.RemoveBodyDependencies(this); 1354 needToRestoreVehicle = _vehicle.RemoveBodyDependencies(this);
1347 }); 1355 });
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index a5e5754..a77dee9 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -415,7 +415,7 @@ public sealed class BSShapeCollection : IDisposable
415 if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE) 415 if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE)
416 { 416 {
417 // an avatar capsule is close to a native shape (it is not shared) 417 // an avatar capsule is close to a native shape (it is not shared)
418 ret = GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_CAPSULE, 418 GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_CAPSULE,
419 FixedShapeKey.KEY_CAPSULE, shapeCallback); 419 FixedShapeKey.KEY_CAPSULE, shapeCallback);
420 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape); 420 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape);
421 ret = true; 421 ret = true;
@@ -423,7 +423,7 @@ public sealed class BSShapeCollection : IDisposable
423 } 423 }
424 424
425 // Compound shapes are handled special as they are rebuilt from scratch. 425 // Compound shapes are handled special as they are rebuilt from scratch.
426 // This isn't too great a hardship since most of the child shapes will already been created. 426 // This isn't too great a hardship since most of the child shapes will have already been created.
427 if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND) 427 if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND)
428 { 428 {
429 ret = GetReferenceToCompoundShape(prim, shapeCallback); 429 ret = GetReferenceToCompoundShape(prim, shapeCallback);
@@ -460,6 +460,9 @@ public sealed class BSShapeCollection : IDisposable
460 && pbs.PathScaleX == 100 && pbs.PathScaleY == 100 460 && pbs.PathScaleX == 100 && pbs.PathScaleY == 100
461 && pbs.PathShearX == 0 && pbs.PathShearY == 0) ) ) 461 && pbs.PathShearX == 0 && pbs.PathShearY == 0) ) )
462 { 462 {
463 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}",
464 prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type);
465
463 // It doesn't look like Bullet scales spheres so make sure the scales are all equal 466 // It doesn't look like Bullet scales spheres so make sure the scales are all equal
464 if ((pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) 467 if ((pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1)
465 && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z) 468 && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z)
@@ -538,6 +541,8 @@ public sealed class BSShapeCollection : IDisposable
538 if (DDetail) DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}", 541 if (DDetail) DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}",
539 prim.LocalID, newShape, prim.Scale); 542 prim.LocalID, newShape, prim.Scale);
540 543
544 // native shapes are scaled by Bullet
545 prim.Scale = prim.Size;
541 prim.PhysShape = newShape; 546 prim.PhysShape = newShape;
542 return true; 547 return true;
543 } 548 }
@@ -550,8 +555,8 @@ public sealed class BSShapeCollection : IDisposable
550 ShapeData nativeShapeData = new ShapeData(); 555 ShapeData nativeShapeData = new ShapeData();
551 nativeShapeData.Type = shapeType; 556 nativeShapeData.Type = shapeType;
552 nativeShapeData.ID = prim.LocalID; 557 nativeShapeData.ID = prim.LocalID;
553 nativeShapeData.Scale = prim.Scale; 558 nativeShapeData.Scale = prim.Size;
554 nativeShapeData.Size = prim.Scale; // unneeded, I think. 559 nativeShapeData.Size = prim.Size; // unneeded, I think.
555 nativeShapeData.MeshKey = (ulong)shapeKey; 560 nativeShapeData.MeshKey = (ulong)shapeKey;
556 nativeShapeData.HullKey = (ulong)shapeKey; 561 nativeShapeData.HullKey = (ulong)shapeKey;
557 562
@@ -566,8 +571,6 @@ public sealed class BSShapeCollection : IDisposable
566 else 571 else
567 { 572 {
568 // Native shapes are scaled in Bullet so set the scaling to the size 573 // Native shapes are scaled in Bullet so set the scaling to the size
569 prim.Scale = prim.Size;
570 nativeShapeData.Scale = prim.Scale;
571 newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType); 574 newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType);
572 } 575 }
573 if (newShape.ptr == IntPtr.Zero) 576 if (newShape.ptr == IntPtr.Zero)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
index d51003c..a2161c3 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
@@ -5,6 +5,9 @@ CRASHES
520121128.1600: mesh object not rezzing (no physics mesh). 520121128.1600: mesh object not rezzing (no physics mesh).
6 Causes many errors. Doesn't stop after first error with box shape. 6 Causes many errors. Doesn't stop after first error with box shape.
7 Eventually crashes when deleting the object. 7 Eventually crashes when deleting the object.
820121206.1434: rez Sam-pan into OSGrid BulletSim11 region
9 Immediate simulator crash. Mono does not output any stacktrace and
10 log just stops after reporting taint-time linking of the linkset.
8 11
9VEHICLES TODO LIST: 12VEHICLES TODO LIST:
10================================================= 13=================================================
@@ -23,9 +26,12 @@ After getting off a vehicle, the root prim is phantom (can be walked through)
23Linkset explosion after three "rides" on Nebadon lite vehicle (LinksetConstraint) 26Linkset explosion after three "rides" on Nebadon lite vehicle (LinksetConstraint)
24Implement referenceFrame for all the motion routines. 27Implement referenceFrame for all the motion routines.
25Cannot edit/move a vehicle being ridden: it jumps back to the origional position. 28Cannot edit/move a vehicle being ridden: it jumps back to the origional position.
29Border crossing with linked vehicle causes crash
26 30
27BULLETSIM TODO LIST: 31BULLETSIM TODO LIST:
28================================================= 32=================================================
33Duplicating a physical prim causes old prim to jump away
34 Dup a phys prim and the original become unselected and thus interacts w/ selected prim.
29Disable activity of passive linkset children. 35Disable activity of passive linkset children.
30 Since the linkset is a compound object, the old prims are left lying 36 Since the linkset is a compound object, the old prims are left lying
31 around and need to be phantomized so they don't collide, ... 37 around and need to be phantomized so they don't collide, ...
@@ -96,7 +102,7 @@ Breakout code for mesh/hull/compound/native into separate BSShape* classes
96Generalize Dynamics and PID with standardized motors. 102Generalize Dynamics and PID with standardized motors.
97Generalize Linkset and vehicles into PropertyManagers 103Generalize Linkset and vehicles into PropertyManagers
98 Methods for Refresh, RemoveBodyDependencies, RestoreBodyDependencies 104 Methods for Refresh, RemoveBodyDependencies, RestoreBodyDependencies
99 Possibly generalized a 'pre step action' registration. 105 Potentially add events for shape destruction, etc.
100Complete implemention of preStepActions 106Complete implemention of preStepActions
101 Replace vehicle step call with prestep event. 107 Replace vehicle step call with prestep event.
102 Is there a need for postStepActions? postStepTaints? 108 Is there a need for postStepActions? postStepTaints?
diff --git a/OpenSim/Server/Base/CommandManager.cs b/OpenSim/Server/Base/CommandManager.cs
new file mode 100644
index 0000000..bd18485
--- /dev/null
+++ b/OpenSim/Server/Base/CommandManager.cs
@@ -0,0 +1,359 @@
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
29using System;
30using System.Text;
31using System.Linq;
32using System.Collections;
33using System.Collections.Generic;
34using System.Collections.ObjectModel;
35using Mono.Addins.Setup;
36using Mono.Addins;
37using Mono.Addins.Description;
38using OpenSim.Framework;
39
40namespace OpenSim.Server.Base
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>
48 public class CommandManager
49 {
50 public AddinRegistry PluginRegistry;
51 protected PluginManager PluginManager;
52
53 public CommandManager(AddinRegistry registry)
54 {
55 PluginRegistry = registry;
56 PluginManager = new PluginManager(PluginRegistry);
57 AddManagementCommands();
58 }
59
60 private void AddManagementCommands()
61 {
62 // add plugin
63 MainConsole.Instance.Commands.AddCommand("Plugin", true,
64 "plugin add", "plugin add \"plugin index\"",
65 "Install plugin from repository.",
66 HandleConsoleInstallPlugin);
67
68 // remove plugin
69 MainConsole.Instance.Commands.AddCommand("Plugin", true,
70 "plugin remove", "plugin remove \"plugin index\"",
71 "Remove plugin from repository",
72 HandleConsoleUnInstallPlugin);
73
74 // list installed plugins
75 MainConsole.Instance.Commands.AddCommand("Plugin", true,
76 "plugin list installed",
77 "plugin list installed","List install plugins",
78 HandleConsoleListInstalledPlugin);
79
80 // list plugins available from registered repositories
81 MainConsole.Instance.Commands.AddCommand("Plugin", true,
82 "plugin list available",
83 "plugin list available","List available plugins",
84 HandleConsoleListAvailablePlugin);
85 // List available updates
86 MainConsole.Instance.Commands.AddCommand("Plugin", true,
87 "plugin updates", "plugin updates","List availble updates",
88 HandleConsoleListUpdates);
89
90 // Update plugin
91 MainConsole.Instance.Commands.AddCommand("Plugin", true,
92 "plugin update", "plugin update \"plugin index\"","Update the plugin",
93 HandleConsoleUpdatePlugin);
94
95 // Add repository
96 MainConsole.Instance.Commands.AddCommand("Repository", true,
97 "repo add", "repo add \"url\"","Add repository",
98 HandleConsoleAddRepo);
99
100 // Refresh repo
101 MainConsole.Instance.Commands.AddCommand("Repository", true,
102 "repo refresh", "repo refresh \"url\"", "Sync with a registered repository",
103 HandleConsoleGetRepo);
104
105 // Remove repository from registry
106 MainConsole.Instance.Commands.AddCommand("Repository", true,
107 "repo remove",
108 "repo remove \"[url | index]\"",
109 "Remove repository from registry",
110 HandleConsoleRemoveRepo);
111
112 // Enable repo
113 MainConsole.Instance.Commands.AddCommand("Repository", true,
114 "repo enable", "repo enable \"[url | index]\"",
115 "Enable registered repository",
116 HandleConsoleEnableRepo);
117
118 // Disable repo
119 MainConsole.Instance.Commands.AddCommand("Repository", true,
120 "repo disable", "repo disable\"[url | index]\"",
121 "Disable registered repository",
122 HandleConsoleDisableRepo);
123
124 // List registered repositories
125 MainConsole.Instance.Commands.AddCommand("Repository", true,
126 "repo list", "repo list",
127 "List registered repositories",
128 HandleConsoleListRepos);
129
130 // *
131 MainConsole.Instance.Commands.AddCommand("Plugin", true,
132 "plugin info", "plugin info \"plugin index\"","Show detailed information for plugin",
133 HandleConsoleShowAddinInfo);
134
135 // Plugin disable
136 MainConsole.Instance.Commands.AddCommand("Plugin", true,
137 "plugin disable", "plugin disable \"plugin index\"",
138 "Disable a plugin",
139 HandleConsoleDisablePlugin);
140
141 // Enable plugin
142 MainConsole.Instance.Commands.AddCommand("Plugin", true,
143 "plugin enable", "plugin enable \"plugin index\"",
144 "Enable the selected plugin plugin",
145 HandleConsoleEnablePlugin);
146 }
147
148 #region console handlers
149 // Handle our console commands
150 //
151 // Install plugin from registered repository
152 /// <summary>
153 /// Handles the console install plugin command. Attempts to install the selected plugin
154 /// and
155 /// </summary>
156 /// <param name='module'>
157 /// Module.
158 /// </param>
159 /// <param name='cmd'>
160 /// Cmd.
161 /// </param>
162 private void HandleConsoleInstallPlugin(string module, string[] cmd)
163 {
164 Dictionary<string, object> result = new Dictionary<string, object>();
165
166 if (cmd.Length == 3)
167 {
168 int ndx = Convert.ToInt16(cmd[2]);
169 if (PluginManager.InstallPlugin(ndx, out result) == true)
170 {
171 ArrayList s = new ArrayList();
172 s.AddRange(result.Keys);
173 s.Sort();
174
175 var list = result.Keys.ToList();
176 list.Sort();
177 foreach (var k in list)
178 {
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}",
182 k,
183 enabled == true ? "[ ]" : "[X]",
184 plugin["name"], plugin["version"]);
185 }
186 }
187 }
188 return;
189 }
190
191 // Remove installed plugin
192 private void HandleConsoleUnInstallPlugin(string module, string[] cmd)
193 {
194 if (cmd.Length == 3)
195 {
196 int ndx = Convert.ToInt16(cmd[2]);
197 PluginManager.UnInstall(ndx);
198 }
199 return;
200 }
201
202 // List installed plugins
203 private void HandleConsoleListInstalledPlugin(string module, string[] cmd)
204 {
205 Dictionary<string, object> result = new Dictionary<string, object>();
206 PluginManager.ListInstalledAddins(out result);
207
208 ArrayList s = new ArrayList();
209 s.AddRange(result.Keys);
210 s.Sort();
211
212 var list = result.Keys.ToList();
213 list.Sort();
214 foreach (var k in list)
215 {
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}",
219 k,
220 enabled == true ? "[ ]" : "[X]",
221 plugin["name"], plugin["version"]);
222 }
223 return;
224 }
225
226 // List available plugins on registered repositories
227 private void HandleConsoleListAvailablePlugin(string module, string[] cmd)
228 {
229 Dictionary<string, object> result = new Dictionary<string, object>();
230 PluginManager.ListAvailable(out result);
231
232 var list = result.Keys.ToList();
233 list.Sort();
234 foreach (var k in list)
235 {
236 // name, version, repository
237 Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
238 MainConsole.Instance.OutputFormat("{0}) {1} rev. {2} {3}",
239 k,
240 plugin["name"],
241 plugin["version"],
242 plugin["repository"]);
243 }
244 return;
245 }
246
247 // List available updates **not ready
248 private void HandleConsoleListUpdates(string module, string[] cmd)
249 {
250 PluginManager.ListUpdates();
251 return;
252 }
253
254 // Update plugin **not ready
255 private void HandleConsoleUpdatePlugin(string module, string[] cmd)
256 {
257 MainConsole.Instance.Output(PluginManager.Update());
258 return;
259 }
260
261 // Register repository
262 private void HandleConsoleAddRepo(string module, string[] cmd)
263 {
264 if ( cmd.Length == 3)
265 {
266 PluginManager.AddRepository(cmd[2]);
267 }
268 return;
269 }
270
271 // Get repository status **not working
272 private void HandleConsoleGetRepo(string module, string[] cmd)
273 {
274 PluginManager.GetRepository();
275 return;
276 }
277
278 // Remove registered repository
279 private void HandleConsoleRemoveRepo(string module, string[] cmd)
280 {
281 if (cmd.Length == 3)
282 PluginManager.RemoveRepository(cmd);
283 return;
284 }
285
286 // Enable repository
287 private void HandleConsoleEnableRepo(string module, string[] cmd)
288 {
289 PluginManager.EnableRepository(cmd);
290 return;
291 }
292
293 // Disable repository
294 private void HandleConsoleDisableRepo(string module, string[] cmd)
295 {
296 PluginManager.DisableRepository(cmd);
297 return;
298 }
299
300 // List repositories
301 private void HandleConsoleListRepos(string module, string[] cmd)
302 {
303 Dictionary<string, object> result = new Dictionary<string, object>();
304 PluginManager.ListRepositories(out result);
305
306 var list = result.Keys.ToList();
307 list.Sort();
308 foreach (var k in list)
309 {
310 Dictionary<string, object> repo = (Dictionary<string, object>)result[k];
311 bool enabled = (bool)repo["enabled"];
312 MainConsole.Instance.OutputFormat("{0}) {1} {2}",
313 k,
314 enabled == true ? "[ ]" : "[X]",
315 repo["name"], repo["url"]);
316 }
317
318 return;
319 }
320
321 // Show description information
322 private void HandleConsoleShowAddinInfo(string module, string[] cmd)
323 {
324 if (cmd.Length >= 3)
325 {
326
327 Dictionary<string, object> result = new Dictionary<string, object>();
328
329 int ndx = Convert.ToInt16(cmd[2]);
330 PluginManager.AddinInfo(ndx, out result);
331
332 MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\nFile: {2}\nAuthor: {3}\nCategory: {4}\nDesc: {5}",
333 result["name"],
334 result["url"],
335 result["file_name"],
336 result["author"],
337 result["category"],
338 result["description"]);
339
340 return;
341 }
342 }
343
344 // Disable plugin
345 private void HandleConsoleDisablePlugin(string module, string[] cmd)
346 {
347 PluginManager.DisablePlugin(cmd);
348 return;
349 }
350
351 // Enable plugin
352 private void HandleConsoleEnablePlugin(string module, string[] cmd)
353 {
354 PluginManager.EnablePlugin(cmd);
355 return;
356 }
357 #endregion
358 }
359} \ No newline at end of file
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 42c82cf..31b0446 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -33,11 +33,137 @@ using System.Xml.Serialization;
33using System.Text; 33using System.Text;
34using System.Collections.Generic; 34using System.Collections.Generic;
35using log4net; 35using log4net;
36using Nini.Config;
36using OpenSim.Framework; 37using OpenSim.Framework;
37using OpenMetaverse; 38using OpenMetaverse;
39using Mono.Addins;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Framework.Servers;
38 42
43
44[assembly:AddinRoot("Robust", "0.1")]
39namespace OpenSim.Server.Base 45namespace 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 void Unload();
69 }
70
71 public class PluginLoader
72 {
73 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
74
75 public AddinRegistry Registry
76 {
77 get;
78 private set;
79 }
80
81 public IConfigSource Config
82 {
83 get;
84 private set;
85 }
86
87 public PluginLoader(IConfigSource config, string registryPath)
88 {
89 Config = config;
90
91 Registry = new AddinRegistry(registryPath, ".");
92 AddinManager.Initialize(registryPath);
93 AddinManager.Registry.Update();
94 CommandManager commandmanager = new CommandManager(Registry);
95 AddinManager.AddExtensionNodeHandler("/Robust/Connector", OnExtensionChanged);
96 }
97
98 private void OnExtensionChanged(object s, ExtensionNodeEventArgs args)
99 {
100 IRobustConnector connector = (IRobustConnector)args.ExtensionObject;
101 Addin a = Registry.GetAddin(args.ExtensionNode.Addin.Id);
102
103 if(a == null)
104 {
105 Registry.Rebuild(null);
106 a = Registry.GetAddin(args.ExtensionNode.Addin.Id);
107 }
108
109 switch(args.Change)
110 {
111 case ExtensionChange.Add:
112 if (a.AddinFile.Contains(Registry.DefaultAddinsFolder))
113 {
114 m_log.InfoFormat("[SERVER]: Adding {0} from registry", a.Name);
115 connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.'));
116 }
117 else
118 {
119 m_log.InfoFormat("[SERVER]: Adding {0} from ./bin", a.Name);
120 connector.PluginPath = a.AddinFile;
121 }
122 LoadPlugin(connector);
123 break;
124 case ExtensionChange.Remove:
125 m_log.InfoFormat("[SERVER]: Removing {0}", a.Name);
126 UnloadPlugin(connector);
127 break;
128 }
129 }
130
131 private void LoadPlugin(IRobustConnector connector)
132 {
133 IHttpServer server = null;
134 uint port = connector.Configure(Config);
135
136 if(connector.Enabled)
137 {
138 server = GetServer(connector, port);
139 connector.Initialize(server);
140 }
141 else
142 {
143 m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName);
144 }
145 }
146
147 private void UnloadPlugin(IRobustConnector connector)
148 {
149 m_log.InfoFormat("[Server]: Unloading {0}", connector.ConfigName);
150
151 connector.Unload();
152 }
153
154 private IHttpServer GetServer(IRobustConnector connector, uint port)
155 {
156 IHttpServer server;
157
158 if(port != 0)
159 server = MainServer.GetHttpServer(port);
160 else
161 server = MainServer.Instance;
162
163 return server;
164 }
165 }
166
41 public static class ServerUtils 167 public static class ServerUtils
42 { 168 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 169 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -333,5 +459,42 @@ namespace OpenSim.Server.Base
333 459
334 return ret; 460 return ret;
335 } 461 }
462
463 public static IConfig GetConfig(string configFile, string configName)
464 {
465 IConfig config;
466
467 if (File.Exists(configFile))
468 {
469 IConfigSource configsource = new IniConfigSource(configFile);
470 config = configsource.Configs[configName];
471 }
472 else
473 config = null;
474
475 return config;
476 }
477
478 public static IConfigSource LoadInitialConfig(string url)
479 {
480 IConfigSource source = new XmlConfigSource();
481 m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url);
482
483 // The ini file path is a http URI
484 // Try to read it
485 try
486 {
487 XmlReader r = XmlReader.Create(url);
488 IConfigSource cs = new XmlConfigSource(r);
489 source.Merge(cs);
490 }
491 catch (Exception e)
492 {
493 m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url);
494 Environment.Exit(1);
495 }
496
497 return source;
498 }
336 } 499 }
337} 500}
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 5b23149..ecd69b0 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -56,6 +56,12 @@ namespace OpenSim.Server.Base
56 // 56 //
57 protected string[] m_Arguments; 57 protected string[] m_Arguments;
58 58
59 public string ConfigDirectory
60 {
61 get;
62 private set;
63 }
64
59 // Run flag 65 // Run flag
60 // 66 //
61 private bool m_Running = true; 67 private bool m_Running = true;
@@ -134,6 +140,8 @@ namespace OpenSim.Server.Base
134 startupConfig = Config.Configs["Startup"]; 140 startupConfig = Config.Configs["Startup"];
135 } 141 }
136 142
143 ConfigDirectory = startupConfig.GetString("ConfigDirectory", ".");
144
137 prompt = startupConfig.GetString("Prompt", prompt); 145 prompt = startupConfig.GetString("Prompt", prompt);
138 146
139 // Allow derived classes to load config before the console is 147 // Allow derived classes to load config before the console is
@@ -242,4 +250,4 @@ namespace OpenSim.Server.Base
242 { 250 {
243 } 251 }
244 } 252 }
245} \ No newline at end of file 253}
diff --git a/OpenSim/Server/Handlers/Base/ServerConnector.cs b/OpenSim/Server/Handlers/Base/ServerConnector.cs
index 71876da..72014db 100644
--- a/OpenSim/Server/Handlers/Base/ServerConnector.cs
+++ b/OpenSim/Server/Handlers/Base/ServerConnector.cs
@@ -39,8 +39,75 @@ 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 { return String.Empty; }
45 }
46
47 public virtual string ConfigName
48 {
49 get;
50 protected set;
51 }
52
53 public virtual string ConfigFile
54 {
55 get;
56 protected set;
57 }
58
59 public virtual IConfigSource Config
60 {
61 get;
62 protected set;
63 }
64
65 public ServiceConnector()
66 {
67 }
68
42 public ServiceConnector(IConfigSource config, IHttpServer server, string configName) 69 public ServiceConnector(IConfigSource config, IHttpServer server, string configName)
43 { 70 {
44 } 71 }
72
73 // We call this from our plugin module to get our configuration
74 public IConfig GetConfig()
75 {
76 IConfig config = null;
77 config = ServerUtils.GetConfig(ConfigFile, ConfigName);
78
79 // Our file is not here? We can get one to bootstrap our plugin module
80 if ( config == null )
81 {
82 IConfigSource remotesource = GetConfigSource();
83
84 if (remotesource != null)
85 {
86 IniConfigSource initialconfig = new IniConfigSource();
87 initialconfig.Merge (remotesource);
88 initialconfig.Save(ConfigFile);
89 }
90
91 config = remotesource.Configs[ConfigName];
92 }
93
94 return config;
95 }
96
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.
101 private IConfigSource GetConfigSource()
102 {
103 IConfigSource source = null;
104
105 source = ServerUtils.LoadInitialConfig(ConfigURL);
106
107 if (source == null)
108 System.Console.WriteLine(String.Format ("Config Url: {0} Not found!", ConfigURL));
109
110 return source;
111 }
45 } 112 }
46} 113}
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index 45c13fb..8be69a9 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework.Servers;
34using OpenSim.Framework.Servers.HttpServer; 34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Server.Base; 35using OpenSim.Server.Base;
36using OpenSim.Server.Handlers.Base; 36using OpenSim.Server.Handlers.Base;
37using Mono.Addins;
37 38
38namespace OpenSim.Server 39namespace 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)
@@ -141,6 +148,9 @@ namespace OpenSim.Server
141 m_log.InfoFormat("[SERVER]: Failed to load {0}", conn); 148 m_log.InfoFormat("[SERVER]: Failed to load {0}", conn);
142 } 149 }
143 } 150 }
151
152 loader = new PluginLoader(m_Server.Config, registryLocation);
153
144 int res = m_Server.Run(); 154 int res = m_Server.Run();
145 155
146 Environment.Exit(res); 156 Environment.Exit(res);
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 508baf7..ef2494a 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -315,7 +315,7 @@ namespace OpenSim.Services.Connectors.Simulation
315 315
316 try 316 try
317 { 317 {
318 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000, false); 318 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false);
319 bool success = result["success"].AsBoolean(); 319 bool success = result["success"].AsBoolean();
320 if (result.ContainsKey("_Result")) 320 if (result.ContainsKey("_Result"))
321 { 321 {