示例#1
0
 private void PackageUpdateSystem(HttpRequest req, Map jsondata)
 {
     try
     {
         CoreUpdater.Instance.CheckForUpdates();
     }
     catch
     {
         m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.NotPossible);
         return;
     }
     m_WebIF.SuccessResponse(req, new Map());
 }
示例#2
0
        private void HandleRemoveNpc(HttpRequest req, Map jsondata)
        {
            SceneInterface scene = null;

            if (!jsondata.ContainsKey("id"))
            {
                m_AdminWebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidRequest);
                return;
            }
            UUID npcId = jsondata["id"].AsUUID;

            if (jsondata.ContainsKey("regionid") &&
                !m_KnownScenes.TryGetValue(jsondata["regionid"].AsUUID, out scene))
            {
                m_AdminWebIF.ErrorResponse(req, AdminWebIfErrorResult.NotFound);
                return;
            }

            NpcAgent npc;

            if (!m_NpcAgents.TryGetValue(npcId, out npc))
            {
                m_AdminWebIF.ErrorResponse(req, AdminWebIfErrorResult.NotFound);
            }
            else if (scene != null && npc.CurrentScene != scene)
            {
                m_AdminWebIF.ErrorResponse(req, AdminWebIfErrorResult.NotFound);
            }
            else if (!m_NpcAgents.Remove(npcId, out npc))
            {
                m_AdminWebIF.ErrorResponse(req, AdminWebIfErrorResult.NotFound);
            }
            else
            {
                npc.CurrentScene.Remove(npc);
                RemoveNpcData(npc);
                m_AdminWebIF.SuccessResponse(req, new Map());
            }
        }
示例#3
0
        private void ReturnRegionsResult(HttpRequest req, List <RegionInfo> regions)
        {
            var resdata = new Map();

            foreach (var ri in regions)
            {
                var owner      = m_WebIF.ResolveName(ri.Owner);
                var regiondata = new Map
                {
                    { "name", ri.Name },
                    { "location_x", ri.Location.GridX },
                    { "location_y", ri.Location.GridY },
                    { "size_x", ri.Size.GridX },
                    { "size_y", ri.Size.GridY },
                    { "owner", owner.ToString() },
                    { "flags", (int)ri.Flags }
                };
                resdata.Add(ri.ID.ToString(), regiondata);
            }

            m_WebIF.SuccessResponse(req, resdata);
        }
示例#4
0
        private void HandleList(HttpRequest req, Map jsondata)
        {
            var estates = m_EstateService.All;

            var res       = new Map();
            var estateRes = new AnArray();

            foreach (EstateInfo estate in estates)
            {
                estateRes.Add(estate.ToJsonMap(m_WebIF));
            }
            res.Add("estates", estateRes);
            m_WebIF.SuccessResponse(req, res);
        }
示例#5
0
        private void HandleUserAccountCreate(HttpRequest req, Map jsondata)
        {
            var account = new UserAccount();

            account.Principal.ID = UUID.Random;
            string firstname;
            string lastname;
            string password;

            if (!jsondata.TryGetValue("firstname", out firstname) ||
                !jsondata.TryGetValue("lastname", out lastname) ||
                !jsondata.TryGetValue("password", out password))
            {
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidRequest);
                return;
            }
            account.Principal.FirstName = firstname;
            account.Principal.LastName  = lastname;
            int    ival;
            string sval;
            uint   uval;

            if (jsondata.TryGetValue("userlevel", out ival))
            {
                account.UserLevel = ival;
                if (account.UserLevel > 255)
                {
                    m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidParameter);
                    return;
                }
            }
            if (jsondata.TryGetValue("usertitle", out sval))
            {
                account.UserTitle = sval;
            }
            if (jsondata.TryGetValue("userflags", out uval))
            {
                account.UserFlags = (UserFlags)uval;
            }
            if (jsondata.TryGetValue("email", out sval))
            {
                account.Email = sval;
            }
            try
            {
                m_UserAccountService.Add(account);
            }
            catch
            {
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.AlreadyExists);
                return;
            }
            var uai = new UserAuthInfo
            {
                ID       = account.Principal.ID,
                Password = password
            };

            try
            {
                m_AuthInfoService.Store(uai);
            }
            catch
            {
                m_UserAccountService.Remove(account.Principal.ID);
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.NotPossible);
                return;
            }
            var res = new Map
            {
                { "id", account.Principal.ID },
                { "firstname", account.Principal.FirstName },
                { "lastname", account.Principal.LastName }
            };
            var resdata = new Map
            {
                ["account"] = res
            };

            m_WebIF.SuccessResponse(req, resdata);
        }