From 380f59d0ffc3a1ec8cc20972b2475faf76f341fb Mon Sep 17 00:00:00 2001
From: diva
Date: Sun, 14 Jun 2009 23:00:23 +0000
Subject: Factoring out "land_data" / RequestLandData that was hanging off of
 IGridServices, erroneously. Not sure when this is used, but now it is
 implemented in the new model of service connectors. Hopefully it works.

---
 .../Region/Communications/OGS1/OGS1GridServices.cs |   4 +-
 .../Resources/CoreModulePlugin.addin.xml           |   2 +
 .../Land/LocalLandServiceConnector.cs              | 135 ++++++++++++++++++++
 .../Land/RemoteLandServiceConnector.cs             | 116 +++++++++++++++++
 .../Neighbour/RemoteNeighourServiceConnector.cs    |   2 +-
 OpenSim/Server/Handlers/Land/LandHandlers.cs       |  94 ++++++++++++++
 .../Server/Handlers/Land/LandServiceInConnector.cs |  66 ++++++++++
 .../Connectors/Land/LandServiceConnector.cs        | 125 +++++++++++++++++++
 OpenSim/Services/Interfaces/ILandService.cs        |  38 ++++++
 .../LandServiceInConnectorModule.cs                | 137 +++++++++++++++++++++
 .../Resources/SimulatorServices.addin.xml          |   1 +
 bin/config-include/Grid.ini                        |   2 +-
 bin/config-include/GridHypergrid.ini               |   1 +
 13 files changed, 720 insertions(+), 3 deletions(-)
 create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs
 create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
 create mode 100644 OpenSim/Server/Handlers/Land/LandHandlers.cs
 create mode 100644 OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
 create mode 100644 OpenSim/Services/Connectors/Land/LandServiceConnector.cs
 create mode 100644 OpenSim/Services/Interfaces/ILandService.cs
 create mode 100644 OpenSim/SimulatorServices/LandServiceInConnectorModule.cs

diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index f82a6a1..a526bb2 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -94,7 +94,9 @@ namespace OpenSim.Region.Communications.OGS1
           //  httpServer.AddXmlRPCHandler("expect_user", ExpectUser);
           //  httpServer.AddXmlRPCHandler("logoff_user", LogOffUser);
             httpServer.AddXmlRPCHandler("check", PingCheckReply);
-            httpServer.AddXmlRPCHandler("land_data", LandData);
+
+            // Retired into the new service connectors, 6/14/09
+            //httpServer.AddXmlRPCHandler("land_data", LandData);
 
         }
 
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index d779f29..1c79bf4 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -28,6 +28,8 @@
         <RegionModule id="HGInventoryBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.HGInventoryBroker" />
         <RegionModule id="LocalNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.LocalNeighbourServicesConnector" />
         <RegionModule id="RemoteNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.RemoteNeighbourServicesConnector" />
+        <RegionModule id="LocalLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.LocalLandServicesConnector" />
+        <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" />
     </Extension>
 
     <Extension path = "/OpenSim/WindModule">
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs
new file mode 100644
index 0000000..a9d9663
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using Nini.Config;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using OpenSim.Framework;
+using OpenSim.Server.Base;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
+
+namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
+{
+    public class LocalLandServicesConnector :
+            ISharedRegionModule, ILandService
+    {
+        private static readonly ILog m_log =
+                LogManager.GetLogger(
+                MethodBase.GetCurrentMethod().DeclaringType);
+
+        private List<Scene> m_Scenes = new List<Scene>();
+
+        private bool m_Enabled = false;
+
+        public LocalLandServicesConnector()
+        {
+        }
+
+        public LocalLandServicesConnector(List<Scene> scenes)
+        {
+            m_Scenes = scenes;
+        }
+
+        #region ISharedRegionModule
+
+        public string Name
+        {
+            get { return "LocalLandServicesConnector"; }
+        }
+
+        public void Initialise(IConfigSource source)
+        {
+            IConfig moduleConfig = source.Configs["Modules"];
+            if (moduleConfig != null)
+            {
+                string name = moduleConfig.GetString("LandServices", this.Name);
+                if (name == Name)
+                {
+                    m_Enabled = true;
+                    m_log.Info("[LAND CONNECTOR]: Local land connector enabled");
+                }
+            }
+        }
+
+        public void Close()
+        {
+        }
+
+        public void AddRegion(Scene scene)
+        {
+            m_Scenes.Add(scene);
+
+            if (!m_Enabled)
+                return;
+
+            scene.RegisterModuleInterface<ILandService>(this);
+        }
+
+        public void RegionLoaded(Scene scene)
+        {
+        }
+
+        public void PostInitialise()
+        {
+        }
+
+        public void RemoveRegion(Scene scene)
+        {
+            if (m_Scenes.Contains(scene))
+                m_Scenes.Remove(scene);
+        }
+
+        #endregion ISharedRegionModule
+
+        #region ILandService
+
+        public LandData GetLandData(ulong regionHandle, uint x, uint y)
+        {
+            m_log.DebugFormat("[LAND CONNECTOR]: request for land data in {0} at {1}, {2}",
+                  regionHandle, x, y);
+
+            foreach (Scene s in m_Scenes)
+            {
+                if (s.RegionInfo.RegionHandle == regionHandle)
+                {
+                    LandData land = s.GetLandData(x, y);
+                    return land;
+                }
+            }
+
+            m_log.Debug("[LAND CONNECTOR]: didn't find land data locally.");
+            return null;
+
+        }
+
+        #endregion ILandService
+    }
+}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
new file mode 100644
index 0000000..f64a1ce
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Services.Connectors;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
+using OpenSim.Server.Base;
+
+namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
+{
+    public class RemoteLandServicesConnector :
+            LandServicesConnector, ISharedRegionModule, ILandService
+    {
+        private static readonly ILog m_log =
+                LogManager.GetLogger(
+                MethodBase.GetCurrentMethod().DeclaringType);
+
+        private bool m_Enabled = false;
+        private LocalLandServicesConnector m_LocalService;
+
+        public string Name
+        {
+            get { return "RemoteLandServicesConnector"; }
+        }
+
+        public void Initialise(IConfigSource source)
+        {
+            IConfig moduleConfig = source.Configs["Modules"];
+            if (moduleConfig != null)
+            {
+                string name = moduleConfig.GetString("LandServices", "");
+                if (name == Name)
+                {
+                    m_LocalService = new LocalLandServicesConnector();
+
+                    m_Enabled = true;
+
+                    m_log.Info("[LAND CONNECTOR]: Remote Land connector enabled");
+                }
+            }
+        }
+
+        public void PostInitialise()
+        {
+        }
+
+        public void Close()
+        {
+        }
+
+        public void AddRegion(Scene scene)
+        {
+            if (!m_Enabled)
+                return;
+
+            m_MapService = scene.CommsManager.GridService;
+            m_LocalService.AddRegion(scene);
+            scene.RegisterModuleInterface<ILandService>(this);
+        }
+
+        public void RemoveRegion(Scene scene)
+        {
+            if (m_Enabled)
+                m_LocalService.RemoveRegion(scene);
+        }
+
+        public void RegionLoaded(Scene scene)
+        {
+        }
+
+
+        #region ILandService
+
+        public override LandData GetLandData(ulong regionHandle, uint x, uint y)
+        {
+            LandData land = m_LocalService.GetLandData(regionHandle, x, y);
+            if (land != null)
+                return land;
+
+            return base.GetLandData(regionHandle, x, y);
+
+        }
+        #endregion ILandService
+    }
+}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
index d584a98..dc876e3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
@@ -120,7 +120,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
 
         public void RemoveRegion(Scene scene)
         {
-            if (m_Enabled && m_Scenes.Contains(scene))
+            if (m_Enabled)
                 m_LocalService.RemoveRegion(scene);
         }
 
