diff options
author | Cinder | 2015-06-12 18:48:07 -0600 |
---|---|---|
committer | Diva Canto | 2015-06-13 07:27:42 -0700 |
commit | 0fa94f222df8ed7f308730c3692bf2a774138718 (patch) | |
tree | 560efc5542dea946a79dbbaebd39b991a67ede73 /OpenSim/Region | |
parent | Relicense AgentPreferences files to BSD and OpenSimulator (diff) | |
download | opensim-SC-0fa94f222df8ed7f308730c3692bf2a774138718.zip opensim-SC-0fa94f222df8ed7f308730c3692bf2a774138718.tar.gz opensim-SC-0fa94f222df8ed7f308730c3692bf2a774138718.tar.bz2 opensim-SC-0fa94f222df8ed7f308730c3692bf2a774138718.tar.xz |
Refactor AgentPreferences so that database operations happen centrally. the opensim way.
Signed-off-by: Diva Canto <diva@metaverseink.com>
Diffstat (limited to 'OpenSim/Region')
6 files changed, 300 insertions, 110 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs index 58d9f7d..509004d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using System.IO; | 31 | using System.IO; |
31 | using log4net; | 32 | using log4net; |
@@ -33,8 +34,6 @@ using Mono.Addins; | |||
33 | using Nini.Config; | 34 | using Nini.Config; |
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
36 | using OpenSim.Data; | ||
37 | using OpenSim.Data.MySQL; | ||
38 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
39 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
40 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
@@ -47,68 +46,34 @@ using OpenSim.Capabilities.Handlers; | |||
47 | namespace OpenSim.Region.ClientStack.LindenCaps | 46 | namespace OpenSim.Region.ClientStack.LindenCaps |
48 | { | 47 | { |
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AgentPreferencesModule")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AgentPreferencesModule")] |
50 | public class AgentPreferencesModule : ISharedRegionModule, IAgentPreferencesModule | 49 | public class AgentPreferencesModule : ISharedRegionModule |
51 | { | 50 | { |
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | 52 | ||
54 | public bool m_enabled { get; private set; } | 53 | private List<Scene> m_scenes = new List<Scene>(); |
55 | private Scene m_Scene; | ||
56 | protected IAgentPreferencesData m_Database; | ||
57 | 54 | ||
58 | public void Initialise(IConfigSource source) | 55 | public void Initialise(IConfigSource source) |
59 | { | 56 | { |
60 | IConfig dbConfig = source.Configs["DatabaseService"]; | 57 | |
61 | if (dbConfig != null) | ||
62 | { | ||
63 | string dllName = String.Empty; | ||
64 | string connString = String.Empty; | ||
65 | |||
66 | dllName = dbConfig.GetString("StorageProvider", dllName); | ||
67 | connString = dbConfig.GetString("ConnectionString", connString); | ||
68 | |||
69 | // We tried, but this doesn't exist. We can't proceed | ||
70 | if (dllName == String.Empty) | ||
71 | throw new Exception("No StorageProvider configured"); | ||
72 | |||
73 | // *FIXME: This is a janky as hell, works for now. | ||
74 | if (dllName == "OpenSim.Data.MySQL.dll") | ||
75 | m_Database = new MySQLAgentPreferencesData(connString, "AgentPrefs"); | ||
76 | else | ||
77 | throw new Exception("Storage provider not supported!"); | ||
78 | |||
79 | if (m_Database == null) | ||
80 | { | ||
81 | m_enabled = false; | ||
82 | throw new Exception("Could not find a storage interface in the given module"); | ||
83 | } | ||
84 | m_log.Debug("[AgentPrefs] AgentPrefs is enabled"); | ||
85 | m_enabled = true; | ||
86 | } | ||
87 | } | 58 | } |
88 | 59 | ||
89 | #region Region module | 60 | #region Region module |
90 | public void AddRegion(Scene s) | ||
91 | { | ||
92 | if (!m_enabled) return; | ||
93 | 61 | ||
94 | s.RegisterModuleInterface<IAgentPreferencesModule>(this); | 62 | public void AddRegion(Scene scene) |
95 | m_Scene = s; | 63 | { |
64 | lock (m_scenes) m_scenes.Add(scene); | ||
96 | } | 65 | } |
97 | 66 | ||
98 | public void RemoveRegion(Scene s) | 67 | public void RemoveRegion(Scene scene) |
99 | { | 68 | { |
100 | if (!m_enabled) return; | 69 | lock (m_scenes) m_scenes.Remove(scene); |
101 | 70 | scene.EventManager.OnRegisterCaps -= RegisterCaps; | |
102 | m_Scene.UnregisterModuleInterface<IAgentPreferencesModule>(this); | 71 | scene = null; |
103 | m_Scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
104 | m_Scene = null; | ||
105 | } | 72 | } |
106 | 73 | ||
107 | public void RegionLoaded(Scene s) | 74 | public void RegionLoaded(Scene scene) |
108 | { | 75 | { |
109 | if (!m_enabled) return; | 76 | scene.EventManager.OnRegisterCaps += delegate(UUID agentID, OpenSim.Framework.Capabilities.Caps caps) |
110 | |||
111 | m_Scene.EventManager.OnRegisterCaps += delegate(UUID agentID, OpenSim.Framework.Capabilities.Caps caps) | ||
112 | { | 77 | { |
113 | RegisterCaps(agentID, caps); | 78 | RegisterCaps(agentID, caps); |
114 | }; | 79 | }; |
@@ -155,11 +120,10 @@ namespace OpenSim.Region.ClientStack.LindenCaps | |||
155 | { | 120 | { |
156 | m_log.DebugFormat("[AgentPrefs] UpdateAgentPreferences for {0}", agent.ToString()); | 121 | m_log.DebugFormat("[AgentPrefs] UpdateAgentPreferences for {0}", agent.ToString()); |
157 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | 122 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); |
158 | AgentPreferencesData data = m_Database.GetPrefs(agent); | 123 | AgentPrefs data = m_scenes[0].AgentPreferencesService.GetAgentPreferences(agent); |
159 | if (data == null) | 124 | if (data == null) |
160 | { | 125 | { |
161 | data = new AgentPreferencesData(); | 126 | data = new AgentPrefs(agent); |
162 | data.PrincipalID = agent; | ||
163 | } | 127 | } |
164 | 128 | ||
165 | if (req.ContainsKey("access_prefs")) | 129 | if (req.ContainsKey("access_prefs")) |
@@ -186,7 +150,7 @@ namespace OpenSim.Region.ClientStack.LindenCaps | |||
186 | { | 150 | { |
187 | data.LanguageIsPublic = req["language_is_public"].AsBoolean(); | 151 | data.LanguageIsPublic = req["language_is_public"].AsBoolean(); |
188 | } | 152 | } |
189 | m_Database.StorePrefs(data); | 153 | m_scenes[0].AgentPreferencesService.StoreAgentPreferences(data); |
190 | OSDMap resp = new OSDMap(); | 154 | OSDMap resp = new OSDMap(); |
191 | OSDMap respAccessPrefs = new OSDMap(); | 155 | OSDMap respAccessPrefs = new OSDMap(); |
192 | respAccessPrefs["max"] = data.AccessPrefs; | 156 | respAccessPrefs["max"] = data.AccessPrefs; |
@@ -204,21 +168,8 @@ namespace OpenSim.Region.ClientStack.LindenCaps | |||
204 | string response = OSDParser.SerializeLLSDXmlString(resp); | 168 | string response = OSDParser.SerializeLLSDXmlString(resp); |
205 | return response; | 169 | return response; |
206 | } | 170 | } |
207 | #endregion Region module | ||
208 | 171 | ||
209 | #region IAgentPreferences | 172 | #endregion Region module |
210 | public string GetLang(UUID agentID) | ||
211 | { | ||
212 | AgentPreferencesData data = m_Database.GetPrefs(agentID); | ||
213 | if (data != null) | ||
214 | { | ||
215 | if (data.LanguageIsPublic) | ||
216 | return data.Language; | ||
217 | } | ||
218 | return "en-us"; | ||
219 | |||
220 | } | ||
221 | #endregion | ||
222 | } | 173 | } |
223 | } | 174 | } |
224 | 175 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/LocalAgentPreferencesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/LocalAgentPreferencesServiceConnector.cs new file mode 100644 index 0000000..9d8367d --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/LocalAgentPreferencesServiceConnector.cs | |||
@@ -0,0 +1,153 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Mono.Addins; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Server.Base; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.AgentPreferences | ||
42 | { | ||
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalAgentPreferencesServicesConnector")] | ||
44 | public class LocalAgentPreferencesServicesConnector : ISharedRegionModule, IAgentPreferencesService | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IAgentPreferencesService m_AgentPreferencesService; | ||
49 | private bool m_Enabled = false; | ||
50 | |||
51 | #region ISharedRegionModule | ||
52 | |||
53 | public Type ReplaceableInterface | ||
54 | { | ||
55 | get { return null; } | ||
56 | } | ||
57 | |||
58 | public string Name | ||
59 | { | ||
60 | get { return "LocalAgentPreferencesServicesConnector"; } | ||
61 | } | ||
62 | |||
63 | public void Initialise(IConfigSource source) | ||
64 | { | ||
65 | IConfig moduleConfig = source.Configs["Modules"]; | ||
66 | if (moduleConfig != null) | ||
67 | { | ||
68 | string name = moduleConfig.GetString("AgentPreferencesServices", ""); | ||
69 | if (name == Name) | ||
70 | { | ||
71 | IConfig userConfig = source.Configs["AgentPreferencesService"]; | ||
72 | if (userConfig == null) | ||
73 | { | ||
74 | m_log.Error("[AGENT PREFERENCES CONNECTOR]: AgentPreferencesService missing from OpenSim.ini"); | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | string serviceDll = userConfig.GetString("LocalServiceModule", String.Empty); | ||
79 | |||
80 | if (String.IsNullOrEmpty(serviceDll)) | ||
81 | { | ||
82 | m_log.Error("[AGENT PREFERENCES CONNECTOR]: No AgentPreferencesModule named in section AgentPreferencesService"); | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | Object[] args = new Object[] { source }; | ||
87 | m_AgentPreferencesService = ServerUtils.LoadPlugin<IAgentPreferencesService>(serviceDll, args); | ||
88 | |||
89 | if (m_AgentPreferencesService == null) | ||
90 | { | ||
91 | m_log.Error("[AGENT PREFERENCES CONNECTOR]: Can't load user account service"); | ||
92 | return; | ||
93 | } | ||
94 | m_Enabled = true; | ||
95 | m_log.Info("[AGENT PREFERENCES CONNECTOR]: Local agent preferences connector enabled"); | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public void PostInitialise() | ||
101 | { | ||
102 | if (!m_Enabled) | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | public void Close() | ||
107 | { | ||
108 | if (!m_Enabled) | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | public void AddRegion(Scene scene) | ||
113 | { | ||
114 | if (!m_Enabled) | ||
115 | return; | ||
116 | |||
117 | scene.RegisterModuleInterface<IAgentPreferencesService>(this); | ||
118 | } | ||
119 | |||
120 | public void RemoveRegion(Scene scene) | ||
121 | { | ||
122 | if (!m_Enabled) | ||
123 | return; | ||
124 | } | ||
125 | |||
126 | public void RegionLoaded(Scene scene) | ||
127 | { | ||
128 | if (!m_Enabled) | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | #endregion ISharedRegionModule | ||
133 | |||
134 | #region IAgentPreferencesService | ||
135 | |||
136 | public AgentPrefs GetAgentPreferences(UUID principalID) | ||
137 | { | ||
138 | return m_AgentPreferencesService.GetAgentPreferences(principalID); | ||
139 | } | ||
140 | |||
141 | public bool StoreAgentPreferences(AgentPrefs data) | ||
142 | { | ||
143 | return m_AgentPreferencesService.StoreAgentPreferences(data); | ||
144 | } | ||
145 | |||
146 | public string GetLang(UUID principalID) | ||
147 | { | ||
148 | return m_AgentPreferencesService.GetLang(principalID); | ||
149 | } | ||
150 | |||
151 | #endregion IAgentPreferencesService | ||
152 | } | ||
153 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/RemoteAgentPreferencesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/RemoteAgentPreferencesServiceConnector.cs new file mode 100644 index 0000000..ad9544a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/RemoteAgentPreferencesServiceConnector.cs | |||
@@ -0,0 +1,116 @@ | |||
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 | |||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using OpenSim.Services.Connectors; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using log4net; | ||
41 | using Mono.Addins; | ||
42 | using Nini.Config; | ||
43 | |||
44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.AgentPreferences | ||
45 | { | ||
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAgentPreferencesServicesConnector")] | ||
47 | public class RemoteAgentPreferencesServicesConnector : AgentPreferencesServicesConnector, | ||
48 | ISharedRegionModule, IAgentPreferencesService | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private bool m_Enabled = false; | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "RemoteAgentPreferencesServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public override void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("AgentPreferencesServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig userConfig = source.Configs["AgentPreferencesService"]; | ||
73 | if (userConfig == null) | ||
74 | { | ||
75 | m_log.Error("[AGENT PREFERENCES CONNECTOR]: AgentPreferencesService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | m_Enabled = true; | ||
80 | |||
81 | base.Initialise(source); | ||
82 | |||
83 | m_log.Info("[AGENT PREFERENCES CONNECTOR]: Remote agent preferences enabled"); | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | |||
88 | public void PostInitialise() | ||
89 | { | ||
90 | /* no op */ | ||
91 | } | ||
92 | |||
93 | public void Close() | ||
94 | { | ||
95 | /* no op */ | ||
96 | } | ||
97 | |||
98 | public void AddRegion(Scene scene) | ||
99 | { | ||
100 | if (!m_Enabled) | ||
101 | return; | ||
102 | |||
103 | scene.RegisterModuleInterface<IAgentPreferencesService>(this); | ||
104 | } | ||
105 | |||
106 | public void RemoveRegion(Scene scene) | ||
107 | { | ||
108 | /* no op */ | ||
109 | } | ||
110 | |||
111 | public void RegionLoaded(Scene scene) | ||
112 | { | ||
113 | /* no op */ | ||
114 | } | ||
115 | } | ||
116 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IAgentPreferencesModule.cs b/OpenSim/Region/Framework/Interfaces/IAgentPreferencesModule.cs deleted file mode 100644 index 4975b96..0000000 --- a/OpenSim/Region/Framework/Interfaces/IAgentPreferencesModule.cs +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
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 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Region.Framework.Interfaces | ||
32 | { | ||
33 | public interface IAgentPreferencesModule | ||
34 | { | ||
35 | string GetLang(UUID agentID); | ||
36 | } | ||
37 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c539f1f..23b2e90 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -325,6 +325,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
325 | protected IUserAccountService m_UserAccountService; | 325 | protected IUserAccountService m_UserAccountService; |
326 | protected IAvatarService m_AvatarService; | 326 | protected IAvatarService m_AvatarService; |
327 | protected IGridUserService m_GridUserService; | 327 | protected IGridUserService m_GridUserService; |
328 | protected IAgentPreferencesService m_AgentPreferencesService; | ||
328 | 329 | ||
329 | protected IXMLRPC m_xmlrpcModule; | 330 | protected IXMLRPC m_xmlrpcModule; |
330 | protected IWorldComm m_worldCommModule; | 331 | protected IWorldComm m_worldCommModule; |
@@ -728,6 +729,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | } | 729 | } |
729 | } | 730 | } |
730 | 731 | ||
732 | public IAgentPreferencesService AgentPreferencesService | ||
733 | { | ||
734 | get | ||
735 | { | ||
736 | if (m_AgentPreferencesService == null) | ||
737 | m_AgentPreferencesService = RequestModuleInterface<IAgentPreferencesService>(); | ||
738 | return m_AgentPreferencesService; | ||
739 | } | ||
740 | } | ||
741 | |||
731 | public IAttachmentsModule AttachmentsModule { get; set; } | 742 | public IAttachmentsModule AttachmentsModule { get; set; } |
732 | public IEntityTransferModule EntityTransferModule { get; private set; } | 743 | public IEntityTransferModule EntityTransferModule { get; private set; } |
733 | public IAgentAssetTransactions AgentTransactionsModule { get; private set; } | 744 | public IAgentAssetTransactions AgentTransactionsModule { get; private set; } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b50f429..75b40af 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -6149,14 +6149,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6149 | { | 6149 | { |
6150 | // This should only return a value if the avatar is in the same region, but eh. idc. | 6150 | // This should only return a value if the avatar is in the same region, but eh. idc. |
6151 | m_host.AddScriptLPS(1); | 6151 | m_host.AddScriptLPS(1); |
6152 | IAgentPreferencesModule ap = World.RequestModuleInterface<IAgentPreferencesModule>(); | 6152 | UUID key = new UUID(); |
6153 | if (ap != null) | 6153 | if (UUID.TryParse(id, out key)) |
6154 | { | 6154 | { |
6155 | UUID key = new UUID(); | 6155 | return new LSL_String(World.AgentPreferencesService.GetLang(key)); |
6156 | if (UUID.TryParse(id, out key)) | ||
6157 | { | ||
6158 | return ap.GetLang(key); | ||
6159 | } | ||
6160 | } | 6156 | } |
6161 | return new LSL_String("en-us"); | 6157 | return new LSL_String("en-us"); |
6162 | } | 6158 | } |