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);
 }
        public string UpdateAgentPreferences(string request, string path, string param, UUID agent)
        {
            OSDMap resp = new OSDMap();
            // The viewer doesn't do much with the return value, so for now, 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 = 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;

            string response = OSDParser.SerializeLLSDXmlString(resp);
            return response;
        }
        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();
        }
 public bool StoreAgentPreferences(AgentPrefs data)
 {
     return m_AgentPreferencesService.StoreAgentPreferences(data);
 }