diff --git a/OpenSim/Server/Handlers/Land/LandHandlers.cs b/OpenSim/Server/Handlers/Land/LandHandlers.cs
new file mode 100644
index 0000000..b15d7f6
--- /dev/null
+++ b/OpenSim/Server/Handlers/Land/LandHandlers.cs
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Net;
+using System.Text;
+
+using OpenSim.Server.Base;
+using OpenSim.Server.Handlers.Base;
+using OpenSim.Services.Interfaces;
+using OpenSim.Framework;
+using OpenSim.Framework.Servers.HttpServer;
+
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+using Nwc.XmlRpc;
+using Nini.Config;
+using log4net;
+
+
+namespace OpenSim.Server.Handlers.Land
+{
+    public class LandHandlers
+    {
+        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+        private ILandService m_LocalService;
+
+        public LandHandlers(ILandService service)
+        {
+            m_LocalService = service;
+        }
+
+        public XmlRpcResponse GetLandData(XmlRpcRequest request, IPEndPoint remoteClient)
+        {
+            Hashtable requestData = (Hashtable)request.Params[0];
+            ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
+            uint x = Convert.ToUInt32(requestData["x"]);
+            uint y = Convert.ToUInt32(requestData["y"]);
+            m_log.DebugFormat("[LAND HANDLER]: Got request for land data at {0}, {1} for region {2}", x, y, regionHandle);
+
+            LandData landData = m_LocalService.GetLandData(regionHandle, x, y);
+            Hashtable hash = new Hashtable();
+            if (landData != null)
+            {
+                // for now, only push out the data we need for answering a ParcelInfoReqeust
+                hash["AABBMax"] = landData.AABBMax.ToString();
+                hash["AABBMin"] = landData.AABBMin.ToString();
+                hash["Area"] = landData.Area.ToString();
+                hash["AuctionID"] = landData.AuctionID.ToString();
+                hash["Description"] = landData.Description;
+                hash["Flags"] = landData.Flags.ToString();
+                hash["GlobalID"] = landData.GlobalID.ToString();
+                hash["Name"] = landData.Name;
+                hash["OwnerID"] = landData.OwnerID.ToString();
+                hash["SalePrice"] = landData.SalePrice.ToString();
+                hash["SnapshotID"] = landData.SnapshotID.ToString();
+                hash["UserLocation"] = landData.UserLocation.ToString();
+            }
+
+            XmlRpcResponse response = new XmlRpcResponse();
+            response.Value = hash;
+            return response;
+        }
+    }
+
+}
diff --git a/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs b/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
new file mode 100644
index 0000000..f550b10
--- /dev/null
+++ b/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using log4net;
+using Nini.Config;
+using OpenSim.Server.Base;
+using OpenSim.Services.Interfaces;
+using OpenSim.Framework;
+using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Server.Handlers.Base;
+
+namespace OpenSim.Server.Handlers.Land
+{
+    public class LandServiceInConnector : ServiceConnector
+    {
+        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+        private ILandService m_LandService;
+        // TODO : private IAuthenticationService m_AuthenticationService;
+
+        public LandServiceInConnector(IConfigSource source, IHttpServer server, ILandService service, IScene scene) :
+                base(source, server)
+        {
+            m_LandService = service;
+            if (m_LandService == null)
+            {
+                m_log.Error("[LAND IN CONNECTOR]: Land service was not provided");
+                return;
+            }
+            
+            //bool authentication = neighbourConfig.GetBoolean("RequireAuthentication", false);
+            //if (authentication)
+            //    m_AuthenticationService = scene.RequestModuleInterface<IAuthenticationService>();
+
+            LandHandlers landHandlers = new LandHandlers(m_LandService);
+            server.AddXmlRPCHandler("land_data", landHandlers.GetLandData, false);
+        }
+    }
+}
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
new file mode 100644
index 0000000..e9375f5
--- /dev/null
+++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Services.Interfaces;
+using OpenMetaverse;
+using Nwc.XmlRpc;
+
+namespace OpenSim.Services.Connectors
+{
+    public class LandServicesConnector : ILandService
+    {
+        private static readonly ILog m_log =
+                LogManager.GetLogger(
+                MethodBase.GetCurrentMethod().DeclaringType);
+
+        protected IGridServices m_MapService = null;
+
+        public LandServicesConnector()
+        {
+        }
+
+        public LandServicesConnector(IGridServices gridServices)
+        {
+            Initialise(gridServices);
+        }
+
+        public virtual void Initialise(IGridServices gridServices)
+        {
+            m_MapService = gridServices;
+        }
+
+        public virtual LandData GetLandData(ulong regionHandle, uint x, uint y)
+        {
+            LandData landData = null;
+            Hashtable hash = new Hashtable();
+            hash["region_handle"] = regionHandle.ToString();
+            hash["x"] = x.ToString();
+            hash["y"] = y.ToString();
+
+            IList paramList = new ArrayList();
+            paramList.Add(hash);
+
+            try
+            {
+                RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle);
+                if (info != null) // just to be sure
+                {
+                    XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
+                    string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
+                    XmlRpcResponse response = request.Send(uri, 10000);
+                    if (response.IsFault)
+                    {
+                        m_log.ErrorFormat("[LAND CONNECTOR] remote call returned an error: {0}", response.FaultString);
+                    }
+                    else
+                    {
+                        hash = (Hashtable)response.Value;
+                        try
+                        {
+                            landData = new LandData();
+                            landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
+                            landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
+                            landData.Area = Convert.ToInt32(hash["Area"]);
+                            landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]);
+                            landData.Description = (string)hash["Description"];
+                            landData.Flags = Convert.ToUInt32(hash["Flags"]);
+                            landData.GlobalID = new UUID((string)hash["GlobalID"]);
+                            landData.Name = (string)hash["Name"];
+                            landData.OwnerID = new UUID((string)hash["OwnerID"]);
+                            landData.SalePrice = Convert.ToInt32(hash["SalePrice"]);
+                            landData.SnapshotID = new UUID((string)hash["SnapshotID"]);
+                            landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
+                            m_log.DebugFormat("[OGS1 GRID SERVICES] Got land data for parcel {0}", landData.Name);
+                        }
+                        catch (Exception e)
+                        {
+                            m_log.Error("[LAND CONNECTOR] Got exception while parsing land-data:", e);
+                        }
+                    }
+                }
+                else m_log.WarnFormat("[LAND CONNECTOR] Couldn't find region with handle {0}", regionHandle);
+            }
+            catch (Exception e)
+            {
+                m_log.ErrorFormat("[LAND CONNECTOR] Couldn't contact region {0}: {1}", regionHandle, e);
+            }
+        
+            return landData;
+        }
+    }
+}
diff --git a/OpenSim/Services/Interfaces/ILandService.cs b/OpenSim/Services/Interfaces/ILandService.cs
new file mode 100644
index 0000000..51cc93b
--- /dev/null
+++ b/OpenSim/Services/Interfaces/ILandService.cs
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using OpenSim.Framework;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Interfaces
+{
+    public interface ILandService
+    {
+        LandData GetLandData(ulong regionHandle, uint x, uint y);
+    }
+}
diff --git a/OpenSim/SimulatorServices/LandServiceInConnectorModule.cs b/OpenSim/SimulatorServices/LandServiceInConnectorModule.cs
new file mode 100644
index 0000000..58d276d
--- /dev/null
+++ b/OpenSim/SimulatorServices/LandServiceInConnectorModule.cs
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Reflection;
+using System.Collections.Generic;
+using log4net;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Server.Base;
+using OpenSim.Server.Handlers.Base;
+using OpenSim.Services.Interfaces;
+
+
+namespace OpenSim.SimulatorServices
+{
+    public class LandServiceInConnectorModule : ISharedRegionModule, ILandService
+    {
+        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+        private static bool m_Enabled = false;
+        private static bool m_Registered = false;
+
+        private IConfigSource m_Config;
+        private List<Scene> m_Scenes = new List<Scene>();
+
+        #region IRegionModule interface
+
+        public void Initialise(IConfigSource config)
+        {
+            m_Config = config;
+
+            IConfig moduleConfig = config.Configs["Modules"];
+            if (moduleConfig != null)
+            {
+                m_Enabled = moduleConfig.GetBoolean("LandServiceInConnector", false);
+                if (m_Enabled)
+                {
+                    m_log.Info("[LAND IN CONNECTOR]: LandServiceInConnector enabled");
+                }
+
+            }
+
+        }
+
+        public void PostInitialise()
+        {
+            if (!m_Enabled)
+                return;
+
+            m_log.Info("[LAND IN CONNECTOR]: Starting...");
+        }
+
+        public void Close()
+        {
+        }
+
+        public string Name
+        {
+            get { return "LandServiceInConnectorModule"; }
+        }
+
+        public void AddRegion(Scene scene)
+        {
+            if (!m_Enabled)
+                return;
+
+            if (!m_Registered)
+            {
+                m_Registered = true;
+                Object[] args = new Object[] { m_Config, scene.CommsManager.HttpServer, this, scene };
+                ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:LandServiceInConnector", args);
+            }
+
+            m_Scenes.Add(scene);
+
+        }
+
+        public void RemoveRegion(Scene scene)
+        {
+            if (m_Enabled && m_Scenes.Contains(scene))
+                m_Scenes.Remove(scene);
+        }
+
+        public void RegionLoaded(Scene scene)
+        {
+        }
+
+        #endregion
+
+        #region ILandService
+
+        public LandData GetLandData(ulong regionHandle, uint x, uint y)
+        {
+            m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {2}",
+                regionHandle, m_Scenes.Count);
+            foreach (Scene s in m_Scenes)
+            {
+                if (s.RegionInfo.RegionHandle == regionHandle)
+                {
+                    m_log.Debug("[LAND IN CONNECTOR]: Found region to GetLandData from");
+                    return s.GetLandData(x, y);
+                }
+            }
+            m_log.DebugFormat("[LAND IN CONNECTOR]: region handle {0} not found", regionHandle);
+            return null;
+        }
+
+        #endregion ILandService
+    }
+}
diff --git a/OpenSim/SimulatorServices/Resources/SimulatorServices.addin.xml b/OpenSim/SimulatorServices/Resources/SimulatorServices.addin.xml
index c83af7b..18b9423 100644
--- a/OpenSim/SimulatorServices/Resources/SimulatorServices.addin.xml
+++ b/OpenSim/SimulatorServices/Resources/SimulatorServices.addin.xml
@@ -11,6 +11,7 @@
         <RegionModule id="RegionAssetService" type="OpenSim.SimulatorServices.RegionAssetService" />
         <RegionModule id="RegionInventoryService" type="OpenSim.SimulatorServices.RegionInventoryService" />
         <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.SimulatorServices.NeighbourServiceInConnectorModule" />
+        <RegionModule id="LandServiceInConnectorModule" type="OpenSim.SimulatorServices.LandServiceInConnectorModule" />
     </Extension>
 
 </Addin>
diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini
index f9ded41..3b8f3a9 100644
--- a/bin/config-include/Grid.ini
+++ b/bin/config-include/Grid.ini
@@ -12,4 +12,4 @@
     InventoryServices = "RemoteInventoryServicesConnector"
     NeighbourServices = "RemoteNeighbourServicesConnector"
     NeighbourServiceInConnector = true
-
+    LandServiceInConnector = true
diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini
index fa3c4ed..4818fc8 100644
--- a/bin/config-include/GridHypergrid.ini
+++ b/bin/config-include/GridHypergrid.ini
@@ -12,6 +12,7 @@
     InventoryServices = "HGInventoryBroker"
     NeighbourServices = "RemoteNeighbourServicesConnector"
     NeighbourServiceInConnector = true
+    LandServiceInConnector = true
 
 
 [AssetService]
-- 
cgit v1.1