diff options
Diffstat (limited to 'OpenSim/Services')
4 files changed, 498 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs new file mode 100644 index 0000000..1dbc0c8 --- /dev/null +++ b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs | |||
@@ -0,0 +1,230 @@ | |||
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 log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.ServiceAuth; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | using IAvatarService = OpenSim.Services.Interfaces.IAvatarService; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Services.Connectors | ||
43 | { | ||
44 | public class AgentPreferencesServicesConnector : BaseServiceConnector, IAgentPreferencesService | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private string m_ServerURI = String.Empty; | ||
49 | |||
50 | public AgentPreferencesServicesConnector() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | public AgentPreferencesServicesConnector(string serverURI) | ||
55 | { | ||
56 | m_ServerURI = serverURI.TrimEnd('/'); | ||
57 | } | ||
58 | |||
59 | public AgentPreferencesServicesConnector(IConfigSource source) | ||
60 | : base(source, "AgentPreferencesService") | ||
61 | { | ||
62 | Initialise(source); | ||
63 | } | ||
64 | |||
65 | public virtual void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig gridConfig = source.Configs["AgentPreferencesService"]; | ||
68 | if (gridConfig == null) | ||
69 | { | ||
70 | m_log.Error("[AGENT PREFERENCES CONNECTOR]: AgentPreferencesService missing from OpenSim.ini"); | ||
71 | throw new Exception("Agent Preferences connector init error"); | ||
72 | } | ||
73 | |||
74 | string serviceURI = gridConfig.GetString("AgentPreferencesServerURI", String.Empty); | ||
75 | |||
76 | if (serviceURI == String.Empty) | ||
77 | { | ||
78 | m_log.Error("[AGENT PREFERENCES CONNECTOR]: No Server URI named in section AgentPreferences"); | ||
79 | throw new Exception("Agent Preferences connector init error"); | ||
80 | } | ||
81 | m_ServerURI = serviceURI; | ||
82 | |||
83 | base.Initialise(source, "AgentPreferencesService"); | ||
84 | } | ||
85 | |||
86 | #region IAgentPreferencesService | ||
87 | |||
88 | public AgentPrefs GetAgentPreferences(UUID principalID) | ||
89 | { | ||
90 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
91 | |||
92 | string reply = string.Empty; | ||
93 | string uri = String.Concat(m_ServerURI, "/agentprefs"); | ||
94 | |||
95 | sendData["METHOD"] = "getagentprefs"; | ||
96 | sendData["UserID"] = principalID; | ||
97 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
98 | // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString); | ||
99 | |||
100 | try | ||
101 | { | ||
102 | reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); | ||
103 | if (String.IsNullOrEmpty(reply)) | ||
104 | { | ||
105 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null or empty reply"); | ||
106 | return null; | ||
107 | } | ||
108 | } | ||
109 | catch (Exception e) | ||
110 | { | ||
111 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message); | ||
112 | } | ||
113 | |||
114 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
115 | if (replyData != null) | ||
116 | { | ||
117 | if (replyData.ContainsKey("result") && | ||
118 | (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure")) | ||
119 | { | ||
120 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received Failure response"); | ||
121 | return null; | ||
122 | } | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null response"); | ||
127 | return null; | ||
128 | } | ||
129 | AgentPrefs prefs = new AgentPrefs(replyData); | ||
130 | return prefs; | ||
131 | } | ||
132 | |||
133 | public bool StoreAgentPreferences(AgentPrefs data) | ||
134 | { | ||
135 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
136 | |||
137 | sendData["METHOD"] = "setagentprefs"; | ||
138 | |||
139 | sendData["PrincipalID"] = data.PrincipalID.ToString(); | ||
140 | sendData["AccessPrefs"] = data.AccessPrefs; | ||
141 | sendData["HoverHeight"] = data.HoverHeight.ToString(); | ||
142 | sendData["Language"] = data.Language; | ||
143 | sendData["LanguageIsPublic"] = data.LanguageIsPublic.ToString(); | ||
144 | sendData["PermEveryone"] = data.PermEveryone.ToString(); | ||
145 | sendData["PermGroup"] = data.PermGroup.ToString(); | ||
146 | sendData["PermNextOwner"] = data.PermNextOwner.ToString(); | ||
147 | |||
148 | string uri = String.Concat(m_ServerURI, "/agentprefs"); | ||
149 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
150 | // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString); | ||
151 | |||
152 | try | ||
153 | { | ||
154 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); | ||
155 | if (reply != string.Empty) | ||
156 | { | ||
157 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
158 | |||
159 | if (replyData.ContainsKey("result")) | ||
160 | { | ||
161 | if (replyData["result"].ToString().ToLower() == "success") | ||
162 | return true; | ||
163 | else | ||
164 | return false; | ||
165 | } | ||
166 | else | ||
167 | { | ||
168 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences reply data does not contain result field"); | ||
169 | } | ||
170 | |||
171 | } | ||
172 | else | ||
173 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences received empty reply"); | ||
174 | } | ||
175 | catch (Exception e) | ||
176 | { | ||
177 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message); | ||
178 | } | ||
179 | |||
180 | return false; | ||
181 | } | ||
182 | |||
183 | public string GetLang(UUID principalID) | ||
184 | { | ||
185 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
186 | string reply = string.Empty; | ||
187 | |||
188 | sendData["METHOD"] = "getagentlang"; | ||
189 | sendData["UserID"] = principalID.ToString(); | ||
190 | |||
191 | string uri = String.Concat(m_ServerURI, "/agentprefs"); | ||
192 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
193 | |||
194 | try | ||
195 | { | ||
196 | reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); | ||
197 | if (String.IsNullOrEmpty(reply)) | ||
198 | { | ||
199 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received null or empty reply"); | ||
200 | return "en-us"; // I guess? Gotta return somethin'! | ||
201 | } | ||
202 | } | ||
203 | catch (Exception e) | ||
204 | { | ||
205 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message); | ||
206 | } | ||
207 | |||
208 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
209 | if (replyData != null) | ||
210 | { | ||
211 | if (replyData.ContainsKey("result") && | ||
212 | (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure")) | ||
213 | { | ||
214 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received Failure response"); | ||
215 | return "en-us"; | ||
216 | } | ||
217 | if (replyData.ContainsKey("Language")) | ||
218 | return replyData["Language"].ToString(); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received null response"); | ||
223 | |||
224 | } | ||
225 | return "en-us"; | ||
226 | } | ||
227 | |||
228 | #endregion IAgentPreferencesService | ||
229 | } | ||
230 | } | ||
diff --git a/OpenSim/Services/Interfaces/IAgentPreferencesService.cs b/OpenSim/Services/Interfaces/IAgentPreferencesService.cs new file mode 100644 index 0000000..b74b580 --- /dev/null +++ b/OpenSim/Services/Interfaces/IAgentPreferencesService.cs | |||
@@ -0,0 +1,115 @@ | |||
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 OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Services.Interfaces | ||
33 | { | ||
34 | public class AgentPrefs | ||
35 | { | ||
36 | public AgentPrefs(UUID principalID) | ||
37 | { | ||
38 | principalID = PrincipalID; | ||
39 | } | ||
40 | |||
41 | public AgentPrefs(Dictionary<string, string> kvp) | ||
42 | { | ||
43 | if (kvp.ContainsKey("PrincipalID")) | ||
44 | UUID.TryParse(kvp["PrincipalID"], out PrincipalID); | ||
45 | if (kvp.ContainsKey("AccessPrefs")) | ||
46 | AccessPrefs = kvp["AccessPrefs"]; | ||
47 | if (kvp.ContainsKey("HoverHeight")) | ||
48 | HoverHeight = double.Parse(kvp["HoverHeight"]); | ||
49 | if (kvp.ContainsKey("Language")) | ||
50 | Language = kvp["Language"]; | ||
51 | if (kvp.ContainsKey("LanguageIsPublic")) | ||
52 | LanguageIsPublic = bool.Parse(kvp["LanguageIsPublic"]); | ||
53 | if (kvp.ContainsKey("PermEveryone")) | ||
54 | PermEveryone = int.Parse(kvp["PermEveryone"]); | ||
55 | if (kvp.ContainsKey("PermGroup")) | ||
56 | PermGroup = int.Parse(kvp["PermGroup"]); | ||
57 | if (kvp.ContainsKey("PermNextOwner")) | ||
58 | PermNextOwner = int.Parse(kvp["PermNextOwner"]); | ||
59 | } | ||
60 | |||
61 | public AgentPrefs(Dictionary<string, object> kvp) | ||
62 | { | ||
63 | if (kvp.ContainsKey("PrincipalID")) | ||
64 | UUID.TryParse(kvp["PrincipalID"].ToString(), out PrincipalID); | ||
65 | if (kvp.ContainsKey("AccessPrefs")) | ||
66 | AccessPrefs = kvp["AccessPrefs"].ToString(); | ||
67 | if (kvp.ContainsKey("HoverHeight")) | ||
68 | HoverHeight = double.Parse(kvp["HoverHeight"].ToString()); | ||
69 | if (kvp.ContainsKey("Language")) | ||
70 | Language = kvp["Language"].ToString(); | ||
71 | if (kvp.ContainsKey("LanguageIsPublic")) | ||
72 | LanguageIsPublic = bool.Parse(kvp["LanguageIsPublic"].ToString()); | ||
73 | if (kvp.ContainsKey("PermEveryone")) | ||
74 | PermEveryone = int.Parse(kvp["PermEveryone"].ToString()); | ||
75 | if (kvp.ContainsKey("PermGroup")) | ||
76 | PermGroup = int.Parse(kvp["PermGroup"].ToString()); | ||
77 | if (kvp.ContainsKey("PermNextOwner")) | ||
78 | PermNextOwner = int.Parse(kvp["PermNextOwner"].ToString()); | ||
79 | } | ||
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 | |||
95 | public UUID PrincipalID = UUID.Zero; | ||
96 | public string AccessPrefs = "M"; | ||
97 | //public int GodLevel; // *TODO: Implement GodLevel (Unused by the viewer, afaict - 6/11/2015) | ||
98 | public double HoverHeight = 0.0; | ||
99 | public string Language = "en-us"; | ||
100 | public bool LanguageIsPublic = true; | ||
101 | // DefaultObjectPermMasks | ||
102 | public int PermEveryone = 0; | ||
103 | public int PermGroup = 0; | ||
104 | public int PermNextOwner = 532480; | ||
105 | } | ||
106 | |||
107 | public interface IAgentPreferencesService | ||
108 | { | ||
109 | AgentPrefs GetAgentPreferences(UUID principalID); | ||
110 | bool StoreAgentPreferences(AgentPrefs data); | ||
111 | |||
112 | string GetLang(UUID principalID); | ||
113 | } | ||
114 | } | ||
115 | |||
diff --git a/OpenSim/Services/UserAccountService/AgentPreferencesService.cs b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs new file mode 100644 index 0000000..f8d2e29 --- /dev/null +++ b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs | |||
@@ -0,0 +1,80 @@ | |||
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.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Data; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | |||
37 | namespace OpenSim.Services.UserAccountService | ||
38 | { | ||
39 | public class AgentPreferencesService : AgentPreferencesServiceBase, IAgentPreferencesService | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | public AgentPreferencesService(IConfigSource config) : base(config) | ||
44 | { | ||
45 | m_log.Debug("[AGENT PREFERENCES SERVICE]: Starting agent preferences service"); | ||
46 | } | ||
47 | |||
48 | public AgentPrefs GetAgentPreferences(UUID principalID) | ||
49 | { | ||
50 | AgentPreferencesData d = m_Database.GetPrefs(principalID); | ||
51 | AgentPrefs prefs = (d == null) ? new AgentPrefs(principalID) : new AgentPrefs(d.Data); | ||
52 | return prefs; | ||
53 | } | ||
54 | |||
55 | public bool StoreAgentPreferences(AgentPrefs data) | ||
56 | { | ||
57 | AgentPreferencesData d = new AgentPreferencesData(); | ||
58 | d.Data["PrincipalID"] = data.PrincipalID.ToString(); | ||
59 | d.Data["AccessPrefs"] = data.AccessPrefs; | ||
60 | d.Data["HoverHeight"] = data.HoverHeight.ToString(); | ||
61 | d.Data["Language"] = data.Language; | ||
62 | d.Data["LanguageIsPublic"] = data.LanguageIsPublic.ToString(); | ||
63 | d.Data["PermEveryone"] = data.PermEveryone.ToString(); | ||
64 | d.Data["PermGroup"] = data.PermGroup.ToString(); | ||
65 | d.Data["PermNextOwner"] = data.PermNextOwner.ToString(); | ||
66 | return m_Database.Store(d); | ||
67 | } | ||
68 | |||
69 | public string GetLang(UUID principalID) | ||
70 | { | ||
71 | AgentPrefs data = GetAgentPreferences(principalID); | ||
72 | if (data != null) | ||
73 | { | ||
74 | if (data.LanguageIsPublic) | ||
75 | return data.Language; | ||
76 | } | ||
77 | return "en-us"; | ||
78 | } | ||
79 | } | ||
80 | } | ||
diff --git a/OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs b/OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs new file mode 100644 index 0000000..5974349 --- /dev/null +++ b/OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs | |||
@@ -0,0 +1,73 @@ | |||
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.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Data; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using OpenSim.Services.Base; | ||
34 | |||
35 | namespace OpenSim.Services.UserAccountService | ||
36 | { | ||
37 | public class AgentPreferencesServiceBase: ServiceBase | ||
38 | { | ||
39 | protected IAgentPreferencesData m_Database = null; | ||
40 | |||
41 | public AgentPreferencesServiceBase(IConfigSource config) : base(config) | ||
42 | { | ||
43 | string dllName = String.Empty; | ||
44 | string connString = String.Empty; | ||
45 | string realm = "AgentPrefs"; | ||
46 | |||
47 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
48 | if (dbConfig != null) | ||
49 | { | ||
50 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
51 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
52 | } | ||
53 | |||
54 | IConfig userConfig = config.Configs["AgentPreferencesService"]; | ||
55 | if (userConfig == null) | ||
56 | throw new Exception("No AgentPreferencesService configuration"); | ||
57 | |||
58 | dllName = userConfig.GetString("StorageProvider", dllName); | ||
59 | |||
60 | if (dllName == String.Empty) | ||
61 | throw new Exception("No StorageProvider configured"); | ||
62 | |||
63 | connString = userConfig.GetString("ConnectionString", connString); | ||
64 | |||
65 | realm = userConfig.GetString("Realm", realm); | ||
66 | |||
67 | m_Database = LoadPlugin<IAgentPreferencesData>(dllName, new Object[] {connString, realm}); | ||
68 | |||
69 | if (m_Database == null) | ||
70 | throw new Exception("Could not find a storage interface in the given module"); | ||
71 | } | ||
72 | } | ||
73 | } | ||