コード例 #1
0
        public AgentPrefs GetAgentPreferences(UUID principalID)
        {
            AgentPreferencesData d     = m_Database.GetPrefs(principalID);
            AgentPrefs           prefs = (d == null) ? null : new AgentPrefs(d.Data);

            return(prefs);
        }
コード例 #2
0
        byte[] GetAgentLang(Dictionary <string, object> request)
        {
            if (!request.ContainsKey("UserID"))
            {
                return(FailureResult());
            }
            UUID userID;

            if (!UUID.TryParse(request["UserID"].ToString(), out userID))
            {
                return(FailureResult());
            }

            string     lang  = "en-us";
            AgentPrefs prefs = m_AgentPreferencesService.GetAgentPreferences(userID);

            if (prefs != null)
            {
                if (prefs.LanguageIsPublic)
                {
                    lang = prefs.Language;
                }
            }
            Dictionary <string, object> result = new Dictionary <string, object>();

            result["Language"] = lang;
            string xmlString = ServerUtils.BuildXmlResponse(result);

            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
コード例 #3
0
        byte[] SetAgentPrefs(Dictionary <string, object> request)
        {
            if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("AccessPrefs") || !request.ContainsKey("HoverHeight") ||
                !request.ContainsKey("Language") || !request.ContainsKey("LanguageIsPublic") || !request.ContainsKey("PermEveryone") ||
                !request.ContainsKey("PermGroup") || !request.ContainsKey("PermNextOwner"))
            {
                return(FailureResult());
            }

            UUID userID;

            if (!UUID.TryParse(request["PrincipalID"].ToString(), out userID))
            {
                return(FailureResult());
            }

            AgentPrefs data = new AgentPrefs(userID);

            data.AccessPrefs      = request["AccessPrefs"].ToString();
            data.HoverHeight      = double.Parse(request["HoverHeight"].ToString());
            data.Language         = request["Language"].ToString();
            data.LanguageIsPublic = bool.Parse(request["LanguageIsPublic"].ToString());
            data.PermEveryone     = int.Parse(request["PermEveryone"].ToString());
            data.PermGroup        = int.Parse(request["PermGroup"].ToString());
            data.PermNextOwner    = int.Parse(request["PermNextOwner"].ToString());

            return(m_AgentPreferencesService.StoreAgentPreferences(data) ? SuccessResult() : FailureResult());
        }
コード例 #4
0
        byte[] GetAgentPrefs(Dictionary <string, object> request)
        {
            if (!request.ContainsKey("UserID"))
            {
                return(FailureResult());
            }

            UUID userID;

            if (!UUID.TryParse(request["UserID"].ToString(), out userID))
            {
                return(FailureResult());
            }
            AgentPrefs prefs = m_AgentPreferencesService.GetAgentPreferences(userID);
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (prefs != null)
            {
                result = prefs.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
コード例 #5
0
        public bool StoreAgentPreferences(AgentPrefs data)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["METHOD"] = "setagentprefs";

            sendData["PrincipalID"]      = data.PrincipalID.ToString();
            sendData["AccessPrefs"]      = data.AccessPrefs;
            sendData["HoverHeight"]      = data.HoverHeight.ToString();
            sendData["Language"]         = data.Language;
            sendData["LanguageIsPublic"] = data.LanguageIsPublic.ToString();
            sendData["PermEveryone"]     = data.PermEveryone.ToString();
            sendData["PermGroup"]        = data.PermGroup.ToString();
            sendData["PermNextOwner"]    = data.PermNextOwner.ToString();

            string uri       = String.Concat(m_ServerURI, "/agentprefs");
            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);

            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("result"))
                    {
                        if (replyData["result"].ToString().ToLower() == "success")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences reply data does not contain result field");
                    }
                }
                else
                {
                    m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
            }

            return(false);
        }
コード例 #6
0
        public string GetLang(UUID principalID)
        {
            AgentPrefs data = GetAgentPreferences(principalID);

            if (data != null)
            {
                if (data.LanguageIsPublic)
                {
                    return(data.Language);
                }
            }
            return("en-us");
        }
