1
0

IAgentPreferencesService.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using OpenMetaverse;
  30. namespace OpenSim.Services.Interfaces
  31. {
  32. public class AgentPrefs
  33. {
  34. public AgentPrefs(UUID principalID)
  35. {
  36. PrincipalID = principalID;
  37. }
  38. public AgentPrefs(Dictionary<string, string> kvp)
  39. {
  40. if (kvp.ContainsKey("PrincipalID"))
  41. UUID.TryParse(kvp["PrincipalID"], out PrincipalID);
  42. if (kvp.ContainsKey("AccessPrefs"))
  43. AccessPrefs = kvp["AccessPrefs"];
  44. if (kvp.ContainsKey("HoverHeight"))
  45. HoverHeight = double.Parse(kvp["HoverHeight"]);
  46. if (kvp.ContainsKey("Language"))
  47. Language = kvp["Language"];
  48. if (kvp.ContainsKey("LanguageIsPublic"))
  49. LanguageIsPublic = bool.Parse(kvp["LanguageIsPublic"]);
  50. if (kvp.ContainsKey("PermEveryone"))
  51. PermEveryone = int.Parse(kvp["PermEveryone"]);
  52. if (kvp.ContainsKey("PermGroup"))
  53. PermGroup = int.Parse(kvp["PermGroup"]);
  54. if (kvp.ContainsKey("PermNextOwner"))
  55. PermNextOwner = int.Parse(kvp["PermNextOwner"]);
  56. }
  57. public AgentPrefs(Dictionary<string, object> kvp)
  58. {
  59. if (kvp.ContainsKey("PrincipalID"))
  60. UUID.TryParse(kvp["PrincipalID"].ToString(), out PrincipalID);
  61. if (kvp.ContainsKey("AccessPrefs"))
  62. AccessPrefs = kvp["AccessPrefs"].ToString();
  63. if (kvp.ContainsKey("HoverHeight"))
  64. HoverHeight = double.Parse(kvp["HoverHeight"].ToString());
  65. if (kvp.ContainsKey("Language"))
  66. Language = kvp["Language"].ToString();
  67. if (kvp.ContainsKey("LanguageIsPublic"))
  68. LanguageIsPublic = bool.Parse(kvp["LanguageIsPublic"].ToString());
  69. if (kvp.ContainsKey("PermEveryone"))
  70. PermEveryone = int.Parse(kvp["PermEveryone"].ToString());
  71. if (kvp.ContainsKey("PermGroup"))
  72. PermGroup = int.Parse(kvp["PermGroup"].ToString());
  73. if (kvp.ContainsKey("PermNextOwner"))
  74. PermNextOwner = int.Parse(kvp["PermNextOwner"].ToString());
  75. }
  76. public Dictionary<string, object> ToKeyValuePairs()
  77. {
  78. Dictionary<string, object> result = new Dictionary<string, object>();
  79. result["PrincipalID"] = PrincipalID.ToString();
  80. result["AccessPrefs"] = AccessPrefs.ToString();
  81. result["HoverHeight"] = HoverHeight.ToString();
  82. result["Language"] = Language.ToString();
  83. result["LanguageIsPublic"] = LanguageIsPublic.ToString();
  84. result["PermEveryone"] = PermEveryone.ToString();
  85. result["PermGroup"] = PermGroup.ToString();
  86. result["PermNextOwner"] = PermNextOwner.ToString();
  87. return result;
  88. }
  89. public UUID PrincipalID = UUID.Zero;
  90. public string AccessPrefs = "M";
  91. //public int GodLevel; // *TODO: Implement GodLevel (Unused by the viewer, afaict - 6/11/2015)
  92. public double HoverHeight = 0.0;
  93. public string Language = "en-us";
  94. public bool LanguageIsPublic = true;
  95. // DefaultObjectPermMasks
  96. public int PermEveryone = 0;
  97. public int PermGroup = 0;
  98. public int PermNextOwner = 0; // Illegal value by design
  99. }
  100. public interface IAgentPreferencesService
  101. {
  102. AgentPrefs GetAgentPreferences(UUID principalID);
  103. bool StoreAgentPreferences(AgentPrefs data);
  104. string GetLang(UUID principalID);
  105. }
  106. }