byte[] GetRegionsByName(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
            }

            string regionName = string.Empty;

            if (request.ContainsKey("NAME"))
            {
                regionName = request["NAME"].ToString();
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
            }

            int max = 0;

            if (request.ContainsKey("MAX"))
            {
                Int32.TryParse(request["MAX"].ToString(), out max);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
            }

            List <GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
            {
                result["result"] = "null";
            }
            else
            {
                int i = 0;
                foreach (GridRegion rinfo in rinfos)
                {
                    Dictionary <string, object> rinfoDict = rinfo.ToKeyValuePairs();
                    result["region" + i] = rinfoDict;
                    i++;
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        protected void HandleResetMainlandEstate(IScene scene, string [] cmd)
        {
            CheckSystemEstateInfo(Constants.MainlandEstateID, mainlandEstateName, (UUID)Constants.GovernorUUID);

            IGridService     gridService     = m_registry.RequestModuleInterface <IGridService> ();
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            var regions = gridService.GetRegionsByName(null, "", null, null);

            if (regions == null || regions.Count < 1)
            {
                return;
            }

            int updated = 0;

            foreach (var region in regions)
            {
                string regType = region.RegionType.ToLower();
                if (regType.StartsWith("m", StringComparison.Ordinal))
                {
                    estateConnector.LinkRegion(region.RegionID, Constants.MainlandEstateID);
                    updated++;
                }
            }

            if (updated > 0)
            {
                MainConsole.Instance.InfoFormat("Relinked {0} mainland regions", updated);
            }
        }
        public List <GridRegion> GetRegionsByURI(UUID scopeID, RegionURI uri, int maxNumber)
        {
            if (!uri.IsValid)
            {
                return(null);
            }

            List <GridRegion> rinfo = m_LocalGridService.GetRegionsByURI(scopeID, uri, maxNumber);

            //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count);

            if (m_RemoteGridService == null || !uri.IsLocalGrid)
            {
                return(rinfo);
            }

            List <GridRegion> grinfo = null;

            if (!uri.HasRegionName && (rinfo == null || rinfo.Count == 0))
            {
                List <GridRegion> grinfos = m_RemoteGridService.GetDefaultRegions(scopeID);
                if (grinfos == null || grinfos.Count == 0)
                {
                    m_log.Info("[REMOTE GRID CONNECTOR] returned no default regions");
                }
                else
                {
                    m_log.InfoFormat("[REMOTE GRID CONNECTOR] returned default regions {0}, ...", grinfos[0].RegionName);
                    // only return first
                    grinfo = new List <GridRegion>()
                    {
                        grinfos[0]
                    };
                }
            }
            else
            {
                grinfo = m_RemoteGridService.GetRegionsByName(scopeID, uri.RegionName, maxNumber);
            }

            if (grinfo != null)
            {
                //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionsByName {0} found {1} regions", name, grinfo.Count);
                foreach (GridRegion r in grinfo)
                {
                    m_RegionInfoCache.Cache(r);
                    if (rinfo.Find(delegate(GridRegion gr) { return(gr.RegionID == r.RegionID); }) == null)
                    {
                        rinfo.Add(r);
                    }
                }
            }

            return(rinfo);
        }
        public List <GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
        {
            List <GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber);
            //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count);

            // HG urls should not get here, strip them
            // side effect is that local regions with same name as HG may also be found
            // this mb good or bad
            string regionName = name;

            if (name.Contains("."))
            {
                if (string.IsNullOrWhiteSpace(m_ThisGatekeeperURI))
                {
                    return(rinfo); // no HG
                }
                string regionURI  = "";
                string regionHost = "";
                if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName))
                {
                    return(rinfo); // invalid
                }
                if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) && !m_ThisGatekeeperIP.Equals(regionHost))
                {
                    return(rinfo); // not local grid
                }
            }

            List <GridRegion> grinfo = null;

            if (String.IsNullOrEmpty(regionName))
            {
                grinfo = m_RemoteGridService.GetDefaultRegions(scopeID);
            }
            else
            {
                grinfo = m_RemoteGridService.GetRegionsByName(scopeID, regionName, maxNumber);
            }

            if (grinfo != null)
            {
                //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionsByName {0} found {1} regions", name, grinfo.Count);
                foreach (GridRegion r in grinfo)
                {
                    m_RegionInfoCache.Cache(r);
                    if (rinfo.Find(delegate(GridRegion gr) { return(gr.RegionID == r.RegionID); }) == null)
                    {
                        rinfo.Add(r);
                    }
                }
            }

            return(rinfo);
        }
Exemple #5
0
        public List <GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
        {
            List <GridRegion> r             = m_localService.GetRegionsByName(scopeID, name, maxNumber);
            List <GridRegion> remoteRegions = m_remoteService.GetRegionsByName(scopeID, name, maxNumber);

            UpdateGridRegionsForIWC(ref remoteRegions);
            r.AddRange(remoteRegions);
            //Sort to find the region with the exact name that was given
            r.Sort(new GridService.RegionDataComparison(name));
            //Results are backwards... so it needs reversed
            r.Reverse();
            return(r);
        }
        public GridRegion GetRegionForGrid(string regionName, string url)
        {
            bool found = Connections.Contains(url);

            if (found)
            {
                //If we are already connected, the grid services are together, so we already know of the region if it exists, therefore, it does not exist
                return(null);
            }
            else
            {
                //Be user friendly, add the http:// if needed as well as the final /
                url = (url.StartsWith("http://") || url.StartsWith("https://")) ? url : "http://" + url;
                url = url.EndsWith("/") ? url + "iwcconnection" : url + "/iwcconnection";
                bool success = this.OutgoingPublicComms.AttemptConnection(url);
                if (success)
                {
                    IGridService service = m_registry.RequestModuleInterface <IGridService>();
                    if (service != null)
                    {
                        List <GridRegion> regions = service.GetRegionsByName(UUID.Zero, regionName, 3);
#if (!ISWIN)
                        foreach (GridRegion t in regions)
                        {
                            if (t.RegionName == regionName)
                            {
                                return(t);
                            }
                        }
#else
                        foreach (GridRegion t in regions.Where(t => t.RegionName == regionName))
                        {
                            return(t);
                        }
#endif
                        if (regions.Count > 0)
                        {
                            return(regions[0]);
                        }
                    }
                }
            }
            return(null);
        }
