Skip to content
This repository has been archived by the owner on Aug 19, 2018. It is now read-only.

AgentPreferences CAP implementation and related features #317

Merged
merged 9 commits into from Jan 20, 2017
18 changes: 12 additions & 6 deletions InWorldz/InWorldz.Phlox.Engine/LSLSystemAPI.cs
Expand Up @@ -7256,12 +7256,18 @@ public int llGetAgentInfo(string id)

public string llGetAgentLanguage(string id)
{
// This should only return a value if the avatar is in the same region
//ckrinke 1-30-09 : This needs to parse the XMLRPC language field supplied
//by the client at login. Currently returning only en-us until our I18N
//effort gains momentum

return "en-us";
UUID agent = new UUID();
if (!UUID.TryParse(id, out agent)) return String.Empty;

ScenePresence presence = World.GetScenePresence(agent);
if (presence == null) return String.Empty;
if (presence.IsChildAgent) return String.Empty;

AgentPreferencesData prefs = presence.AgentPrefs;
if (prefs == null) return String.Empty;
if (!prefs.LanguageIsPublic) return String.Empty;

return prefs.Language;
}

public void llAdjustSoundVolume(float volume)
Expand Down
3 changes: 2 additions & 1 deletion InWorldz/InWorldz.Testing/MockClientAPI.cs
Expand Up @@ -33,6 +33,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenMetaverse;
using OpenSim.Framework;
using OpenMetaverse.StructuredData;

Expand Down Expand Up @@ -607,7 +608,7 @@ public void SendWearables(AvatarWearable[] wearables, int serial)

}

public void SendAppearance(AvatarAppearance app)
public void SendAppearance(AvatarAppearance app, Vector3 hover)
{

}
Expand Down
108 changes: 108 additions & 0 deletions OpenSim/Framework/AgentPreferencesData.cs
@@ -0,0 +1,108 @@
/*
* Copyright (c) InWorldz Halcyon Developers
* Copyright (c) Contributors, http://opensimulator.org/
*
* 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 OpenSim 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.Collections.Generic;
using OpenMetaverse;
using OpenMetaverse.StructuredData;

namespace OpenSim.Framework
{
/// <summary>
/// Known information about a particular user preferences
/// </summary>
public class AgentPreferencesData
{
public UUID PrincipalID = UUID.Zero;
public string AccessPrefs = "M";
//public int GodLevel; // *TODO: Implement GodLevel (Unused by the viewer, afaict - 6/11/2015)
public double HoverHeight = 0.0;
public string Language = "en-us";
public bool LanguageIsPublic = true;
// DefaultObjectPermMasks
public uint PermEveryone = 0;
public uint PermGroup = 0;
public uint PermNextOwner = 0; // Illegal value by design

public AgentPreferencesData()
{
}

public AgentPreferencesData(OSDMap map)
{
this.FromOSDMap(map);
}

public AgentPreferencesData(AgentPreferencesData data)
{
if (data != null)
{
this.HoverHeight = data.HoverHeight;
this.AccessPrefs = data.AccessPrefs;
this.Language = data.Language;
this.LanguageIsPublic = data.LanguageIsPublic;
this.PermEveryone = data.PermEveryone;
this.PermGroup = data.PermGroup;
this.PermNextOwner = data.PermNextOwner;
this.PrincipalID = data.PrincipalID;
}
}

public OSDMap ToOSDMap()
{
OSDMap result = new OSDMap();
result["PrincipalID"] = PrincipalID;
result["AccessPrefs"] = AccessPrefs;
result["HoverHeight"] = HoverHeight;
result["Language"] = Language;
result["LanguageIsPublic"] = LanguageIsPublic;
result["PermEveryone"] = PermEveryone;
result["PermGroup"] = PermGroup;
result["PermNextOwner"] = PermNextOwner;
return result;
}

public void FromOSDMap(OSDMap map)
{
if (map.ContainsKey("PrincipalID"))
UUID.TryParse(map["PrincipalID"].ToString(), out PrincipalID);
if (map.ContainsKey("AccessPrefs"))
AccessPrefs = map["AccessPrefs"].ToString();
if (map.ContainsKey("HoverHeight"))
HoverHeight = double.Parse(map["HoverHeight"].ToString());
if (map.ContainsKey("Language"))
Language = map["Language"].ToString();
if (map.ContainsKey("LanguageIsPublic"))
LanguageIsPublic = bool.Parse(map["LanguageIsPublic"].ToString());
if (map.ContainsKey("PermEveryone"))
PermEveryone = uint.Parse(map["PermEveryone"].ToString());
if (map.ContainsKey("PermGroup"))
PermGroup = uint.Parse(map["PermGroup"].ToString());
if (map.ContainsKey("PermNextOwner"))
PermNextOwner = uint.Parse(map["PermNextOwner"].ToString());
}
}
}