OSDN Git Service

Added parcelinfo command.
authorLatif Khalifa <latifer@streamgrid.net>
Sat, 12 Sep 2009 19:03:35 +0000 (19:03 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Sat, 12 Sep 2009 19:03:35 +0000 (19:03 +0000)
Made RadegastCommand.Dispose virtual

git-svn-id: https://radegast.googlecode.com/svn/trunk@228 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/Core/Commands/ParcelInfoCommand.cs [new file with mode: 0644]
Radegast/Core/Commands/RadegastCommand.cs

diff --git a/Radegast/Core/Commands/ParcelInfoCommand.cs b/Radegast/Core/Commands/ParcelInfoCommand.cs
new file mode 100644 (file)
index 0000000..af2f97d
--- /dev/null
@@ -0,0 +1,102 @@
+// \r
+// Radegast Metaverse Client\r
+// Copyright (c) 2009, Radegast Development Team\r
+// All rights reserved.\r
+// \r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are met:\r
+// \r
+//     * Redistributions of source code must retain the above copyright notice,\r
+//       this list of conditions and the following disclaimer.\r
+//     * Redistributions in binary form must reproduce the above copyright\r
+//       notice, this list of conditions and the following disclaimer in the\r
+//       documentation and/or other materials provided with the distribution.\r
+//     * Neither the name of the application "Radegast", nor the names of its\r
+//       contributors may be used to endorse or promote products derived from\r
+//       this software without specific prior written permission.\r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+//\r
+// $Id: CommandsManager.cs 226 2009-09-12 18:10:30Z logicmoo $\r
+//\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Threading;\r
+using System.Text;\r
+using OpenMetaverse;\r
+\r
+namespace Radegast.Commands\r
+{\r
+    public class ParcelInfoCommand : RadegastCommand\r
+    {\r
+        private ManualResetEvent ParcelsDownloaded = new ManualResetEvent(false);\r
+\r
+        public ParcelInfoCommand(RadegastInstance instance)\r
+            : base(instance)\r
+        {\r
+            Name = "parcelinfo";\r
+            Description = "Prints out info about all the parcels in this simulator";\r
+            Usage = Name;\r
+\r
+            Client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(Network_OnDisconnected);\r
+        }\r
+\r
+        public override void Dispose()\r
+        {\r
+            base.Dispose();\r
+            Client.Network.OnDisconnected -= new NetworkManager.DisconnectedCallback(Network_OnDisconnected);\r
+        }\r
+\r
+        public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine)\r
+        {\r
+            StringBuilder sb = new StringBuilder();\r
+            string result;\r
+\r
+            ParcelManager.SimParcelsDownloaded del = delegate(Simulator simulator, InternalDictionary<int, Parcel> simParcels, int[,] parcelMap)\r
+            {\r
+                ParcelsDownloaded.Set();\r
+            };\r
+\r
+            ParcelsDownloaded.Reset();\r
+            Client.Parcels.OnSimParcelsDownloaded += del;\r
+            Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim);\r
+\r
+            if (Client.Network.CurrentSim.IsParcelMapFull())\r
+                ParcelsDownloaded.Set();\r
+\r
+            if (ParcelsDownloaded.WaitOne(30000, false) && Client.Network.Connected)\r
+            {\r
+                sb.AppendFormat("Downloaded {0} Parcels in {1} " + System.Environment.NewLine,\r
+                    Client.Network.CurrentSim.Parcels.Count, Client.Network.CurrentSim.Name);\r
+\r
+                Client.Network.CurrentSim.Parcels.ForEach(delegate(Parcel parcel)\r
+                {\r
+                    sb.AppendFormat("Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" + System.Environment.NewLine,\r
+                        parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessBlackList.Count, parcel.Dwell, parcel.AccessWhiteList.Count);\r
+                });\r
+\r
+                result = sb.ToString();\r
+            }\r
+            else\r
+                result = "Failed to retrieve information on all the simulator parcels";\r
+\r
+            Client.Parcels.OnSimParcelsDownloaded -= del;\r
+\r
+            WriteLine("Parcel Infro results:\n{0}", result);\r
+        }\r
+\r
+        void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)\r
+        {\r
+            ParcelsDownloaded.Set();\r
+        }\r
+    }\r
+}\r
index 3f4a148..fbab7e4 100644 (file)
@@ -84,7 +84,7 @@ namespace Radegast.Commands
         }\r
 \r
         // maybe we shoould make this class abstract to force people to implement\r
-        public void Dispose()\r
+        virtual public void Dispose()\r
         {\r
         }\r
 \r