Exemple #7
0
        public override List <GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
        {
            List <GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber);
            //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count);
            List <GridRegion> grinfo = base.GetRegionsByName(scopeID, name, maxNumber);

            if (grinfo != null)
            {
                //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionsByName {0} found {1} regions", name, grinfo.Count);
                foreach (GridRegion r in grinfo)
                {
                    if (rinfo.Find(delegate(GridRegion gr) { return(gr.RegionID == r.RegionID); }) == null)
                    {
                        rinfo.Add(r);
                    }
                }
            }

            return(rinfo);
        }
        public GridRegion GetRegionForGrid(string regionName, string Url)
        {
            IWCCertificate c = FindConnectionByURL(Url);

            if (c != null)
            {
                //If we are already connected, the grid services are together, so we already know of the region if it exists, therefore, it does not exist
                return(null);
            }
            else
            {
                c            = new IWCCertificate();
                c.Connection = new IWCConnection();
                //Build the certificate
                c.ValidUntil = DateTime.Now.AddDays(1);             //One day for now...

                c.ThreatLevel = m_untrustedConnectionsDefaultTrust; //Least amount of our trust for them
                //Be user friendly, add the http:// if needed as well as the final /
                Url = (Url.StartsWith("http://") || Url.StartsWith("https://")) ? Url : "http://" + Url;
                Url = Url.EndsWith("/") ? Url + "iwcconnection" : Url + "/iwcconnection";
                c.Connection.RecieverURL = Url;
                IHttpServer server = m_registry.RequestModuleInterface <ISimulationBase>().GetHttpServer(0);
                c.Connection.SenderURL = server.HostName + ":" + server.Port + "/iwcconnection";
                c.Connection.UserName  = c.Connection.SenderURL;

                //Add the certificate now
                CertificateVerification.AddCertificate(c);

                TryAddConnection(c);
                IGridService gridService = m_registry.RequestModuleInterface <IGridService>();
                if (gridService != null)
                {
                    List <GridRegion> regions = gridService.GetRegionsByName(UUID.Zero, regionName, 1);
                    if (regions != null && regions.Count > 0)
                    {
                        return(regions[0]);
                    }
                }
            }
            return(null);
        }
        protected GridRegion FindDestination(
            UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation,
            GridRegion home, out GridRegion gatekeeper,
            out string where, out Vector3 position, out Vector3 lookAt, out TeleportFlags flags)
        {
            flags = TeleportFlags.ViaLogin;

            m_log.DebugFormat(
                "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}",
                startLocation, account.Name);

            gatekeeper = null;
            where      = "home";
            position   = new Vector3(128, 128, 0);
            lookAt     = new Vector3(0, 1, 0);

            if (m_GridService == null)
            {
                return(null);
            }

            if (startLocation.Equals("home"))
            {
                // logging into home region
                if (pinfo == null)
                {
                    return(null);
                }

                GridRegion region = null;

                bool tryDefaults = false;

                if (home == null)
                {
                    tryDefaults = true;
                }
                else
                {
                    region = home;

                    position = pinfo.HomePosition;
                    lookAt   = pinfo.HomeLookAt;
                    flags   |= TeleportFlags.ViaHome;
                }

                if (tryDefaults)
                {
                    List <GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where  = "safe";
                    }
                    else
                    {
                        m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region",
                                         account.FirstName, account.LastName);
                        region = FindAlternativeRegion(scopeID);
                        if (region != null)
                        {
                            where = "safe";
                        }
                    }
                }

                return(region);
            }
            else if (startLocation.Equals("last"))
            {
                // logging into last visited region
                where = "last";

                if (pinfo == null)
                {
                    return(null);
                }

                GridRegion region = null;

                if (pinfo.LastRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.LastRegionID)) == null)
                {
                    List <GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where  = "safe";
                    }
                    else
                    {
                        m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
                        region = FindAlternativeRegion(scopeID);
                        if (region != null)
                        {
                            where = "safe";
                        }
                    }
                }
                else
                {
                    position = pinfo.LastPosition;
                    lookAt   = pinfo.LastLookAt;
                }

                return(region);
            }
            else
            {
                flags |= TeleportFlags.ViaRegionID;

                // free uri form
                // e.g. New Moon&135&46  New [email protected]:8002&153&34
                where = "url";
                GridRegion region   = null;
                Regex      reURI    = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
                Match      uriMatch = reURI.Match(startLocation);
                if (uriMatch == null)
                {
                    m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation);
                    return(null);
                }
                else
                {
                    position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo),
                                           float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo),
                                           float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo));

                    string regionName = uriMatch.Groups["region"].ToString();
                    if (regionName != null)
                    {
                        if (!regionName.Contains("@"))
                        {
                            List <GridRegion> regions = m_GridService.GetRegionsByName(scopeID, regionName, 1);
                            if ((regions == null) || (regions != null && regions.Count == 0))
                            {
                                m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName);
                                regions = m_GridService.GetDefaultRegions(scopeID);
                                if (regions != null && regions.Count > 0)
                                {
                                    where = "safe";
                                    return(regions[0]);
                                }
                                else
                                {
                                    m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
                                    region = FindAlternativeRegion(scopeID);
                                    if (region != null)
                                    {
                                        where = "safe";
                                        return(region);
                                    }
                                    else
                                    {
                                        m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not provide default regions and no alternative found.", startLocation);
                                        return(null);
                                    }
                                }
                            }
                            return(regions[0]);
                        }
                        else
                        {
                            if (m_UserAgentService == null)
                            {
                                m_log.WarnFormat("[LLLOGIN SERVICE]: This llogin service is not running a user agent service, as such it can't lauch agents at foreign grids");
                                return(null);
                            }
                            string[] parts = regionName.Split(new char[] { '@' });
                            if (parts.Length < 2)
                            {
                                m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName);
                                return(null);
                            }
                            // Valid specification of a remote grid

                            regionName = parts[0];
                            string domainLocator = parts[1];
                            parts = domainLocator.Split(new char[] { ':' });
                            string domainName = parts[0];
                            uint   port       = 0;
                            if (parts.Length > 1)
                            {
                                UInt32.TryParse(parts[1], out port);
                            }

                            region = FindForeignRegion(domainName, port, regionName, account, out gatekeeper);
                            return(region);
                        }
                    }
                    else
                    {
                        List <GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
                        if (defaults != null && defaults.Count > 0)
                        {
                            where = "safe";
                            return(defaults[0]);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                //response.LookAt = "[r0,r1,r0]";
                //// can be: last, home, safe, url
                //response.StartLocation = "url";
            }
        }
