aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserProfilesService/UserProfilesService.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Services/UserProfilesService/UserProfilesService.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Services/UserProfilesService/UserProfilesService.cs')
-rw-r--r--OpenSim/Services/UserProfilesService/UserProfilesService.cs263
1 files changed, 263 insertions, 0 deletions
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
new file mode 100644
index 0000000..96c13c0
--- /dev/null
+++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
@@ -0,0 +1,263 @@
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
28using System;
29using System.Reflection;
30using System.Text;
31using Nini.Config;
32using log4net;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.UserAccountService;
36using OpenSim.Data;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40
41namespace OpenSim.Services.ProfilesService
42{
43 public class UserProfilesService: UserProfilesServiceBase, IUserProfilesService
44 {
45 static readonly ILog m_log =
46 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType);
48
49 IUserAccountService userAccounts;
50
51 public UserProfilesService(IConfigSource config, string configName):
52 base(config, configName)
53 {
54 IConfig Config = config.Configs[configName];
55 if (Config == null)
56 {
57 m_log.Warn("[PROFILES SERVICE]: No configuration found!");
58 return;
59 }
60 Object[] args = null;
61
62 args = new Object[] { config };
63 string accountService = Config.GetString("UserAccountService", String.Empty);
64 if (accountService != string.Empty)
65 userAccounts = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
66
67 args = new Object[] { config };
68 }
69
70 #region Classifieds
71 public OSD AvatarClassifiedsRequest(UUID creatorId)
72 {
73 OSDArray records = ProfilesData.GetClassifiedRecords(creatorId);
74
75 return records;
76 }
77
78 public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result)
79 {
80 if(!ProfilesData.UpdateClassifiedRecord(ad, ref result))
81 {
82 return false;
83 }
84 result = "success";
85 return true;
86 }
87
88 public bool ClassifiedDelete(UUID recordId)
89 {
90 if(ProfilesData.DeleteClassifiedRecord(recordId))
91 return true;
92
93 return false;
94 }
95
96 public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result)
97 {
98 if(ProfilesData.GetClassifiedInfo(ref ad, ref result))
99 return true;
100
101 return false;
102 }
103 #endregion Classifieds
104
105 #region Picks
106 public OSD AvatarPicksRequest(UUID creatorId)
107 {
108 OSDArray records = ProfilesData.GetAvatarPicks(creatorId);
109
110 return records;
111 }
112
113 public bool PickInfoRequest(ref UserProfilePick pick, ref string result)
114 {
115 pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId);
116 result = "OK";
117 return true;
118 }
119
120 public bool PicksUpdate(ref UserProfilePick pick, ref string result)
121 {
122 return ProfilesData.UpdatePicksRecord(pick);
123 }
124
125 public bool PicksDelete(UUID pickId)
126 {
127 return ProfilesData.DeletePicksRecord(pickId);
128 }
129 #endregion Picks
130
131 #region Notes
132 public bool AvatarNotesRequest(ref UserProfileNotes note)
133 {
134 return ProfilesData.GetAvatarNotes(ref note);
135 }
136
137 public bool NotesUpdate(ref UserProfileNotes note, ref string result)
138 {
139 return ProfilesData.UpdateAvatarNotes(ref note, ref result);
140 }
141 #endregion Notes
142
143 #region Profile Properties
144 public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result)
145 {
146 return ProfilesData.GetAvatarProperties(ref prop, ref result);
147 }
148
149 public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result)
150 {
151 return ProfilesData.UpdateAvatarProperties(ref prop, ref result);
152 }
153 #endregion Profile Properties
154
155 #region Interests
156 public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result)
157 {
158 return ProfilesData.UpdateAvatarInterests(prop, ref result);
159 }
160 #endregion Interests
161
162 #region User Preferences
163 public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result)
164 {
165 if(string.IsNullOrEmpty(pref.EMail))
166 {
167 UserAccount account = new UserAccount();
168 if(userAccounts is UserAccountService.UserAccountService)
169 {
170 try
171 {
172 account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId);
173 if(string.IsNullOrEmpty(account.Email))
174 {
175 pref.EMail = string.Empty;
176 }
177 else
178 pref.EMail = account.Email;
179 }
180 catch
181 {
182 m_log.Error ("[PROFILES SERVICE]: UserAccountService Exception: Could not get user account");
183 result = "UserAccountService settings error in UserProfileService!";
184 return false;
185 }
186 }
187 else
188 {
189 m_log.Error ("[PROFILES SERVICE]: UserAccountService: Could not get user account");
190 result = "UserAccountService settings error in UserProfileService!";
191 return false;
192 }
193 }
194 return ProfilesData.UpdateUserPreferences(ref pref, ref result);
195 }
196
197 public bool UserPreferencesRequest(ref UserPreferences pref, ref string result)
198 {
199 if (!ProfilesData.GetUserPreferences(ref pref, ref result))
200 return false;
201
202 if(string.IsNullOrEmpty(pref.EMail))
203 {
204 UserAccount account = new UserAccount();
205 if(userAccounts is UserAccountService.UserAccountService)
206 {
207 try
208 {
209 account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId);
210 if(string.IsNullOrEmpty(account.Email))
211 {
212 pref.EMail = string.Empty;
213 }
214 else
215 {
216 pref.EMail = account.Email;
217 UserPreferencesUpdate(ref pref, ref result);
218 }
219 }
220 catch
221 {
222 m_log.Error ("[PROFILES SERVICE]: UserAccountService Exception: Could not get user account");
223 result = "UserAccountService settings error in UserProfileService!";
224 return false;
225 }
226 }
227 else
228 {
229 m_log.Error ("[PROFILES SERVICE]: UserAccountService: Could not get user account");
230 result = "UserAccountService settings error in UserProfileService!";
231 return false;
232 }
233 }
234
235 if(string.IsNullOrEmpty(pref.EMail))
236 pref.EMail = "No Email Address On Record";
237
238 return true;
239 }
240 #endregion User Preferences
241
242 #region Utility
243 public OSD AvatarImageAssetsRequest(UUID avatarId)
244 {
245 OSDArray records = ProfilesData.GetUserImageAssets(avatarId);
246 return records;
247 }
248 #endregion Utility
249
250 #region UserData
251 public bool RequestUserAppData(ref UserAppData prop, ref string result)
252 {
253 return ProfilesData.GetUserAppData(ref prop, ref result);
254 }
255
256 public bool SetUserAppData(UserAppData prop, ref string result)
257 {
258 return true;
259 }
260 #endregion UserData
261 }
262}
263