コード例 #7
0
        public bool StoreAgentPreferences(AgentPrefs data)
        {
            AgentPreferencesData d = new AgentPreferencesData();

            d.Data = new Dictionary <string, string>();
            d.Data["PrincipalID"]      = data.PrincipalID.ToString();
            d.Data["AccessPrefs"]      = data.AccessPrefs;
            d.Data["HoverHeight"]      = data.HoverHeight.ToString();
            d.Data["Language"]         = data.Language;
            d.Data["LanguageIsPublic"] = (data.LanguageIsPublic ? "1" : "0");
            d.Data["PermEveryone"]     = data.PermEveryone.ToString();
            d.Data["PermGroup"]        = data.PermGroup.ToString();
            d.Data["PermNextOwner"]    = data.PermNextOwner.ToString();
            return(m_Database.Store(d));
        }
コード例 #8
0
        public AgentPrefs GetAgentPreferences(UUID principalID)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            string reply = string.Empty;
            string uri   = String.Concat(m_ServerURI, "/agentprefs");

            sendData["METHOD"] = "getagentprefs";
            sendData["UserID"] = principalID;
            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);

            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (string.IsNullOrEmpty(reply))
                {
                    m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null or empty reply");
                    return(null);
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
            }

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

            if (replyData != null)
            {
                if (replyData.ContainsKey("result") &&
                    (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
                {
                    m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received Failure response");
                    return(null);
                }
            }
            else
            {
                m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null response");
                return(null);
            }
            AgentPrefs prefs = new AgentPrefs(replyData);

            return(prefs);
        }
コード例 #9
0
        public bool StoreAgentPreferences(AgentPrefs data)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["METHOD"] = "setagentprefs";

            sendData["PrincipalID"]      = data.PrincipalID.ToString();
            sendData["AccessPrefs"]      = data.AccessPrefs;
            sendData["HoverHeight"]      = data.HoverHeight.ToString();
            sendData["Language"]         = data.Language;
            sendData["LanguageIsPublic"] = data.LanguageIsPublic.ToString();
            sendData["PermEveryone"]     = data.PermEveryone.ToString();
            sendData["PermGroup"]        = data.PermGroup.ToString();
            sendData["PermNextOwner"]    = data.PermNextOwner.ToString();

            string uri       = string.Concat(m_ServerURI, "/agentprefs");
            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);

            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (reply != string.Empty)
                {
                    int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase);
                    if (indx > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
                else
                {
                    m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
            }

            return(false);
        }
コード例 #10
0
        public string UpdateAgentPreferences(string request, string path, string param, UUID agent)
        {
            OSDMap resp = new OSDMap();

            // if there is no preference service,
            // we'll return a null llsd block for debugging purposes. This may change if someone knows what the
            // correct server response would be here.
            if (m_scenes[0].AgentPreferencesService == null)
            {
                return(OSDParser.SerializeLLSDXmlString(resp));
            }
            m_log.DebugFormat("[AgentPrefs]: UpdateAgentPreferences for {0}", agent.ToString());
            OSDMap     req  = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            AgentPrefs data = m_scenes[0].AgentPreferencesService.GetAgentPreferences(agent);

            if (data == null)
            {
                data = new AgentPrefs(agent);
            }

            if (req.ContainsKey("access_prefs"))
            {
                OSDMap accessPrefs = (OSDMap)req["access_prefs"];  // We could check with ContainsKey...
                data.AccessPrefs = accessPrefs["max"].AsString();
            }
            if (req.ContainsKey("default_object_perm_masks"))
            {
                OSDMap permsMap = (OSDMap)req["default_object_perm_masks"];
                data.PermEveryone  = permsMap["Everyone"].AsInteger();
                data.PermGroup     = permsMap["Group"].AsInteger();
                data.PermNextOwner = permsMap["NextOwner"].AsInteger();
            }
            if (req.ContainsKey("hover_height"))
            {
                data.HoverHeight = (float)req["hover_height"].AsReal();
            }
            if (req.ContainsKey("language"))
            {
                data.Language = req["language"].AsString();
            }
            if (req.ContainsKey("language_is_public"))
            {
                data.LanguageIsPublic = req["language_is_public"].AsBoolean();
            }
            m_scenes[0].AgentPreferencesService.StoreAgentPreferences(data);
            OSDMap respAccessPrefs = new OSDMap();

            respAccessPrefs["max"] = data.AccessPrefs;
            resp["access_prefs"]   = respAccessPrefs;
            OSDMap respDefaultPerms = new OSDMap();

            respDefaultPerms["Everyone"]      = data.PermEveryone;
            respDefaultPerms["Group"]         = data.PermGroup;
            respDefaultPerms["NextOwner"]     = data.PermNextOwner;
            resp["default_object_perm_masks"] = respDefaultPerms;
            resp["god_level"]          = 0; // *TODO: Add this
            resp["hover_height"]       = data.HoverHeight;
            resp["language"]           = data.Language;
            resp["language_is_public"] = data.LanguageIsPublic;

            IAvatarFactoryModule afm = m_scenes[0].RequestModuleInterface <IAvatarFactoryModule>();

            afm?.SetPreferencesHoverZ(agent, (float)data.HoverHeight);

            string response = OSDParser.SerializeLLSDXmlString(resp);

            return(response);
        }