Exemple #10
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars        = new Dictionary <string, object>();
            var regionslist = new List <Dictionary <string, object> >();

            uint amountPerQuery = 10;

            if (requestParameters.ContainsKey("Submit"))
            {
                IGridService gridService = webInterface.Registry.RequestModuleInterface <IGridService>();
                string       regionname  = requestParameters["regionname"].ToString();
                int          start       = httpRequest.Query.ContainsKey("Start")
                                ? int.Parse(httpRequest.Query["Start"].ToString())
                                : 0;
                uint count    = gridService.GetRegionsByNameCount(null, regionname);
                int  maxPages = (int)(count / amountPerQuery) - 1;

                if (start == -1)
                {
                    start = (int)(maxPages < 0 ? 0 : maxPages);
                }

                vars.Add("CurrentPage", start);
                vars.Add("NextOne", start + 1 > maxPages ? start : start + 1);
                vars.Add("BackOne", start - 1 < 0 ? 0 : start - 1);

                var regions = gridService.GetRegionsByName(null, regionname, (uint)start, amountPerQuery);
                if (regions != null)
                {
                    foreach (var region in regions)
                    {
                        regionslist.Add(new Dictionary <string, object>
                        {
                            { "RegionName", region.RegionName },
                            { "RegionID", region.RegionID }
                        });
                    }
                }
            }
            else
            {
                vars.Add("CurrentPage", 0);
                vars.Add("NextOne", 0);
                vars.Add("BackOne", 0);
            }

            vars.Add("RegionsList", regionslist);
            vars.Add("RegionSearchText", translator.GetTranslatedString("RegionSearchText"));
            vars.Add("SearchForRegionText", translator.GetTranslatedString("SearchForRegionText"));
            vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText"));
            vars.Add("Search", translator.GetTranslatedString("Search"));

            vars.Add("FirstText", translator.GetTranslatedString("FirstText"));
            vars.Add("BackText", translator.GetTranslatedString("BackText"));
            vars.Add("NextText", translator.GetTranslatedString("NextText"));
            vars.Add("LastText", translator.GetTranslatedString("LastText"));
            vars.Add("CurrentPageText", translator.GetTranslatedString("CurrentPageText"));

            vars.Add("SearchResultForRegionText", translator.GetTranslatedString("SearchResultForRegionText"));
            vars.Add("RegionMoreInfo", translator.GetTranslatedString("RegionMoreInfo"));
            vars.Add("MoreInfoText", translator.GetTranslatedString("MoreInfoText"));

            return(vars);
        }
 public List <GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
 {
     return(m_GridService.GetRegionsByName(scopeID, name, maxNumber));
 }
Exemple #12
0
        private void OnMapNameRequestHandler(IClientAPI remoteClient, string mapName, uint flags)
        {
            if (m_gridservice == null)
            {
                return;
            }

            try
            {
                List <MapBlockData> blocks = new List <MapBlockData>();
                if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4))
                {
                    // final block, closing the search result
                    AddFinalBlock(blocks, mapName);

                    // flags are agent flags sent from the viewer.
                    // they have different values depending on different viewers, apparently
                    remoteClient.SendMapBlock(blocks, flags);
                    remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
                    return;
                }

                //m_log.DebugFormat("MAP NAME=({0})", mapName);
                string mapNameOrig      = mapName;
                int    indx             = mapName.IndexOfAny(new char[] { '.', '!', '+', '|', ':', '%' });
                bool   needOriginalName = indx >= 0;

                // try to fetch from GridServer
                List <GridRegion> regionInfos = m_gridservice.GetRegionsByName(m_stupidScope, mapName, 20);

                if (!remoteClient.IsActive)
                {
                    return;
                }

                //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);

                MapBlockData data;
                if (regionInfos != null && regionInfos.Count > 0)
                {
                    foreach (GridRegion info in regionInfos)
                    {
                        data        = new MapBlockData();
                        data.Agents = 0;
                        data.Access = info.Access;
                        MapBlockData block = new MapBlockData();
                        MapBlockFromGridRegion(block, info, flags);

                        if (needOriginalName && flags == 2 && regionInfos.Count == 1)
                        {
                            block.Name = mapNameOrig;
                        }
                        blocks.Add(block);
                    }
                }

                // final block, closing the search result
                AddFinalBlock(blocks, mapNameOrig);

                // flags are agent flags sent from the viewer.
                // they have different values depending on different viewers, apparently
                remoteClient.SendMapBlock(blocks, flags);

                // send extra user messages for V3
                // because the UI is very confusing
                // while we don't fix the hard-coded urls
                if (flags == 2)
                {
                    if (regionInfos == null || regionInfos.Count == 0)
                    {
                        remoteClient.SendAgentAlertMessage("No regions found with that name.", true);
                    }
                }
            }
            catch { }
        }
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars        = new Dictionary <string, object>();
            var regionslist = new List <Dictionary <string, object> >();

            uint   amountPerQuery = 10;
            string noDetails      = translator.GetTranslatedString("NoDetailsText");

            if (requestParameters.ContainsKey("Submit"))
            {
                IGridService gridService = webInterface.Registry.RequestModuleInterface <IGridService>();
                string       regionname  = requestParameters["regionname"].ToString();
                int          start       = httpRequest.Query.ContainsKey("Start")
                                ? int.Parse(httpRequest.Query["Start"].ToString())
                                : 0;
                uint count    = gridService.GetRegionsByNameCount(null, regionname);
                int  maxPages = (int)(count / amountPerQuery) - 1;

                if (start == -1)
                {
                    start = (int)(maxPages < 0 ? 0 : maxPages);
                }

                vars.Add("CurrentPage", start);
                vars.Add("NextOne", start + 1 > maxPages ? start : start + 1);
                vars.Add("BackOne", start - 1 < 0 ? 0 : start - 1);

                var regions = gridService.GetRegionsByName(null, regionname, (uint)start, amountPerQuery);
                if (regions != null)
                {
                    noDetails = "";

                    foreach (var region in regions)
                    {
                        string info;
                        info = (region.RegionArea < 1000000) ? region.RegionArea + " m2" : (region.RegionArea / 1000000) + " km2";
                        info = info + ", " + region.RegionTerrain;

                        regionslist.Add(new Dictionary <string, object> {
                            { "RegionName", region.RegionName },
                            { "RegionLocX", region.RegionLocX / Constants.RegionSize },
                            { "RegionLocY", region.RegionLocY / Constants.RegionSize },
                            { "RegionInfo", info },
                            { "RegionStatus", region.IsOnline ? "yes" : "no" },
                            { "RegionID", region.RegionID }
                        });
                    }
                }
            }
            else
            {
                vars.Add("CurrentPage", 0);
                vars.Add("NextOne", 0);
                vars.Add("BackOne", 0);
            }

            vars.Add("NoDetailsText", noDetails);
            vars.Add("RegionsList", regionslist);
            vars.Add("RegionSearchText", translator.GetTranslatedString("RegionSearchText"));
            vars.Add("SearchForRegionText", translator.GetTranslatedString("SearchForRegionText"));
            vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText"));
            vars.Add("RegionLocXText", translator.GetTranslatedString("RegionLocXText"));
            vars.Add("RegionLocYText", translator.GetTranslatedString("RegionLocYText"));
            vars.Add("RegionOnlineText", translator.GetTranslatedString("Online"));

            vars.Add("Search", translator.GetTranslatedString("Search"));

            vars.Add("FirstText", translator.GetTranslatedString("FirstText"));
            vars.Add("BackText", translator.GetTranslatedString("BackText"));
            vars.Add("NextText", translator.GetTranslatedString("NextText"));
            vars.Add("LastText", translator.GetTranslatedString("LastText"));
            vars.Add("CurrentPageText", translator.GetTranslatedString("CurrentPageText"));

            vars.Add("SearchResultForRegionText", translator.GetTranslatedString("SearchResultForRegionText"));
            vars.Add("RegionMoreInfo", translator.GetTranslatedString("RegionMoreInfo"));
            vars.Add("MoreInfoText", translator.GetTranslatedString("MoreInfoText"));

            return(vars);
        }
Exemple #14
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var         vars        = new Dictionary <string, object>();
            var         regionslist = new List <Dictionary <string, object> >();
            UserAccount account     = null;

            // future use // uint amountPerQuery = 10;
            string noDetails = translator.GetTranslatedString("NoDetailsText");

            if (httpRequest.Query.ContainsKey("userid"))
            {
                List <UUID> scopeUUID = new List <UUID>();
                string      userid    = httpRequest.Query["userid"].ToString();
                UUID        userUUID  = UUID.Parse(userid);
                scopeUUID.Add(userUUID);

                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, userUUID);

                IGridService           gridService       = webInterface.Registry.RequestModuleInterface <IGridService>();
                IWebHttpTextureService webTextureService = webInterface.Registry.RequestModuleInterface <IWebHttpTextureService>();

                var regions = gridService.GetRegionsByName(scopeUUID, "", null, null);
                // TODO: Searching using the user UUID scope does not appear to work  -greythane- 20141020
                if (regions != null)
                {
                    noDetails = "";

                    foreach (var region in regions)
                    {
                        if (region.EstateOwner != userUUID)         // not this one...
                        {
                            continue;
                        }

                        string info;
                        info = (region.RegionArea < 1000000) ? region.RegionArea + " m2" : (region.RegionArea / 1000000) + " km2";
                        info = info + ", " + region.RegionTerrain;

                        var regionData = new Dictionary <string, object> ();
                        regionData.Add("RegionName", region.RegionName);
                        regionData.Add("RegionLocX", region.RegionLocX / Constants.RegionSize);
                        regionData.Add("RegionLocY", region.RegionLocY / Constants.RegionSize);
                        regionData.Add("RegionInfo", info);
                        regionData.Add("RegionStatus", region.IsOnline ? "yes" : "no");
                        regionData.Add("RegionID", region.RegionID);

                        if (webTextureService != null && region.TerrainMapImage != UUID.Zero)
                        {
                            regionData.Add("RegionImageURL", webTextureService.GetTextureURL(region.TerrainMapImage));
                        }
                        else
                        {
                            regionData.Add("RegionImageURL", "../images/icons/no_terrain.jpg");
                        }

                        regionslist.Add(regionData);
                    }
                }
            }

            // provide something..
            if (regionslist.Count == 0)
            {
                regionslist.Add(new Dictionary <string, object> {
                    { "RegionName", translator.GetTranslatedString("NoDetailsText") },
                    { "RegionLocX", "" },
                    { "RegionLocY", "" },
                    { "RegionInfo", "" },
                    { "RegionStatus", "" },
                    { "RegionID", "" },
                    { "RegionImageURL", "../images/icons/no_terrain.jpg" }
                });
            }

            vars.Add("NoDetailsText", noDetails);
            if (account != null)
            {
                vars.Add("UserName", account.Name);
            }
            else
            {
                vars.Add("UserName", "");
            }

            vars.Add("RegionListText", translator.GetTranslatedString("RegionListText"));
            vars.Add("RegionList", regionslist);
            vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText"));
            vars.Add("RegionText", translator.GetTranslatedString("Region"));
            vars.Add("RegionLocXText", translator.GetTranslatedString("RegionLocXText"));
            vars.Add("RegionLocYText", translator.GetTranslatedString("RegionLocYText"));
            vars.Add("RegionOnlineText", translator.GetTranslatedString("Online"));
            vars.Add("RegionMoreInfo", translator.GetTranslatedString("RegionMoreInfo"));
            vars.Add("MoreInfoText", translator.GetTranslatedString("MoreInfoText"));

            return(vars);
        }
Exemple #15
0
        private byte[] GetRegionsByName(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                MainConsole.Instance.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
            }

            string regionName = string.Empty;

            if (request.ContainsKey("NAME"))
            {
                regionName = request["NAME"].ToString();
            }
            else
            {
                MainConsole.Instance.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
            }

            int max = 0;

            if (request.ContainsKey("MAX"))
            {
                Int32.TryParse(request["MAX"].ToString(), out max);
            }
            else
            {
                MainConsole.Instance.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
            }

            List <GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);

            rinfos = CleanRegions(rinfos);
            //MainConsole.Instance.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
            {
                result["result"] = "null";
            }
            else
            {
                int i = 0;
#if (!ISWIN)
                foreach (GridRegion rinfo in rinfos)
                {
                    Dictionary <string, object> rinfoDict = rinfo.ToKVP();
                    result["region" + i] = rinfoDict;
                    i++;
                }
#else
                foreach (Dictionary <string, object> rinfoDict in rinfos.Select(rinfo => rinfo.ToKVP()))
                {
                    result["region" + i] = rinfoDict;
                    i++;
                }
#endif
            }

            string xmlString = WebUtils.BuildXmlResponse(result);
            //MainConsole.Instance.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();
            return(encoding.GetBytes(xmlString));
        }
Exemple #16
0
        public List <GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
        {
            List <GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber);
            //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count);

            // HG urls should not get here, strip them
            // side effect is that local regions with same name as HG may also be found
            // this mb good or bad
            string regionName = name;

            if (name.Contains("."))
            {
                if (!m_ThisGridInfo.HasHGConfig)
                {
                    return(rinfo); // no HG
                }
                string regionURI = "";
                if (!Util.buildHGRegionURI(name, out regionURI, out regionName))
                {
                    return(rinfo); // invalid
                }
                if (m_ThisGridInfo.IsLocalGrid(regionURI) != 1)
                {
                    return(rinfo); // not local grid
                }
            }

            List <GridRegion> grinfo = null;

            if (String.IsNullOrEmpty(regionName))
            {
                List <GridRegion> grinfos = m_RemoteGridService.GetDefaultRegions(scopeID);
                if (grinfos == null || grinfos.Count == 0)
                {
                    m_log.Warn("[REMOTE GRID CONNECTOR] returned no default regions");
                }
                else
                {
                    m_log.WarnFormat("[REMOTE GRID CONNECTOR] returned default regions {0}, ...", grinfos[0].RegionName);
                    // only return first
                    grinfo = new List <GridRegion>()
                    {
                        grinfos[0]
                    };
                }
            }
            else
            {
                grinfo = m_RemoteGridService.GetRegionsByName(scopeID, regionName, maxNumber);
            }

            if (grinfo != null)
            {
                //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionsByName {0} found {1} regions", name, grinfo.Count);
                foreach (GridRegion r in grinfo)
                {
                    m_RegionInfoCache.Cache(r);
                    if (rinfo.Find(delegate(GridRegion gr) { return(gr.RegionID == r.RegionID); }) == null)
                    {
                        rinfo.Add(r);
                    }
                }
            }

            return(rinfo);
        }