opensim – Blame information for rev 1

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