clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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 System.Text;
31 using Nini.Config;
32 using log4net;
33 using OpenSim.Server.Base;
34 using OpenSim.Services.Interfaces;
35 using OpenSim.Services.UserAccountService;
36 using OpenSim.Data;
37 using OpenMetaverse;
38 using OpenMetaverse.StructuredData;
39 using OpenSim.Framework;
40  
41 namespace 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 IAuthenticationService authService;
51  
52 public UserProfilesService(IConfigSource config, string configName):
53 base(config, configName)
54 {
55 IConfig Config = config.Configs[configName];
56 if (Config == null)
57 {
58 m_log.Warn("[PROFILES]: No configuration found!");
59 return;
60 }
61 Object[] args = null;
62  
63 args = new Object[] { config };
64 string accountService = Config.GetString("UserAccountService", String.Empty);
65 if (accountService != string.Empty)
66 userAccounts = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
67  
68 args = new Object[] { config };
69 string authServiceConfig = Config.GetString("AuthenticationServiceModule", String.Empty);
70 if (accountService != string.Empty)
71 authService = ServerUtils.LoadPlugin<IAuthenticationService>(authServiceConfig, args);
72 }
73  
74 #region Classifieds
75 public OSD AvatarClassifiedsRequest(UUID creatorId)
76 {
77 OSDArray records = ProfilesData.GetClassifiedRecords(creatorId);
78  
79 return records;
80 }
81  
82 public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result)
83 {
84 if(!ProfilesData.UpdateClassifiedRecord(ad, ref result))
85 {
86 return false;
87 }
88 result = "success";
89 return true;
90 }
91  
92 public bool ClassifiedDelete(UUID recordId)
93 {
94 if(ProfilesData.DeleteClassifiedRecord(recordId))
95 return true;
96  
97 return false;
98 }
99  
100 public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result)
101 {
102 if(ProfilesData.GetClassifiedInfo(ref ad, ref result))
103 return true;
104  
105 return false;
106 }
107 #endregion Classifieds
108  
109 #region Picks
110 public OSD AvatarPicksRequest(UUID creatorId)
111 {
112 OSDArray records = ProfilesData.GetAvatarPicks(creatorId);
113  
114 return records;
115 }
116  
117 public bool PickInfoRequest(ref UserProfilePick pick, ref string result)
118 {
119 pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId);
120 result = "OK";
121 return true;
122 }
123  
124 public bool PicksUpdate(ref UserProfilePick pick, ref string result)
125 {
126 return ProfilesData.UpdatePicksRecord(pick);
127 }
128  
129 public bool PicksDelete(UUID pickId)
130 {
131 return ProfilesData.DeletePicksRecord(pickId);
132 }
133 #endregion Picks
134  
135 #region Notes
136 public bool AvatarNotesRequest(ref UserProfileNotes note)
137 {
138 return ProfilesData.GetAvatarNotes(ref note);
139 }
140  
141 public bool NotesUpdate(ref UserProfileNotes note, ref string result)
142 {
143 return ProfilesData.UpdateAvatarNotes(ref note, ref result);
144 }
145 #endregion Notes
146  
147 #region Profile Properties
148 public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result)
149 {
150 return ProfilesData.GetAvatarProperties(ref prop, ref result);
151 }
152  
153 public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result)
154 {
155 return ProfilesData.UpdateAvatarProperties(ref prop, ref result);
156 }
157 #endregion Profile Properties
158  
159 #region Interests
160 public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result)
161 {
162 return ProfilesData.UpdateAvatarInterests(prop, ref result);
163 }
164 #endregion Interests
165  
166 #region User Preferences
167 public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result)
168 {
169 if(string.IsNullOrEmpty(pref.EMail))
170 {
171 UserAccount account = new UserAccount();
172 if(userAccounts is UserAccountService.UserAccountService)
173 {
174 try
175 {
176 account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId);
177 if(string.IsNullOrEmpty(account.Email))
178 {
179 result = "No Email address on record!";
180 return false;
181 }
182 else
183 pref.EMail = account.Email;
184 }
185 catch
186 {
187 m_log.Info ("[PROFILES]: UserAccountService Exception: Could not get user account");
188 result = "Missing Email address!";
189 return false;
190 }
191 }
192 else
193 {
194 m_log.Info ("[PROFILES]: UserAccountService: Could not get user account");
195 result = "Missing Email address!";
196 return false;
197 }
198 }
199 return ProfilesData.UpdateUserPreferences(ref pref, ref result);
200 }
201  
202 public bool UserPreferencesRequest(ref UserPreferences pref, ref string result)
203 {
204 if(string.IsNullOrEmpty(pref.EMail))
205 {
206 UserAccount account = new UserAccount();
207 if(userAccounts is UserAccountService.UserAccountService)
208 {
209 try
210 {
211 account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId);
212 if(string.IsNullOrEmpty(account.Email))
213 {
214 result = "No Email address on record!";
215 return false;
216 }
217 else
218 pref.EMail = account.Email;
219 }
220 catch
221 {
222 m_log.Info ("[PROFILES]: UserAccountService Exception: Could not get user account");
223 result = "Missing Email address!";
224 return false;
225 }
226 }
227 else
228 {
229 m_log.Info ("[PROFILES]: UserAccountService: Could not get user account");
230 result = "Missing Email address!";
231 return false;
232 }
233 }
234 return ProfilesData.GetUserPreferences(ref pref, ref result);
235 }
236 #endregion User Preferences
237  
238 #region Utility
239 public OSD AvatarImageAssetsRequest(UUID avatarId)
240 {
241 OSDArray records = ProfilesData.GetUserImageAssets(avatarId);
242 return records;
243 }
244 #endregion Utility
245  
246 #region UserData
247 public bool RequestUserAppData(ref UserAppData prop, ref string result)
248 {
249 return ProfilesData.GetUserAppData(ref prop, ref result);
250 }
251  
252 public bool SetUserAppData(UserAppData prop, ref string result)
253 {
254 return true;
255 }
256 #endregion UserData
257 }
258 }
259