diff options
author | Mike Mazur | 2009-02-24 23:40:08 +0000 |
---|---|---|
committer | Mike Mazur | 2009-02-24 23:40:08 +0000 |
commit | d81fb565c1f48b013d107651c3bf383bd59e4daa (patch) | |
tree | 78b90903c6ee6dbce33f28b352d64e3b82fe3768 /OpenSim/Grid/UserServer.Modules/UserManager.cs | |
parent | Close-to-final tweaking with appearance. This time sending *everything*. Addr... (diff) | |
download | opensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.zip opensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.tar.gz opensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.tar.bz2 opensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.tar.xz |
Setting svn:eol-style=native on new files.
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/UserManager.cs')
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserManager.cs | 1372 |
1 files changed, 686 insertions, 686 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs index dd9f495..c6c3a1a 100644 --- a/OpenSim/Grid/UserServer.Modules/UserManager.cs +++ b/OpenSim/Grid/UserServer.Modules/UserManager.cs | |||
@@ -1,686 +1,686 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using Nwc.XmlRpc; | 33 | using Nwc.XmlRpc; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications; | 36 | using OpenSim.Framework.Communications; |
37 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
38 | 38 | ||
39 | namespace OpenSim.Grid.UserServer.Modules | 39 | namespace OpenSim.Grid.UserServer.Modules |
40 | { | 40 | { |
41 | public delegate void logOffUser(UUID AgentID); | 41 | public delegate void logOffUser(UUID AgentID); |
42 | 42 | ||
43 | public class UserManager | 43 | public class UserManager |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | public event logOffUser OnLogOffUser; | 47 | public event logOffUser OnLogOffUser; |
48 | private logOffUser handlerLogOffUser; | 48 | private logOffUser handlerLogOffUser; |
49 | 49 | ||
50 | private UserDataBaseService m_userDataBaseService; | 50 | private UserDataBaseService m_userDataBaseService; |
51 | private BaseHttpServer m_httpServer; | 51 | private BaseHttpServer m_httpServer; |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// | 54 | /// |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <param name="userDataBaseService"></param> | 56 | /// <param name="userDataBaseService"></param> |
57 | public UserManager( UserDataBaseService userDataBaseService) | 57 | public UserManager( UserDataBaseService userDataBaseService) |
58 | { | 58 | { |
59 | m_userDataBaseService = userDataBaseService; | 59 | m_userDataBaseService = userDataBaseService; |
60 | } | 60 | } |
61 | 61 | ||
62 | public void Initialise() | 62 | public void Initialise() |
63 | { | 63 | { |
64 | 64 | ||
65 | } | 65 | } |
66 | 66 | ||
67 | public void PostInitialise() | 67 | public void PostInitialise() |
68 | { | 68 | { |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | public void RegisterHandlers(BaseHttpServer httpServer) | 72 | public void RegisterHandlers(BaseHttpServer httpServer) |
73 | { | 73 | { |
74 | m_httpServer = httpServer; | 74 | m_httpServer = httpServer; |
75 | 75 | ||
76 | m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName); | 76 | m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName); |
77 | m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); | 77 | m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); |
78 | m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); | 78 | m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); |
79 | 79 | ||
80 | m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); | 80 | m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); |
81 | m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); | 81 | m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); |
82 | m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); | 82 | m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); |
83 | m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession); | 83 | m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession); |
84 | 84 | ||
85 | m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile); | 85 | m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile); |
86 | 86 | ||
87 | m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod)); | 87 | m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod)); |
88 | } | 88 | } |
89 | 89 | ||
90 | /// <summary> | 90 | /// <summary> |
91 | /// Deletes an active agent session | 91 | /// Deletes an active agent session |
92 | /// </summary> | 92 | /// </summary> |
93 | /// <param name="request">The request</param> | 93 | /// <param name="request">The request</param> |
94 | /// <param name="path">The path (eg /bork/narf/test)</param> | 94 | /// <param name="path">The path (eg /bork/narf/test)</param> |
95 | /// <param name="param">Parameters sent</param> | 95 | /// <param name="param">Parameters sent</param> |
96 | /// <param name="httpRequest">HTTP request header object</param> | 96 | /// <param name="httpRequest">HTTP request header object</param> |
97 | /// <param name="httpResponse">HTTP response header object</param> | 97 | /// <param name="httpResponse">HTTP response header object</param> |
98 | /// <returns>Success "OK" else error</returns> | 98 | /// <returns>Success "OK" else error</returns> |
99 | public string RestDeleteUserSessionMethod(string request, string path, string param, | 99 | public string RestDeleteUserSessionMethod(string request, string path, string param, |
100 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 100 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
101 | { | 101 | { |
102 | // TODO! Important! | 102 | // TODO! Important! |
103 | 103 | ||
104 | return "OK"; | 104 | return "OK"; |
105 | } | 105 | } |
106 | 106 | ||
107 | /// <summary> | 107 | /// <summary> |
108 | /// Returns an error message that the user could not be found in the database | 108 | /// Returns an error message that the user could not be found in the database |
109 | /// </summary> | 109 | /// </summary> |
110 | /// <returns>XML string consisting of a error element containing individual error(s)</returns> | 110 | /// <returns>XML string consisting of a error element containing individual error(s)</returns> |
111 | public XmlRpcResponse CreateUnknownUserErrorResponse() | 111 | public XmlRpcResponse CreateUnknownUserErrorResponse() |
112 | { | 112 | { |
113 | XmlRpcResponse response = new XmlRpcResponse(); | 113 | XmlRpcResponse response = new XmlRpcResponse(); |
114 | Hashtable responseData = new Hashtable(); | 114 | Hashtable responseData = new Hashtable(); |
115 | responseData["error_type"] = "unknown_user"; | 115 | responseData["error_type"] = "unknown_user"; |
116 | responseData["error_desc"] = "The user requested is not in the database"; | 116 | responseData["error_desc"] = "The user requested is not in the database"; |
117 | 117 | ||
118 | response.Value = responseData; | 118 | response.Value = responseData; |
119 | return response; | 119 | return response; |
120 | } | 120 | } |
121 | 121 | ||
122 | public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List<AvatarPickerAvatar> returnUsers) | 122 | public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List<AvatarPickerAvatar> returnUsers) |
123 | { | 123 | { |
124 | XmlRpcResponse response = new XmlRpcResponse(); | 124 | XmlRpcResponse response = new XmlRpcResponse(); |
125 | Hashtable responseData = new Hashtable(); | 125 | Hashtable responseData = new Hashtable(); |
126 | // Query Result Information | 126 | // Query Result Information |
127 | responseData["queryid"] = queryID.ToString(); | 127 | responseData["queryid"] = queryID.ToString(); |
128 | responseData["avcount"] = returnUsers.Count.ToString(); | 128 | responseData["avcount"] = returnUsers.Count.ToString(); |
129 | 129 | ||
130 | for (int i = 0; i < returnUsers.Count; i++) | 130 | for (int i = 0; i < returnUsers.Count; i++) |
131 | { | 131 | { |
132 | responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString(); | 132 | responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString(); |
133 | responseData["firstname" + i] = returnUsers[i].firstName; | 133 | responseData["firstname" + i] = returnUsers[i].firstName; |
134 | responseData["lastname" + i] = returnUsers[i].lastName; | 134 | responseData["lastname" + i] = returnUsers[i].lastName; |
135 | } | 135 | } |
136 | response.Value = responseData; | 136 | response.Value = responseData; |
137 | 137 | ||
138 | return response; | 138 | return response; |
139 | } | 139 | } |
140 | 140 | ||
141 | /// <summary> | 141 | /// <summary> |
142 | /// Converts a user profile to an XML element which can be returned | 142 | /// Converts a user profile to an XML element which can be returned |
143 | /// </summary> | 143 | /// </summary> |
144 | /// <param name="profile">The user profile</param> | 144 | /// <param name="profile">The user profile</param> |
145 | /// <returns>A string containing an XML Document of the user profile</returns> | 145 | /// <returns>A string containing an XML Document of the user profile</returns> |
146 | public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) | 146 | public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) |
147 | { | 147 | { |
148 | XmlRpcResponse response = new XmlRpcResponse(); | 148 | XmlRpcResponse response = new XmlRpcResponse(); |
149 | Hashtable responseData = new Hashtable(); | 149 | Hashtable responseData = new Hashtable(); |
150 | 150 | ||
151 | // Account information | 151 | // Account information |
152 | responseData["firstname"] = profile.FirstName; | 152 | responseData["firstname"] = profile.FirstName; |
153 | responseData["lastname"] = profile.SurName; | 153 | responseData["lastname"] = profile.SurName; |
154 | responseData["uuid"] = profile.ID.ToString(); | 154 | responseData["uuid"] = profile.ID.ToString(); |
155 | // Server Information | 155 | // Server Information |
156 | responseData["server_inventory"] = profile.UserInventoryURI; | 156 | responseData["server_inventory"] = profile.UserInventoryURI; |
157 | responseData["server_asset"] = profile.UserAssetURI; | 157 | responseData["server_asset"] = profile.UserAssetURI; |
158 | // Profile Information | 158 | // Profile Information |
159 | responseData["profile_about"] = profile.AboutText; | 159 | responseData["profile_about"] = profile.AboutText; |
160 | responseData["profile_firstlife_about"] = profile.FirstLifeAboutText; | 160 | responseData["profile_firstlife_about"] = profile.FirstLifeAboutText; |
161 | responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString(); | 161 | responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString(); |
162 | responseData["profile_can_do"] = profile.CanDoMask.ToString(); | 162 | responseData["profile_can_do"] = profile.CanDoMask.ToString(); |
163 | responseData["profile_want_do"] = profile.WantDoMask.ToString(); | 163 | responseData["profile_want_do"] = profile.WantDoMask.ToString(); |
164 | responseData["profile_image"] = profile.Image.ToString(); | 164 | responseData["profile_image"] = profile.Image.ToString(); |
165 | responseData["profile_created"] = profile.Created.ToString(); | 165 | responseData["profile_created"] = profile.Created.ToString(); |
166 | responseData["profile_lastlogin"] = profile.LastLogin.ToString(); | 166 | responseData["profile_lastlogin"] = profile.LastLogin.ToString(); |
167 | // Home region information | 167 | // Home region information |
168 | responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString(); | 168 | responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString(); |
169 | responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString(); | 169 | responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString(); |
170 | responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString(); | 170 | responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString(); |
171 | 171 | ||
172 | responseData["home_region"] = profile.HomeRegion.ToString(); | 172 | responseData["home_region"] = profile.HomeRegion.ToString(); |
173 | responseData["home_region_id"] = profile.HomeRegionID.ToString(); | 173 | responseData["home_region_id"] = profile.HomeRegionID.ToString(); |
174 | 174 | ||
175 | responseData["home_look_x"] = profile.HomeLookAt.X.ToString(); | 175 | responseData["home_look_x"] = profile.HomeLookAt.X.ToString(); |
176 | responseData["home_look_y"] = profile.HomeLookAt.Y.ToString(); | 176 | responseData["home_look_y"] = profile.HomeLookAt.Y.ToString(); |
177 | responseData["home_look_z"] = profile.HomeLookAt.Z.ToString(); | 177 | responseData["home_look_z"] = profile.HomeLookAt.Z.ToString(); |
178 | 178 | ||
179 | responseData["user_flags"] = profile.UserFlags.ToString(); | 179 | responseData["user_flags"] = profile.UserFlags.ToString(); |
180 | responseData["god_level"] = profile.GodLevel.ToString(); | 180 | responseData["god_level"] = profile.GodLevel.ToString(); |
181 | responseData["custom_type"] = profile.CustomType; | 181 | responseData["custom_type"] = profile.CustomType; |
182 | responseData["partner"] = profile.Partner.ToString(); | 182 | responseData["partner"] = profile.Partner.ToString(); |
183 | response.Value = responseData; | 183 | response.Value = responseData; |
184 | 184 | ||
185 | return response; | 185 | return response; |
186 | } | 186 | } |
187 | 187 | ||
188 | #region XMLRPC User Methods | 188 | #region XMLRPC User Methods |
189 | 189 | ||
190 | public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) | 190 | public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) |
191 | { | 191 | { |
192 | // XmlRpcResponse response = new XmlRpcResponse(); | 192 | // XmlRpcResponse response = new XmlRpcResponse(); |
193 | Hashtable requestData = (Hashtable) request.Params[0]; | 193 | Hashtable requestData = (Hashtable) request.Params[0]; |
194 | List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>(); | 194 | List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>(); |
195 | UUID queryID = new UUID(UUID.Zero.ToString()); | 195 | UUID queryID = new UUID(UUID.Zero.ToString()); |
196 | 196 | ||
197 | if (requestData.Contains("avquery") && requestData.Contains("queryid")) | 197 | if (requestData.Contains("avquery") && requestData.Contains("queryid")) |
198 | { | 198 | { |
199 | queryID = new UUID((string) requestData["queryid"]); | 199 | queryID = new UUID((string) requestData["queryid"]); |
200 | returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]); | 200 | returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]); |
201 | } | 201 | } |
202 | 202 | ||
203 | m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]); | 203 | m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]); |
204 | return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); | 204 | return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); |
205 | } | 205 | } |
206 | 206 | ||
207 | public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request) | 207 | public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request) |
208 | { | 208 | { |
209 | XmlRpcResponse response = new XmlRpcResponse(); | 209 | XmlRpcResponse response = new XmlRpcResponse(); |
210 | Hashtable requestData = (Hashtable) request.Params[0]; | 210 | Hashtable requestData = (Hashtable) request.Params[0]; |
211 | Hashtable responseData = new Hashtable(); | 211 | Hashtable responseData = new Hashtable(); |
212 | string returnstring = "FALSE"; | 212 | string returnstring = "FALSE"; |
213 | 213 | ||
214 | if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") && | 214 | if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") && |
215 | requestData.Contains("region_uuid")) | 215 | requestData.Contains("region_uuid")) |
216 | { | 216 | { |
217 | // ulong cregionhandle = 0; | 217 | // ulong cregionhandle = 0; |
218 | UUID regionUUID; | 218 | UUID regionUUID; |
219 | UUID avatarUUID; | 219 | UUID avatarUUID; |
220 | 220 | ||
221 | UUID.TryParse((string) requestData["avatar_id"], out avatarUUID); | 221 | UUID.TryParse((string) requestData["avatar_id"], out avatarUUID); |
222 | UUID.TryParse((string) requestData["region_uuid"], out regionUUID); | 222 | UUID.TryParse((string) requestData["region_uuid"], out regionUUID); |
223 | 223 | ||
224 | if (avatarUUID != UUID.Zero) | 224 | if (avatarUUID != UUID.Zero) |
225 | { | 225 | { |
226 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID); | 226 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID); |
227 | userProfile.CurrentAgent.Region = regionUUID; | 227 | userProfile.CurrentAgent.Region = regionUUID; |
228 | userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]); | 228 | userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]); |
229 | //userProfile.CurrentAgent. | 229 | //userProfile.CurrentAgent. |
230 | m_userDataBaseService.CommitAgent(ref userProfile); | 230 | m_userDataBaseService.CommitAgent(ref userProfile); |
231 | //setUserProfile(userProfile); | 231 | //setUserProfile(userProfile); |
232 | 232 | ||
233 | 233 | ||
234 | returnstring = "TRUE"; | 234 | returnstring = "TRUE"; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | responseData.Add("returnString", returnstring); | 237 | responseData.Add("returnString", returnstring); |
238 | response.Value = responseData; | 238 | response.Value = responseData; |
239 | return response; | 239 | return response; |
240 | } | 240 | } |
241 | 241 | ||
242 | public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) | 242 | public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) |
243 | { | 243 | { |
244 | // XmlRpcResponse response = new XmlRpcResponse(); | 244 | // XmlRpcResponse response = new XmlRpcResponse(); |
245 | Hashtable requestData = (Hashtable) request.Params[0]; | 245 | Hashtable requestData = (Hashtable) request.Params[0]; |
246 | UserProfileData userProfile; | 246 | UserProfileData userProfile; |
247 | if (requestData.Contains("avatar_name")) | 247 | if (requestData.Contains("avatar_name")) |
248 | { | 248 | { |
249 | string query = (string) requestData["avatar_name"]; | 249 | string query = (string) requestData["avatar_name"]; |
250 | 250 | ||
251 | // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); | 251 | // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); |
252 | 252 | ||
253 | string[] querysplit = query.Split(' '); | 253 | string[] querysplit = query.Split(' '); |
254 | 254 | ||
255 | if (querysplit.Length == 2) | 255 | if (querysplit.Length == 2) |
256 | { | 256 | { |
257 | userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]); | 257 | userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]); |
258 | if (userProfile == null) | 258 | if (userProfile == null) |
259 | { | 259 | { |
260 | return CreateUnknownUserErrorResponse(); | 260 | return CreateUnknownUserErrorResponse(); |
261 | } | 261 | } |
262 | } | 262 | } |
263 | else | 263 | else |
264 | { | 264 | { |
265 | return CreateUnknownUserErrorResponse(); | 265 | return CreateUnknownUserErrorResponse(); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | else | 268 | else |
269 | { | 269 | { |
270 | return CreateUnknownUserErrorResponse(); | 270 | return CreateUnknownUserErrorResponse(); |
271 | } | 271 | } |
272 | 272 | ||
273 | return ProfileToXmlRPCResponse(userProfile); | 273 | return ProfileToXmlRPCResponse(userProfile); |
274 | } | 274 | } |
275 | 275 | ||
276 | public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) | 276 | public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) |
277 | { | 277 | { |
278 | // XmlRpcResponse response = new XmlRpcResponse(); | 278 | // XmlRpcResponse response = new XmlRpcResponse(); |
279 | Hashtable requestData = (Hashtable) request.Params[0]; | 279 | Hashtable requestData = (Hashtable) request.Params[0]; |
280 | UserProfileData userProfile; | 280 | UserProfileData userProfile; |
281 | //CFK: this clogs the UserServer log and is not necessary at this time. | 281 | //CFK: this clogs the UserServer log and is not necessary at this time. |
282 | //CFK: m_log.Debug("METHOD BY UUID CALLED"); | 282 | //CFK: m_log.Debug("METHOD BY UUID CALLED"); |
283 | if (requestData.Contains("avatar_uuid")) | 283 | if (requestData.Contains("avatar_uuid")) |
284 | { | 284 | { |
285 | try | 285 | try |
286 | { | 286 | { |
287 | UUID guess = new UUID((string) requestData["avatar_uuid"]); | 287 | UUID guess = new UUID((string) requestData["avatar_uuid"]); |
288 | 288 | ||
289 | userProfile = m_userDataBaseService.GetUserProfile(guess); | 289 | userProfile = m_userDataBaseService.GetUserProfile(guess); |
290 | } | 290 | } |
291 | catch (FormatException) | 291 | catch (FormatException) |
292 | { | 292 | { |
293 | return CreateUnknownUserErrorResponse(); | 293 | return CreateUnknownUserErrorResponse(); |
294 | } | 294 | } |
295 | 295 | ||
296 | if (userProfile == null) | 296 | if (userProfile == null) |
297 | { | 297 | { |
298 | return CreateUnknownUserErrorResponse(); | 298 | return CreateUnknownUserErrorResponse(); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | else | 301 | else |
302 | { | 302 | { |
303 | return CreateUnknownUserErrorResponse(); | 303 | return CreateUnknownUserErrorResponse(); |
304 | } | 304 | } |
305 | 305 | ||
306 | return ProfileToXmlRPCResponse(userProfile); | 306 | return ProfileToXmlRPCResponse(userProfile); |
307 | } | 307 | } |
308 | 308 | ||
309 | public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request) | 309 | public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request) |
310 | { | 310 | { |
311 | XmlRpcResponse response = new XmlRpcResponse(); | 311 | XmlRpcResponse response = new XmlRpcResponse(); |
312 | Hashtable requestData = (Hashtable) request.Params[0]; | 312 | Hashtable requestData = (Hashtable) request.Params[0]; |
313 | UserProfileData userProfile; | 313 | UserProfileData userProfile; |
314 | //CFK: this clogs the UserServer log and is not necessary at this time. | 314 | //CFK: this clogs the UserServer log and is not necessary at this time. |
315 | //CFK: m_log.Debug("METHOD BY UUID CALLED"); | 315 | //CFK: m_log.Debug("METHOD BY UUID CALLED"); |
316 | if (requestData.Contains("avatar_uuid")) | 316 | if (requestData.Contains("avatar_uuid")) |
317 | { | 317 | { |
318 | UUID guess; | 318 | UUID guess; |
319 | 319 | ||
320 | UUID.TryParse((string) requestData["avatar_uuid"], out guess); | 320 | UUID.TryParse((string) requestData["avatar_uuid"], out guess); |
321 | 321 | ||
322 | if (guess == UUID.Zero) | 322 | if (guess == UUID.Zero) |
323 | { | 323 | { |
324 | return CreateUnknownUserErrorResponse(); | 324 | return CreateUnknownUserErrorResponse(); |
325 | } | 325 | } |
326 | 326 | ||
327 | userProfile = m_userDataBaseService.GetUserProfile(guess); | 327 | userProfile = m_userDataBaseService.GetUserProfile(guess); |
328 | 328 | ||
329 | if (userProfile == null) | 329 | if (userProfile == null) |
330 | { | 330 | { |
331 | return CreateUnknownUserErrorResponse(); | 331 | return CreateUnknownUserErrorResponse(); |
332 | } | 332 | } |
333 | 333 | ||
334 | // no agent??? | 334 | // no agent??? |
335 | if (userProfile.CurrentAgent == null) | 335 | if (userProfile.CurrentAgent == null) |
336 | { | 336 | { |
337 | return CreateUnknownUserErrorResponse(); | 337 | return CreateUnknownUserErrorResponse(); |
338 | } | 338 | } |
339 | Hashtable responseData = new Hashtable(); | 339 | Hashtable responseData = new Hashtable(); |
340 | 340 | ||
341 | responseData["handle"] = userProfile.CurrentAgent.Handle.ToString(); | 341 | responseData["handle"] = userProfile.CurrentAgent.Handle.ToString(); |
342 | responseData["session"] = userProfile.CurrentAgent.SessionID.ToString(); | 342 | responseData["session"] = userProfile.CurrentAgent.SessionID.ToString(); |
343 | if (userProfile.CurrentAgent.AgentOnline) | 343 | if (userProfile.CurrentAgent.AgentOnline) |
344 | responseData["agent_online"] = "TRUE"; | 344 | responseData["agent_online"] = "TRUE"; |
345 | else | 345 | else |
346 | responseData["agent_online"] = "FALSE"; | 346 | responseData["agent_online"] = "FALSE"; |
347 | 347 | ||
348 | response.Value = responseData; | 348 | response.Value = responseData; |
349 | } | 349 | } |
350 | else | 350 | else |
351 | { | 351 | { |
352 | return CreateUnknownUserErrorResponse(); | 352 | return CreateUnknownUserErrorResponse(); |
353 | } | 353 | } |
354 | 354 | ||
355 | return response; | 355 | return response; |
356 | } | 356 | } |
357 | 357 | ||
358 | public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request) | 358 | public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request) |
359 | { | 359 | { |
360 | XmlRpcResponse response = new XmlRpcResponse(); | 360 | XmlRpcResponse response = new XmlRpcResponse(); |
361 | Hashtable requestData = (Hashtable) request.Params[0]; | 361 | Hashtable requestData = (Hashtable) request.Params[0]; |
362 | UserProfileData userProfile; | 362 | UserProfileData userProfile; |
363 | 363 | ||
364 | string authed = "FALSE"; | 364 | string authed = "FALSE"; |
365 | if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id")) | 365 | if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id")) |
366 | { | 366 | { |
367 | UUID guess_aid; | 367 | UUID guess_aid; |
368 | UUID guess_sid; | 368 | UUID guess_sid; |
369 | 369 | ||
370 | UUID.TryParse((string) requestData["avatar_uuid"], out guess_aid); | 370 | UUID.TryParse((string) requestData["avatar_uuid"], out guess_aid); |
371 | if (guess_aid == UUID.Zero) | 371 | if (guess_aid == UUID.Zero) |
372 | { | 372 | { |
373 | return CreateUnknownUserErrorResponse(); | 373 | return CreateUnknownUserErrorResponse(); |
374 | } | 374 | } |
375 | UUID.TryParse((string) requestData["session_id"], out guess_sid); | 375 | UUID.TryParse((string) requestData["session_id"], out guess_sid); |
376 | if (guess_sid == UUID.Zero) | 376 | if (guess_sid == UUID.Zero) |
377 | { | 377 | { |
378 | return CreateUnknownUserErrorResponse(); | 378 | return CreateUnknownUserErrorResponse(); |
379 | } | 379 | } |
380 | userProfile = m_userDataBaseService.GetUserProfile(guess_aid); | 380 | userProfile = m_userDataBaseService.GetUserProfile(guess_aid); |
381 | if (userProfile != null && userProfile.CurrentAgent != null && | 381 | if (userProfile != null && userProfile.CurrentAgent != null && |
382 | userProfile.CurrentAgent.SessionID == guess_sid) | 382 | userProfile.CurrentAgent.SessionID == guess_sid) |
383 | { | 383 | { |
384 | authed = "TRUE"; | 384 | authed = "TRUE"; |
385 | } | 385 | } |
386 | m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); | 386 | m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); |
387 | } | 387 | } |
388 | else | 388 | else |
389 | { | 389 | { |
390 | m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); | 390 | m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); |
391 | return CreateUnknownUserErrorResponse(); | 391 | return CreateUnknownUserErrorResponse(); |
392 | } | 392 | } |
393 | Hashtable responseData = new Hashtable(); | 393 | Hashtable responseData = new Hashtable(); |
394 | responseData["auth_session"] = authed; | 394 | responseData["auth_session"] = authed; |
395 | response.Value = responseData; | 395 | response.Value = responseData; |
396 | return response; | 396 | return response; |
397 | } | 397 | } |
398 | 398 | ||
399 | public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request) | 399 | public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request) |
400 | { | 400 | { |
401 | m_log.Debug("[UserManager]: Got request to update user profile"); | 401 | m_log.Debug("[UserManager]: Got request to update user profile"); |
402 | XmlRpcResponse response = new XmlRpcResponse(); | 402 | XmlRpcResponse response = new XmlRpcResponse(); |
403 | Hashtable requestData = (Hashtable) request.Params[0]; | 403 | Hashtable requestData = (Hashtable) request.Params[0]; |
404 | Hashtable responseData = new Hashtable(); | 404 | Hashtable responseData = new Hashtable(); |
405 | 405 | ||
406 | if (!requestData.Contains("avatar_uuid")) | 406 | if (!requestData.Contains("avatar_uuid")) |
407 | { | 407 | { |
408 | return CreateUnknownUserErrorResponse(); | 408 | return CreateUnknownUserErrorResponse(); |
409 | } | 409 | } |
410 | 410 | ||
411 | UUID UserUUID = new UUID((string) requestData["avatar_uuid"]); | 411 | UUID UserUUID = new UUID((string) requestData["avatar_uuid"]); |
412 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID); | 412 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID); |
413 | if (null == userProfile) | 413 | if (null == userProfile) |
414 | { | 414 | { |
415 | return CreateUnknownUserErrorResponse(); | 415 | return CreateUnknownUserErrorResponse(); |
416 | } | 416 | } |
417 | // don't know how yet. | 417 | // don't know how yet. |
418 | if (requestData.Contains("AllowPublish")) | 418 | if (requestData.Contains("AllowPublish")) |
419 | { | 419 | { |
420 | } | 420 | } |
421 | if (requestData.Contains("FLImageID")) | 421 | if (requestData.Contains("FLImageID")) |
422 | { | 422 | { |
423 | userProfile.FirstLifeImage = new UUID((string) requestData["FLImageID"]); | 423 | userProfile.FirstLifeImage = new UUID((string) requestData["FLImageID"]); |
424 | } | 424 | } |
425 | if (requestData.Contains("ImageID")) | 425 | if (requestData.Contains("ImageID")) |
426 | { | 426 | { |
427 | userProfile.Image = new UUID((string) requestData["ImageID"]); | 427 | userProfile.Image = new UUID((string) requestData["ImageID"]); |
428 | } | 428 | } |
429 | // dont' know how yet | 429 | // dont' know how yet |
430 | if (requestData.Contains("MaturePublish")) | 430 | if (requestData.Contains("MaturePublish")) |
431 | { | 431 | { |
432 | } | 432 | } |
433 | if (requestData.Contains("AboutText")) | 433 | if (requestData.Contains("AboutText")) |
434 | { | 434 | { |
435 | userProfile.AboutText = (string) requestData["AboutText"]; | 435 | userProfile.AboutText = (string) requestData["AboutText"]; |
436 | } | 436 | } |
437 | if (requestData.Contains("FLAboutText")) | 437 | if (requestData.Contains("FLAboutText")) |
438 | { | 438 | { |
439 | userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"]; | 439 | userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"]; |
440 | } | 440 | } |
441 | // not in DB yet. | 441 | // not in DB yet. |
442 | if (requestData.Contains("ProfileURL")) | 442 | if (requestData.Contains("ProfileURL")) |
443 | { | 443 | { |
444 | } | 444 | } |
445 | if (requestData.Contains("home_region")) | 445 | if (requestData.Contains("home_region")) |
446 | { | 446 | { |
447 | try | 447 | try |
448 | { | 448 | { |
449 | userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]); | 449 | userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]); |
450 | } | 450 | } |
451 | catch (ArgumentException) | 451 | catch (ArgumentException) |
452 | { | 452 | { |
453 | m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument"); | 453 | m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument"); |
454 | } | 454 | } |
455 | catch (FormatException) | 455 | catch (FormatException) |
456 | { | 456 | { |
457 | m_log.Error("[PROFILE]:Failed to set home region, Invalid Format"); | 457 | m_log.Error("[PROFILE]:Failed to set home region, Invalid Format"); |
458 | } | 458 | } |
459 | catch (OverflowException) | 459 | catch (OverflowException) |
460 | { | 460 | { |
461 | m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); | 461 | m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | if (requestData.Contains("home_region_id")) | 464 | if (requestData.Contains("home_region_id")) |
465 | { | 465 | { |
466 | UUID regionID; | 466 | UUID regionID; |
467 | UUID.TryParse((string) requestData["home_region_id"], out regionID); | 467 | UUID.TryParse((string) requestData["home_region_id"], out regionID); |
468 | userProfile.HomeRegionID = regionID; | 468 | userProfile.HomeRegionID = regionID; |
469 | } | 469 | } |
470 | if (requestData.Contains("home_pos_x")) | 470 | if (requestData.Contains("home_pos_x")) |
471 | { | 471 | { |
472 | try | 472 | try |
473 | { | 473 | { |
474 | userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]); | 474 | userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]); |
475 | } | 475 | } |
476 | catch (InvalidCastException) | 476 | catch (InvalidCastException) |
477 | { | 477 | { |
478 | m_log.Error("[PROFILE]:Failed to set home postion x"); | 478 | m_log.Error("[PROFILE]:Failed to set home postion x"); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | if (requestData.Contains("home_pos_y")) | 481 | if (requestData.Contains("home_pos_y")) |
482 | { | 482 | { |
483 | try | 483 | try |
484 | { | 484 | { |
485 | userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]); | 485 | userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]); |
486 | } | 486 | } |
487 | catch (InvalidCastException) | 487 | catch (InvalidCastException) |
488 | { | 488 | { |
489 | m_log.Error("[PROFILE]:Failed to set home postion y"); | 489 | m_log.Error("[PROFILE]:Failed to set home postion y"); |
490 | } | 490 | } |
491 | } | 491 | } |
492 | if (requestData.Contains("home_pos_z")) | 492 | if (requestData.Contains("home_pos_z")) |
493 | { | 493 | { |
494 | try | 494 | try |
495 | { | 495 | { |
496 | userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]); | 496 | userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]); |
497 | } | 497 | } |
498 | catch (InvalidCastException) | 498 | catch (InvalidCastException) |
499 | { | 499 | { |
500 | m_log.Error("[PROFILE]:Failed to set home postion z"); | 500 | m_log.Error("[PROFILE]:Failed to set home postion z"); |
501 | } | 501 | } |
502 | } | 502 | } |
503 | if (requestData.Contains("home_look_x")) | 503 | if (requestData.Contains("home_look_x")) |
504 | { | 504 | { |
505 | try | 505 | try |
506 | { | 506 | { |
507 | userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]); | 507 | userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]); |
508 | } | 508 | } |
509 | catch (InvalidCastException) | 509 | catch (InvalidCastException) |
510 | { | 510 | { |
511 | m_log.Error("[PROFILE]:Failed to set home lookat x"); | 511 | m_log.Error("[PROFILE]:Failed to set home lookat x"); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | if (requestData.Contains("home_look_y")) | 514 | if (requestData.Contains("home_look_y")) |
515 | { | 515 | { |
516 | try | 516 | try |
517 | { | 517 | { |
518 | userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]); | 518 | userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]); |
519 | } | 519 | } |
520 | catch (InvalidCastException) | 520 | catch (InvalidCastException) |
521 | { | 521 | { |
522 | m_log.Error("[PROFILE]:Failed to set home lookat y"); | 522 | m_log.Error("[PROFILE]:Failed to set home lookat y"); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | if (requestData.Contains("home_look_z")) | 525 | if (requestData.Contains("home_look_z")) |
526 | { | 526 | { |
527 | try | 527 | try |
528 | { | 528 | { |
529 | userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]); | 529 | userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]); |
530 | } | 530 | } |
531 | catch (InvalidCastException) | 531 | catch (InvalidCastException) |
532 | { | 532 | { |
533 | m_log.Error("[PROFILE]:Failed to set home lookat z"); | 533 | m_log.Error("[PROFILE]:Failed to set home lookat z"); |
534 | } | 534 | } |
535 | } | 535 | } |
536 | if (requestData.Contains("user_flags")) | 536 | if (requestData.Contains("user_flags")) |
537 | { | 537 | { |
538 | try | 538 | try |
539 | { | 539 | { |
540 | userProfile.UserFlags = Convert.ToInt32((string) requestData["user_flags"]); | 540 | userProfile.UserFlags = Convert.ToInt32((string) requestData["user_flags"]); |
541 | } | 541 | } |
542 | catch (InvalidCastException) | 542 | catch (InvalidCastException) |
543 | { | 543 | { |
544 | m_log.Error("[PROFILE]:Failed to set user flags"); | 544 | m_log.Error("[PROFILE]:Failed to set user flags"); |
545 | } | 545 | } |
546 | } | 546 | } |
547 | if (requestData.Contains("god_level")) | 547 | if (requestData.Contains("god_level")) |
548 | { | 548 | { |
549 | try | 549 | try |
550 | { | 550 | { |
551 | userProfile.GodLevel = Convert.ToInt32((string) requestData["god_level"]); | 551 | userProfile.GodLevel = Convert.ToInt32((string) requestData["god_level"]); |
552 | } | 552 | } |
553 | catch (InvalidCastException) | 553 | catch (InvalidCastException) |
554 | { | 554 | { |
555 | m_log.Error("[PROFILE]:Failed to set god level"); | 555 | m_log.Error("[PROFILE]:Failed to set god level"); |
556 | } | 556 | } |
557 | } | 557 | } |
558 | if (requestData.Contains("custom_type")) | 558 | if (requestData.Contains("custom_type")) |
559 | { | 559 | { |
560 | try | 560 | try |
561 | { | 561 | { |
562 | userProfile.CustomType = (string) requestData["custom_type"]; | 562 | userProfile.CustomType = (string) requestData["custom_type"]; |
563 | } | 563 | } |
564 | catch (InvalidCastException) | 564 | catch (InvalidCastException) |
565 | { | 565 | { |
566 | m_log.Error("[PROFILE]:Failed to set custom type"); | 566 | m_log.Error("[PROFILE]:Failed to set custom type"); |
567 | } | 567 | } |
568 | } | 568 | } |
569 | if (requestData.Contains("partner")) | 569 | if (requestData.Contains("partner")) |
570 | { | 570 | { |
571 | try | 571 | try |
572 | { | 572 | { |
573 | userProfile.Partner = new UUID((string) requestData["partner"]); | 573 | userProfile.Partner = new UUID((string) requestData["partner"]); |
574 | } | 574 | } |
575 | catch (InvalidCastException) | 575 | catch (InvalidCastException) |
576 | { | 576 | { |
577 | m_log.Error("[PROFILE]:Failed to set partner"); | 577 | m_log.Error("[PROFILE]:Failed to set partner"); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | else | 580 | else |
581 | { | 581 | { |
582 | userProfile.Partner = UUID.Zero; | 582 | userProfile.Partner = UUID.Zero; |
583 | } | 583 | } |
584 | 584 | ||
585 | // call plugin! | 585 | // call plugin! |
586 | bool ret = m_userDataBaseService.UpdateUserProfile(userProfile); | 586 | bool ret = m_userDataBaseService.UpdateUserProfile(userProfile); |
587 | responseData["returnString"] = ret.ToString(); | 587 | responseData["returnString"] = ret.ToString(); |
588 | response.Value = responseData; | 588 | response.Value = responseData; |
589 | return response; | 589 | return response; |
590 | } | 590 | } |
591 | 591 | ||
592 | public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) | 592 | public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) |
593 | { | 593 | { |
594 | XmlRpcResponse response = new XmlRpcResponse(); | 594 | XmlRpcResponse response = new XmlRpcResponse(); |
595 | Hashtable requestData = (Hashtable) request.Params[0]; | 595 | Hashtable requestData = (Hashtable) request.Params[0]; |
596 | 596 | ||
597 | if (requestData.Contains("avatar_uuid")) | 597 | if (requestData.Contains("avatar_uuid")) |
598 | { | 598 | { |
599 | try | 599 | try |
600 | { | 600 | { |
601 | UUID userUUID = new UUID((string)requestData["avatar_uuid"]); | 601 | UUID userUUID = new UUID((string)requestData["avatar_uuid"]); |
602 | UUID RegionID = new UUID((string)requestData["region_uuid"]); | 602 | UUID RegionID = new UUID((string)requestData["region_uuid"]); |
603 | ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); | 603 | ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); |
604 | Vector3 position = new Vector3( | 604 | Vector3 position = new Vector3( |
605 | (float)Convert.ToDecimal((string)requestData["region_pos_x"]), | 605 | (float)Convert.ToDecimal((string)requestData["region_pos_x"]), |
606 | (float)Convert.ToDecimal((string)requestData["region_pos_y"]), | 606 | (float)Convert.ToDecimal((string)requestData["region_pos_y"]), |
607 | (float)Convert.ToDecimal((string)requestData["region_pos_z"])); | 607 | (float)Convert.ToDecimal((string)requestData["region_pos_z"])); |
608 | Vector3 lookat = new Vector3( | 608 | Vector3 lookat = new Vector3( |
609 | (float)Convert.ToDecimal((string)requestData["lookat_x"]), | 609 | (float)Convert.ToDecimal((string)requestData["lookat_x"]), |
610 | (float)Convert.ToDecimal((string)requestData["lookat_y"]), | 610 | (float)Convert.ToDecimal((string)requestData["lookat_y"]), |
611 | (float)Convert.ToDecimal((string)requestData["lookat_z"])); | 611 | (float)Convert.ToDecimal((string)requestData["lookat_z"])); |
612 | 612 | ||
613 | handlerLogOffUser = OnLogOffUser; | 613 | handlerLogOffUser = OnLogOffUser; |
614 | if (handlerLogOffUser != null) | 614 | if (handlerLogOffUser != null) |
615 | handlerLogOffUser(userUUID); | 615 | handlerLogOffUser(userUUID); |
616 | 616 | ||
617 | m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat); | 617 | m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat); |
618 | } | 618 | } |
619 | catch (FormatException) | 619 | catch (FormatException) |
620 | { | 620 | { |
621 | m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params"); | 621 | m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params"); |
622 | return response; | 622 | return response; |
623 | } | 623 | } |
624 | } | 624 | } |
625 | else | 625 | else |
626 | { | 626 | { |
627 | return CreateUnknownUserErrorResponse(); | 627 | return CreateUnknownUserErrorResponse(); |
628 | } | 628 | } |
629 | 629 | ||
630 | return response; | 630 | return response; |
631 | } | 631 | } |
632 | 632 | ||
633 | #endregion | 633 | #endregion |
634 | 634 | ||
635 | 635 | ||
636 | public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) | 636 | public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) |
637 | { | 637 | { |
638 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); | 638 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); |
639 | if (userProfile != null) | 639 | if (userProfile != null) |
640 | { | 640 | { |
641 | userProfile.CurrentAgent.Region = regionID; | 641 | userProfile.CurrentAgent.Region = regionID; |
642 | userProfile.CurrentAgent.Handle = regionHandle; | 642 | userProfile.CurrentAgent.Handle = regionHandle; |
643 | m_userDataBaseService.CommitAgent(ref userProfile); | 643 | m_userDataBaseService.CommitAgent(ref userProfile); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) | 647 | public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) |
648 | { | 648 | { |
649 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); | 649 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); |
650 | if (userProfile != null) | 650 | if (userProfile != null) |
651 | { | 651 | { |
652 | if (userProfile.CurrentAgent.Region == regionID) | 652 | if (userProfile.CurrentAgent.Region == regionID) |
653 | { | 653 | { |
654 | UserAgentData userAgent = userProfile.CurrentAgent; | 654 | UserAgentData userAgent = userProfile.CurrentAgent; |
655 | if (userAgent != null && userAgent.AgentOnline) | 655 | if (userAgent != null && userAgent.AgentOnline) |
656 | { | 656 | { |
657 | userAgent.AgentOnline = false; | 657 | userAgent.AgentOnline = false; |
658 | userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); | 658 | userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); |
659 | if (regionID != UUID.Zero) | 659 | if (regionID != UUID.Zero) |
660 | { | 660 | { |
661 | userAgent.Region = regionID; | 661 | userAgent.Region = regionID; |
662 | } | 662 | } |
663 | userAgent.Handle = regionHandle; | 663 | userAgent.Handle = regionHandle; |
664 | userProfile.LastLogin = userAgent.LogoutTime; | 664 | userProfile.LastLogin = userAgent.LogoutTime; |
665 | 665 | ||
666 | m_userDataBaseService.CommitAgent(ref userProfile); | 666 | m_userDataBaseService.CommitAgent(ref userProfile); |
667 | 667 | ||
668 | handlerLogOffUser = OnLogOffUser; | 668 | handlerLogOffUser = OnLogOffUser; |
669 | if (handlerLogOffUser != null) | 669 | if (handlerLogOffUser != null) |
670 | handlerLogOffUser(agentID); | 670 | handlerLogOffUser(agentID); |
671 | } | 671 | } |
672 | } | 672 | } |
673 | } | 673 | } |
674 | } | 674 | } |
675 | 675 | ||
676 | public void HandleRegionStartup(UUID regionID) | 676 | public void HandleRegionStartup(UUID regionID) |
677 | { | 677 | { |
678 | m_userDataBaseService.LogoutUsers(regionID); | 678 | m_userDataBaseService.LogoutUsers(regionID); |
679 | } | 679 | } |
680 | 680 | ||
681 | public void HandleRegionShutdown(UUID regionID) | 681 | public void HandleRegionShutdown(UUID regionID) |
682 | { | 682 | { |
683 | m_userDataBaseService.LogoutUsers(regionID); | 683 | m_userDataBaseService.LogoutUsers(regionID); |
684 | } | 684 | } |
685 | } | 685 | } |
686 | } | 686 | } |