1
0

IAgentPreferencesService.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. string tmp;
  41. if (kvp.TryGetValue("PrincipalID", out tmp))
  42. UUID.TryParse(tmp, out PrincipalID);
  43. if (kvp.TryGetValue("AccessPrefs", out tmp))
  44. AccessPrefs = tmp;
  45. if (kvp.TryGetValue("HoverHeight", out tmp))
  46. HoverHeight = float.Parse(tmp);
  47. if (kvp.TryGetValue("Language", out tmp))
  48. Language = tmp;
  49. if (kvp.TryGetValue("LanguageIsPublic", out tmp))
  50. LanguageIsPublic = tmp =="1" || tmp[0] == 't' || tmp[0] == 'T';
  51. if (kvp.TryGetValue("PermEveryone", out tmp))
  52. PermEveryone = int.Parse(tmp);
  53. if (kvp.TryGetValue("PermGroup", out tmp))
  54. PermGroup = int.Parse(tmp);
  55. if (kvp.TryGetValue("PermNextOwner", out tmp))
  56. PermNextOwner = int.Parse(tmp);
  57. }
  58. public AgentPrefs(Dictionary<string, object> kvp)
  59. {
  60. object tmp;
  61. if (kvp.TryGetValue("PrincipalID", out tmp))
  62. UUID.TryParse(tmp.ToString(), out PrincipalID);
  63. if (kvp.TryGetValue("AccessPrefs", out tmp))
  64. AccessPrefs = tmp.ToString();
  65. if (kvp.TryGetValue("HoverHeight", out tmp))
  66. HoverHeight = float.Parse(tmp.ToString());
  67. if (kvp.TryGetValue("Language", out tmp))
  68. Language = tmp.ToString();
  69. if (kvp.TryGetValue("LanguageIsPublic", out tmp))
  70. {
  71. string s = tmp as string;
  72. LanguageIsPublic = s == "1" || s[0] == 't' || s[0] == 'T';
  73. }
  74. if (kvp.TryGetValue("PermEveryone", out tmp))
  75. PermEveryone = int.Parse(tmp.ToString());
  76. if (kvp.TryGetValue("PermGroup", out tmp))
  77. PermGroup = int.Parse(tmp.ToString());
  78. if (kvp.TryGetValue("PermNextOwner", out tmp))
  79. PermNextOwner = int.Parse(tmp.ToString());
  80. }
  81. public Dictionary<string, object> ToKeyValuePairs()
  82. {
  83. Dictionary<string, object> result = new Dictionary<string, object>();
  84. result["PrincipalID"] = PrincipalID.ToString();
  85. result["AccessPrefs"] = AccessPrefs.ToString();
  86. result["HoverHeight"] = HoverHeight.ToString();
  87. result["Language"] = Language.ToString();
  88. result["LanguageIsPublic"] = LanguageIsPublic.ToString();
  89. result["PermEveryone"] = PermEveryone.ToString();
  90. result["PermGroup"] = PermGroup.ToString();
  91. result["PermNextOwner"] = PermNextOwner.ToString();
  92. return result;
  93. }
  94. public UUID PrincipalID = UUID.Zero;
  95. public string AccessPrefs = "M";
  96. //public int GodLevel; // *TODO: Implement GodLevel (Unused by the viewer, afaict - 6/11/2015)
  97. public float HoverHeight = 0.0f;
  98. public string Language = "en-us";
  99. public bool LanguageIsPublic = true;
  100. // DefaultObjectPermMasks
  101. public int PermEveryone = 0;
  102. public int PermGroup = 0;
  103. public int PermNextOwner = 0; // Illegal value by design
  104. }
  105. public interface IAgentPreferencesService
  106. {
  107. AgentPrefs GetAgentPreferences(UUID principalID);
  108. bool StoreAgentPreferences(AgentPrefs data);
  109. string GetLang(UUID principalID);
  110. }
  111. }