コード例 #11
0
 public bool StoreAgentPreferences(AgentPrefs data)
 {
     return(m_AgentPreferencesService.StoreAgentPreferences(data));
 }
コード例 #12
0
        public void UpdateAgentPreferences(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agent)
        {
            if (httpRequest.HttpMethod != "POST")
            {
                httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            //m_log.DebugFormat("[AgentPrefs]: UpdateAgentPreferences for {0}", agent.ToString());
            OSDMap req;

            try
            {
                req = (OSDMap)OSDParser.DeserializeLLSDXml(httpRequest.InputStream);
            }
            catch
            {
                httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }

            IAgentPreferencesService aps = m_scenes[0].AgentPreferencesService;
            AgentPrefs data = null;

            if (aps != null)
            {
                data = aps.GetAgentPreferences(agent);
            }

            if (data == null)
            {
                data = new AgentPrefs(agent);
            }

            bool changed = false;
            OSD  tmp;

            if (req.TryGetValue("access_prefs", out tmp) && tmp is OSDMap)
            {
                OSDMap accessPrefs = (OSDMap)tmp;  // We could check with ContainsKey...
                data.AccessPrefs = accessPrefs["max"].AsString();
                changed          = true;
            }
            if (req.TryGetValue("default_object_perm_masks", out tmp) && tmp is OSDMap)
            {
                OSDMap permsMap = (OSDMap)tmp;
                data.PermEveryone  = permsMap["Everyone"].AsInteger();
                data.PermGroup     = permsMap["Group"].AsInteger();
                data.PermNextOwner = permsMap["NextOwner"].AsInteger();
                changed            = true;
            }
            if (req.TryGetValue("hover_height", out tmp))
            {
                data.HoverHeight = (float)tmp.AsReal();
                changed          = true;
            }
            if (req.TryGetValue("language", out tmp))
            {
                data.Language = tmp.AsString();
                changed       = true;
            }
            if (req.TryGetValue("language_is_public", out tmp))
            {
                data.LanguageIsPublic = tmp.AsBoolean();
                changed = true;
            }

            if (changed)
            {
                aps?.StoreAgentPreferences(data);
            }

            IAvatarFactoryModule afm = m_scenes[0].RequestModuleInterface <IAvatarFactoryModule>();

            afm?.SetPreferencesHoverZ(agent, (float)data.HoverHeight);

            OSDMap resp            = new OSDMap();
            OSDMap respAccessPrefs = new OSDMap();

            respAccessPrefs["max"] = data.AccessPrefs;
            resp["access_prefs"]   = respAccessPrefs;

            OSDMap respDefaultPerms = new OSDMap();

            respDefaultPerms["Everyone"]  = data.PermEveryone;
            respDefaultPerms["Group"]     = data.PermGroup;
            respDefaultPerms["NextOwner"] = data.PermNextOwner;

            resp["default_object_perm_masks"] = respDefaultPerms;
            resp["god_level"]          = 0; // *TODO: Add this
            resp["hover_height"]       = data.HoverHeight;
            resp["language"]           = data.Language;
            resp["language_is_public"] = data.LanguageIsPublic;

            httpResponse.RawBuffer  = OSDParser.SerializeLLSDXmlBytes(resp);
            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }