diff options
author | Justin Clarke Casey | 2009-04-22 18:15:43 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-04-22 18:15:43 +0000 |
commit | 2c81e41c8a884ece643f3079349b033d03b6b774 (patch) | |
tree | bea7956ef00378f47fa420e82ffb665a137a9630 /OpenSim | |
parent | From: Alan Webb <alan_webb@us.ibm.com> (diff) | |
download | opensim-SC-2c81e41c8a884ece643f3079349b033d03b6b774.zip opensim-SC-2c81e41c8a884ece643f3079349b033d03b6b774.tar.gz opensim-SC-2c81e41c8a884ece643f3079349b033d03b6b774.tar.bz2 opensim-SC-2c81e41c8a884ece643f3079349b033d03b6b774.tar.xz |
* Fission OGS1UserServices into user service and OGS1 user data plugin components
* Make OGS1UserServices inherit from UserManagerBase
* This allows grid mode regions to use the same user data plugin infrastructure as grid servers and standalone OpenSims
Diffstat (limited to '')
15 files changed, 886 insertions, 842 deletions
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index a0c592e..cd39296 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs | |||
@@ -220,7 +220,11 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager | |||
220 | new LocalUserServices( | 220 | new LocalUserServices( |
221 | m_openSim.NetServersInfo.DefaultHomeLocX, m_openSim.NetServersInfo.DefaultHomeLocY, inventoryService); | 221 | m_openSim.NetServersInfo.DefaultHomeLocX, m_openSim.NetServersInfo.DefaultHomeLocY, inventoryService); |
222 | localuserService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneUserPlugin, m_openSim.ConfigurationSettings.StandaloneUserSource); | 222 | localuserService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneUserPlugin, m_openSim.ConfigurationSettings.StandaloneUserSource); |
223 | |||
223 | HGUserServices userService = new HGUserServices(localuserService); | 224 | HGUserServices userService = new HGUserServices(localuserService); |
225 | // This plugin arrangement could eventually be configurable rather than hardcoded here. | ||
226 | OGS1UserDataPlugin userDataPlugin = new OGS1UserDataPlugin(m_commsManager); | ||
227 | userService.AddPlugin(userDataPlugin); | ||
224 | 228 | ||
225 | HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager); | 229 | HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager); |
226 | 230 | ||
diff --git a/OpenSim/Data/IUserData.cs b/OpenSim/Data/IUserData.cs index 1564033..9ac923f 100644 --- a/OpenSim/Data/IUserData.cs +++ b/OpenSim/Data/IUserData.cs | |||
@@ -25,6 +25,7 @@ | |||
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.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
@@ -48,8 +49,15 @@ namespace OpenSim.Data | |||
48 | /// </summary> | 49 | /// </summary> |
49 | /// <param name="fname">Account firstname</param> | 50 | /// <param name="fname">Account firstname</param> |
50 | /// <param name="lname">Account lastname</param> | 51 | /// <param name="lname">Account lastname</param> |
51 | /// <returns>The user data profile</returns> | 52 | /// <returns>The user data profile. Null if no user is found</returns> |
52 | UserProfileData GetUserByName(string fname, string lname); | 53 | UserProfileData GetUserByName(string fname, string lname); |
54 | |||
55 | /// <summary> | ||
56 | /// Get a user from a given uri. | ||
57 | /// </summary> | ||
58 | /// <param name="uri"></param> | ||
59 | /// <returns>The user data profile. Null if no user is found.</returns> | ||
60 | UserProfileData GetUserByUri(Uri uri); | ||
53 | 61 | ||
54 | /// <summary> | 62 | /// <summary> |
55 | /// Returns a list of UUIDs firstnames and lastnames that match string query entered into the avatar picker. | 63 | /// Returns a list of UUIDs firstnames and lastnames that match string query entered into the avatar picker. |
@@ -63,7 +71,7 @@ namespace OpenSim.Data | |||
63 | /// Returns the current agent for a user searching by it's UUID | 71 | /// Returns the current agent for a user searching by it's UUID |
64 | /// </summary> | 72 | /// </summary> |
65 | /// <param name="user">The users UUID</param> | 73 | /// <param name="user">The users UUID</param> |
66 | /// <returns>The current agent session</returns> | 74 | /// <returns>The current agent session. Null if no session was found</returns> |
67 | UserAgentData GetAgentByUUID(UUID user); | 75 | UserAgentData GetAgentByUUID(UUID user); |
68 | 76 | ||
69 | /// <summary> | 77 | /// <summary> |
diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs index 0fa9e58..167a837 100644 --- a/OpenSim/Data/UserDataBase.cs +++ b/OpenSim/Data/UserDataBase.cs | |||
@@ -25,6 +25,7 @@ | |||
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.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
@@ -42,6 +43,7 @@ namespace OpenSim.Data | |||
42 | public abstract UserAgentData GetAgentByUUID(UUID user); | 43 | public abstract UserAgentData GetAgentByUUID(UUID user); |
43 | public abstract UserAgentData GetAgentByName(string name); | 44 | public abstract UserAgentData GetAgentByName(string name); |
44 | public abstract UserAgentData GetAgentByName(string fname, string lname); | 45 | public abstract UserAgentData GetAgentByName(string fname, string lname); |
46 | public UserProfileData GetUserByUri(Uri uri) { return null; } | ||
45 | public abstract void StoreWebLoginKey(UUID agentID, UUID webLoginKey); | 47 | public abstract void StoreWebLoginKey(UUID agentID, UUID webLoginKey); |
46 | public abstract void AddNewUserProfile(UserProfileData user); | 48 | public abstract void AddNewUserProfile(UserProfileData user); |
47 | public abstract bool UpdateUserProfile(UserProfileData user); | 49 | public abstract bool UpdateUserProfile(UserProfileData user); |
diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index 3822e9f..db583e1 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs | |||
@@ -31,10 +31,18 @@ namespace OpenSim.Framework.Communications | |||
31 | { | 31 | { |
32 | public interface IAvatarService | 32 | public interface IAvatarService |
33 | { | 33 | { |
34 | /// Get's the User Appearance | 34 | /// <summary> |
35 | /// Get avatar appearance information | ||
36 | /// </summary> | ||
37 | /// <param name="user"></param> | ||
38 | /// <returns></returns> | ||
35 | AvatarAppearance GetUserAppearance(UUID user); | 39 | AvatarAppearance GetUserAppearance(UUID user); |
36 | 40 | ||
41 | /// <summary> | ||
42 | /// Update avatar appearance information | ||
43 | /// </summary> | ||
44 | /// <param name="user"></param> | ||
45 | /// <param name="appearance"></param> | ||
37 | void UpdateUserAppearance(UUID user, AvatarAppearance appearance); | 46 | void UpdateUserAppearance(UUID user, AvatarAppearance appearance); |
38 | |||
39 | } | 47 | } |
40 | } | 48 | } |
diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 72a4281..1b71367 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs | |||
@@ -1147,14 +1147,15 @@ namespace OpenSim.Framework.Communications.Services | |||
1147 | if (m_userManager.VerifySession(guess_aid, guess_sid)) | 1147 | if (m_userManager.VerifySession(guess_aid, guess_sid)) |
1148 | { | 1148 | { |
1149 | authed = "TRUE"; | 1149 | authed = "TRUE"; |
1150 | m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); | ||
1151 | } | ||
1152 | else | ||
1153 | { | ||
1154 | m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); | ||
1155 | return Util.CreateUnknownUserErrorResponse(); | ||
1150 | } | 1156 | } |
1151 | m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); | ||
1152 | } | ||
1153 | else | ||
1154 | { | ||
1155 | m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); | ||
1156 | return Util.CreateUnknownUserErrorResponse(); | ||
1157 | } | 1157 | } |
1158 | |||
1158 | Hashtable responseData = new Hashtable(); | 1159 | Hashtable responseData = new Hashtable(); |
1159 | responseData["auth_session"] = authed; | 1160 | responseData["auth_session"] = authed; |
1160 | response.Value = responseData; | 1161 | response.Value = responseData; |
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 1115041..3b43622 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications | |||
50 | /// <value> | 50 | /// <value> |
51 | /// List of plugins to search for user data | 51 | /// List of plugins to search for user data |
52 | /// </value> | 52 | /// </value> |
53 | private List<IUserDataPlugin> _plugins = new List<IUserDataPlugin>(); | 53 | private List<IUserDataPlugin> m_plugins = new List<IUserDataPlugin>(); |
54 | 54 | ||
55 | protected IInterServiceInventoryServices m_interServiceInventoryService; | 55 | protected IInterServiceInventoryServices m_interServiceInventoryService; |
56 | 56 | ||
@@ -69,7 +69,7 @@ namespace OpenSim.Framework.Communications | |||
69 | /// <param name="plugin">The plugin that will provide user data</param> | 69 | /// <param name="plugin">The plugin that will provide user data</param> |
70 | public void AddPlugin(IUserDataPlugin plugin) | 70 | public void AddPlugin(IUserDataPlugin plugin) |
71 | { | 71 | { |
72 | _plugins.Add(plugin); | 72 | m_plugins.Add(plugin); |
73 | } | 73 | } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
@@ -84,15 +84,15 @@ namespace OpenSim.Framework.Communications | |||
84 | /// </param> | 84 | /// </param> |
85 | public void AddPlugin(string provider, string connect) | 85 | public void AddPlugin(string provider, string connect) |
86 | { | 86 | { |
87 | _plugins.AddRange(DataPluginFactory.LoadDataPlugins<IUserDataPlugin>(provider, connect)); | 87 | m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IUserDataPlugin>(provider, connect)); |
88 | } | 88 | } |
89 | 89 | ||
90 | #region Get UserProfile | 90 | #region Get UserProfile |
91 | 91 | ||
92 | // see IUserService | 92 | // see IUserService |
93 | public UserProfileData GetUserProfile(string fname, string lname) | 93 | public virtual UserProfileData GetUserProfile(string fname, string lname) |
94 | { | 94 | { |
95 | foreach (IUserDataPlugin plugin in _plugins) | 95 | foreach (IUserDataPlugin plugin in m_plugins) |
96 | { | 96 | { |
97 | UserProfileData profile = plugin.GetUserByName(fname, lname); | 97 | UserProfileData profile = plugin.GetUserByName(fname, lname); |
98 | 98 | ||
@@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications | |||
108 | 108 | ||
109 | public void LogoutUsers(UUID regionID) | 109 | public void LogoutUsers(UUID regionID) |
110 | { | 110 | { |
111 | foreach (IUserDataPlugin plugin in _plugins) | 111 | foreach (IUserDataPlugin plugin in m_plugins) |
112 | { | 112 | { |
113 | plugin.LogoutUsers(regionID); | 113 | plugin.LogoutUsers(regionID); |
114 | } | 114 | } |
@@ -116,7 +116,7 @@ namespace OpenSim.Framework.Communications | |||
116 | 116 | ||
117 | public void ResetAttachments(UUID userID) | 117 | public void ResetAttachments(UUID userID) |
118 | { | 118 | { |
119 | foreach (IUserDataPlugin plugin in _plugins) | 119 | foreach (IUserDataPlugin plugin in m_plugins) |
120 | { | 120 | { |
121 | plugin.ResetAttachments(userID); | 121 | plugin.ResetAttachments(userID); |
122 | } | 122 | } |
@@ -124,12 +124,20 @@ namespace OpenSim.Framework.Communications | |||
124 | 124 | ||
125 | public UserProfileData GetUserProfile(Uri uri) | 125 | public UserProfileData GetUserProfile(Uri uri) |
126 | { | 126 | { |
127 | throw new NotImplementedException(); | 127 | foreach (IUserDataPlugin plugin in m_plugins) |
128 | { | ||
129 | UserProfileData profile = plugin.GetUserByUri(uri); | ||
130 | |||
131 | if (null != profile) | ||
132 | return profile; | ||
133 | } | ||
134 | |||
135 | return null; | ||
128 | } | 136 | } |
129 | 137 | ||
130 | public UserAgentData GetAgentByUUID(UUID userId) | 138 | public virtual UserAgentData GetAgentByUUID(UUID userId) |
131 | { | 139 | { |
132 | foreach (IUserDataPlugin plugin in _plugins) | 140 | foreach (IUserDataPlugin plugin in m_plugins) |
133 | { | 141 | { |
134 | UserAgentData agent = plugin.GetAgentByUUID(userId); | 142 | UserAgentData agent = plugin.GetAgentByUUID(userId); |
135 | 143 | ||
@@ -150,7 +158,7 @@ namespace OpenSim.Framework.Communications | |||
150 | // see IUserService | 158 | // see IUserService |
151 | public virtual UserProfileData GetUserProfile(UUID uuid) | 159 | public virtual UserProfileData GetUserProfile(UUID uuid) |
152 | { | 160 | { |
153 | foreach (IUserDataPlugin plugin in _plugins) | 161 | foreach (IUserDataPlugin plugin in m_plugins) |
154 | { | 162 | { |
155 | UserProfileData profile = plugin.GetUserByUUID(uuid); | 163 | UserProfileData profile = plugin.GetUserByUUID(uuid); |
156 | 164 | ||
@@ -164,10 +172,10 @@ namespace OpenSim.Framework.Communications | |||
164 | return null; | 172 | return null; |
165 | } | 173 | } |
166 | 174 | ||
167 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | 175 | public virtual List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) |
168 | { | 176 | { |
169 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); | 177 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); |
170 | foreach (IUserDataPlugin plugin in _plugins) | 178 | foreach (IUserDataPlugin plugin in m_plugins) |
171 | { | 179 | { |
172 | try | 180 | try |
173 | { | 181 | { |
@@ -188,9 +196,9 @@ namespace OpenSim.Framework.Communications | |||
188 | /// </summary> | 196 | /// </summary> |
189 | /// <param name="data"></param> | 197 | /// <param name="data"></param> |
190 | /// <returns></returns> | 198 | /// <returns></returns> |
191 | public bool UpdateUserProfile(UserProfileData data) | 199 | public virtual bool UpdateUserProfile(UserProfileData data) |
192 | { | 200 | { |
193 | foreach (IUserDataPlugin plugin in _plugins) | 201 | foreach (IUserDataPlugin plugin in m_plugins) |
194 | { | 202 | { |
195 | try | 203 | try |
196 | { | 204 | { |
@@ -217,7 +225,7 @@ namespace OpenSim.Framework.Communications | |||
217 | /// <returns>Agent profiles</returns> | 225 | /// <returns>Agent profiles</returns> |
218 | public UserAgentData GetUserAgent(UUID uuid) | 226 | public UserAgentData GetUserAgent(UUID uuid) |
219 | { | 227 | { |
220 | foreach (IUserDataPlugin plugin in _plugins) | 228 | foreach (IUserDataPlugin plugin in m_plugins) |
221 | { | 229 | { |
222 | try | 230 | try |
223 | { | 231 | { |
@@ -244,7 +252,7 @@ namespace OpenSim.Framework.Communications | |||
244 | /// <returns>A user agent</returns> | 252 | /// <returns>A user agent</returns> |
245 | public UserAgentData GetUserAgent(string name) | 253 | public UserAgentData GetUserAgent(string name) |
246 | { | 254 | { |
247 | foreach (IUserDataPlugin plugin in _plugins) | 255 | foreach (IUserDataPlugin plugin in m_plugins) |
248 | { | 256 | { |
249 | try | 257 | try |
250 | { | 258 | { |
@@ -267,7 +275,7 @@ namespace OpenSim.Framework.Communications | |||
267 | /// <returns>A user agent</returns> | 275 | /// <returns>A user agent</returns> |
268 | public UserAgentData GetUserAgent(string fname, string lname) | 276 | public UserAgentData GetUserAgent(string fname, string lname) |
269 | { | 277 | { |
270 | foreach (IUserDataPlugin plugin in _plugins) | 278 | foreach (IUserDataPlugin plugin in m_plugins) |
271 | { | 279 | { |
272 | try | 280 | try |
273 | { | 281 | { |
@@ -287,9 +295,9 @@ namespace OpenSim.Framework.Communications | |||
287 | /// </summary> | 295 | /// </summary> |
288 | /// <param name="name">the UUID of the friend list owner</param> | 296 | /// <param name="name">the UUID of the friend list owner</param> |
289 | /// <returns>A List of FriendListItems that contains info about the user's friends</returns> | 297 | /// <returns>A List of FriendListItems that contains info about the user's friends</returns> |
290 | public List<FriendListItem> GetUserFriendList(UUID ownerID) | 298 | public virtual List<FriendListItem> GetUserFriendList(UUID ownerID) |
291 | { | 299 | { |
292 | foreach (IUserDataPlugin plugin in _plugins) | 300 | foreach (IUserDataPlugin plugin in m_plugins) |
293 | { | 301 | { |
294 | try | 302 | try |
295 | { | 303 | { |
@@ -309,9 +317,9 @@ namespace OpenSim.Framework.Communications | |||
309 | return null; | 317 | return null; |
310 | } | 318 | } |
311 | 319 | ||
312 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) | 320 | public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) |
313 | { | 321 | { |
314 | foreach (IUserDataPlugin plugin in _plugins) | 322 | foreach (IUserDataPlugin plugin in m_plugins) |
315 | { | 323 | { |
316 | try | 324 | try |
317 | { | 325 | { |
@@ -332,7 +340,7 @@ namespace OpenSim.Framework.Communications | |||
332 | 340 | ||
333 | public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) | 341 | public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) |
334 | { | 342 | { |
335 | foreach (IUserDataPlugin plugin in _plugins) | 343 | foreach (IUserDataPlugin plugin in m_plugins) |
336 | { | 344 | { |
337 | try | 345 | try |
338 | { | 346 | { |
@@ -345,13 +353,13 @@ namespace OpenSim.Framework.Communications | |||
345 | } | 353 | } |
346 | } | 354 | } |
347 | 355 | ||
348 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | 356 | public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) |
349 | { | 357 | { |
350 | foreach (IUserDataPlugin plugin in _plugins) | 358 | foreach (IUserDataPlugin plugin in m_plugins) |
351 | { | 359 | { |
352 | try | 360 | try |
353 | { | 361 | { |
354 | plugin.AddNewUserFriend(friendlistowner,friend,perms); | 362 | plugin.AddNewUserFriend(friendlistowner, friend, perms); |
355 | } | 363 | } |
356 | catch (Exception e) | 364 | catch (Exception e) |
357 | { | 365 | { |
@@ -360,9 +368,9 @@ namespace OpenSim.Framework.Communications | |||
360 | } | 368 | } |
361 | } | 369 | } |
362 | 370 | ||
363 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | 371 | public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) |
364 | { | 372 | { |
365 | foreach (IUserDataPlugin plugin in _plugins) | 373 | foreach (IUserDataPlugin plugin in m_plugins) |
366 | { | 374 | { |
367 | try | 375 | try |
368 | { | 376 | { |
@@ -375,9 +383,9 @@ namespace OpenSim.Framework.Communications | |||
375 | } | 383 | } |
376 | } | 384 | } |
377 | 385 | ||
378 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | 386 | public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) |
379 | { | 387 | { |
380 | foreach (IUserDataPlugin plugin in _plugins) | 388 | foreach (IUserDataPlugin plugin in m_plugins) |
381 | { | 389 | { |
382 | try | 390 | try |
383 | { | 391 | { |
@@ -394,7 +402,7 @@ namespace OpenSim.Framework.Communications | |||
394 | /// Resets the currentAgent in the user profile | 402 | /// Resets the currentAgent in the user profile |
395 | /// </summary> | 403 | /// </summary> |
396 | /// <param name="agentID">The agent's ID</param> | 404 | /// <param name="agentID">The agent's ID</param> |
397 | public void ClearUserAgent(UUID agentID) | 405 | public virtual void ClearUserAgent(UUID agentID) |
398 | { | 406 | { |
399 | UserProfileData profile = GetUserProfile(agentID); | 407 | UserProfileData profile = GetUserProfile(agentID); |
400 | 408 | ||
@@ -408,7 +416,6 @@ namespace OpenSim.Framework.Communications | |||
408 | UpdateUserProfile(profile); | 416 | UpdateUserProfile(profile); |
409 | } | 417 | } |
410 | 418 | ||
411 | |||
412 | #endregion | 419 | #endregion |
413 | 420 | ||
414 | #region CreateAgent | 421 | #region CreateAgent |
@@ -544,7 +551,7 @@ namespace OpenSim.Framework.Communications | |||
544 | /// <param name="regionhandle"></param> | 551 | /// <param name="regionhandle"></param> |
545 | /// <param name="position"></param> | 552 | /// <param name="position"></param> |
546 | /// <param name="lookat"></param> | 553 | /// <param name="lookat"></param> |
547 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | 554 | public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) |
548 | { | 555 | { |
549 | if (StatsManager.UserStats != null) | 556 | if (StatsManager.UserStats != null) |
550 | StatsManager.UserStats.AddLogout(); | 557 | StatsManager.UserStats.AddLogout(); |
@@ -583,15 +590,6 @@ namespace OpenSim.Framework.Communications | |||
583 | } | 590 | } |
584 | } | 591 | } |
585 | 592 | ||
586 | /// <summary> | ||
587 | /// Process a user logoff from OpenSim (deprecated as of 2008-08-27) | ||
588 | /// </summary> | ||
589 | /// <param name="userid"></param> | ||
590 | /// <param name="regionid"></param> | ||
591 | /// <param name="regionhandle"></param> | ||
592 | /// <param name="posx"></param> | ||
593 | /// <param name="posy"></param> | ||
594 | /// <param name="posz"></param> | ||
595 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | 593 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) |
596 | { | 594 | { |
597 | LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); | 595 | LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); |
@@ -643,7 +641,7 @@ namespace OpenSim.Framework.Communications | |||
643 | user.HomeRegionY = regY; | 641 | user.HomeRegionY = regY; |
644 | user.Email = email; | 642 | user.Email = email; |
645 | 643 | ||
646 | foreach (IUserDataPlugin plugin in _plugins) | 644 | foreach (IUserDataPlugin plugin in m_plugins) |
647 | { | 645 | { |
648 | try | 646 | try |
649 | { | 647 | { |
@@ -669,13 +667,13 @@ namespace OpenSim.Framework.Communications | |||
669 | } | 667 | } |
670 | 668 | ||
671 | /// <summary> | 669 | /// <summary> |
672 | /// Reset a user password | 670 | /// Reset a user password. |
673 | /// </summary> | 671 | /// </summary> |
674 | /// <param name="firstName"></param> | 672 | /// <param name="firstName"></param> |
675 | /// <param name="lastName"></param> | 673 | /// <param name="lastName"></param> |
676 | /// <param name="newPassword"></param> | 674 | /// <param name="newPassword"></param> |
677 | /// <returns>true if the update was successful, false otherwise</returns> | 675 | /// <returns>true if the update was successful, false otherwise</returns> |
678 | public bool ResetUserPassword(string firstName, string lastName, string newPassword) | 676 | public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword) |
679 | { | 677 | { |
680 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty); | 678 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty); |
681 | 679 | ||
@@ -705,7 +703,7 @@ namespace OpenSim.Framework.Communications | |||
705 | /// <param name="agentdata">The agent data to be added</param> | 703 | /// <param name="agentdata">The agent data to be added</param> |
706 | public bool AddUserAgent(UserAgentData agentdata) | 704 | public bool AddUserAgent(UserAgentData agentdata) |
707 | { | 705 | { |
708 | foreach (IUserDataPlugin plugin in _plugins) | 706 | foreach (IUserDataPlugin plugin in m_plugins) |
709 | { | 707 | { |
710 | try | 708 | try |
711 | { | 709 | { |
@@ -725,9 +723,9 @@ namespace OpenSim.Framework.Communications | |||
725 | /// </summary> | 723 | /// </summary> |
726 | /// <param name="user"></param> | 724 | /// <param name="user"></param> |
727 | /// <returns></returns> | 725 | /// <returns></returns> |
728 | public AvatarAppearance GetUserAppearance(UUID user) | 726 | public virtual AvatarAppearance GetUserAppearance(UUID user) |
729 | { | 727 | { |
730 | foreach (IUserDataPlugin plugin in _plugins) | 728 | foreach (IUserDataPlugin plugin in m_plugins) |
731 | { | 729 | { |
732 | try | 730 | try |
733 | { | 731 | { |
@@ -741,14 +739,9 @@ namespace OpenSim.Framework.Communications | |||
741 | return null; | 739 | return null; |
742 | } | 740 | } |
743 | 741 | ||
744 | /// <summary> | 742 | public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) |
745 | /// Update avatar appearance information | ||
746 | /// </summary> | ||
747 | /// <param name="user"></param> | ||
748 | /// <param name="appearance"></param> | ||
749 | public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | ||
750 | { | 743 | { |
751 | foreach (IUserDataPlugin plugin in _plugins) | 744 | foreach (IUserDataPlugin plugin in m_plugins) |
752 | { | 745 | { |
753 | try | 746 | try |
754 | { | 747 | { |
@@ -838,8 +831,8 @@ namespace OpenSim.Framework.Communications | |||
838 | return false; | 831 | return false; |
839 | } | 832 | } |
840 | } | 833 | } |
841 | 834 | ||
842 | public bool VerifySession(UUID userID, UUID sessionID) | 835 | public virtual bool VerifySession(UUID userID, UUID sessionID) |
843 | { | 836 | { |
844 | UserProfileData userProfile = GetUserProfile(userID); | 837 | UserProfileData userProfile = GetUserProfile(userID); |
845 | 838 | ||
@@ -851,6 +844,7 @@ namespace OpenSim.Framework.Communications | |||
851 | return true; | 844 | return true; |
852 | } | 845 | } |
853 | } | 846 | } |
847 | |||
854 | return false; | 848 | return false; |
855 | } | 849 | } |
856 | 850 | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs b/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs index 6dec026..f76328c 100644 --- a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs +++ b/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs | |||
@@ -70,6 +70,6 @@ namespace OpenSim.Grid.MessagingServer.Modules | |||
70 | { | 70 | { |
71 | //throw new Exception("The method or operation is not implemented."); | 71 | //throw new Exception("The method or operation is not implemented."); |
72 | return null; | 72 | return null; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | } | 75 | } |
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs index 795efaa..8881e81 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs | |||
@@ -331,6 +331,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
331 | } | 331 | } |
332 | } | 332 | } |
333 | } | 333 | } |
334 | |||
334 | if (responseSuccess) | 335 | if (responseSuccess) |
335 | { | 336 | { |
336 | handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; | 337 | handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; |
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs index 2ef0fd3..1268237 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs | |||
@@ -31,6 +31,7 @@ using OpenSim.Framework; | |||
31 | using OpenSim.Framework.Communications; | 31 | using OpenSim.Framework.Communications; |
32 | using OpenSim.Framework.Communications.Cache; | 32 | using OpenSim.Framework.Communications.Cache; |
33 | using OpenSim.Framework.Servers; | 33 | using OpenSim.Framework.Servers; |
34 | using OpenSim.Region.Communications.OGS1; | ||
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
35 | 36 | ||
36 | namespace OpenSim.Region.Communications.Hypergrid | 37 | namespace OpenSim.Region.Communications.Hypergrid |
@@ -51,7 +52,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
51 | IAssetCache assetCache, SceneManager sman, LibraryRootFolder libraryRootFolder) | 52 | IAssetCache assetCache, SceneManager sman, LibraryRootFolder libraryRootFolder) |
52 | : base(serversInfo, httpServer, assetCache, false, libraryRootFolder) | 53 | : base(serversInfo, httpServer, assetCache, false, libraryRootFolder) |
53 | { | 54 | { |
54 | |||
55 | // From constructor at CommunicationsOGS1 | 55 | // From constructor at CommunicationsOGS1 |
56 | HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, httpServer, assetCache, sman, m_userProfileCacheService); | 56 | HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, httpServer, assetCache, sman, m_userProfileCacheService); |
57 | m_gridService = gridInterComms; | 57 | m_gridService = gridInterComms; |
@@ -63,12 +63,15 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
63 | AddSecureInventoryService(invService); | 63 | AddSecureInventoryService(invService); |
64 | m_defaultInventoryHost = invService.Host; | 64 | m_defaultInventoryHost = invService.Host; |
65 | if (SecureInventoryService != null) | 65 | if (SecureInventoryService != null) |
66 | m_log.Info("[HG] SecureInventoryService."); | 66 | m_log.Info("[HG]: SecureInventoryService."); |
67 | else | 67 | else |
68 | m_log.Info("[HG] Non-secureInventoryService."); | 68 | m_log.Info("[HG]: Non-secureInventoryService."); |
69 | |||
70 | 69 | ||
71 | HGUserServices userServices = new HGUserServices(this); | 70 | HGUserServices userServices = new HGUserServices(this); |
71 | // This plugin arrangement could eventually be configurable rather than hardcoded here. | ||
72 | OGS1UserDataPlugin userDataPlugin = new OGS1UserDataPlugin(this); | ||
73 | userServices.AddPlugin(userDataPlugin); | ||
74 | |||
72 | m_userService = userServices; | 75 | m_userService = userServices; |
73 | m_messageService = userServices; | 76 | m_messageService = userServices; |
74 | m_avatarService = (IAvatarService)m_userService; | 77 | m_avatarService = (IAvatarService)m_userService; |
diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs index 370ef12..357d8a6 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs | |||
@@ -59,6 +59,7 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
59 | 59 | ||
60 | // Constructor called when running in standalone | 60 | // Constructor called when running in standalone |
61 | public HGUserServices(LocalUserServices local) | 61 | public HGUserServices(LocalUserServices local) |
62 | : base(null) | ||
62 | { | 63 | { |
63 | m_localUserServices = local; | 64 | m_localUserServices = local; |
64 | } | 65 | } |
@@ -101,30 +102,12 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
101 | base.LogOffUser(userid, regionid, regionhandle, position, lookat); | 102 | base.LogOffUser(userid, regionid, regionhandle, position, lookat); |
102 | } | 103 | } |
103 | 104 | ||
104 | /// <summary> | ||
105 | /// Logs off a user on the user server (deprecated as of 2008-08-27) | ||
106 | /// </summary> | ||
107 | /// <param name="UserID">UUID of the user</param> | ||
108 | /// <param name="regionID">UUID of the Region</param> | ||
109 | /// <param name="regionhandle">regionhandle</param> | ||
110 | /// <param name="posx">final position x</param> | ||
111 | /// <param name="posy">final position y</param> | ||
112 | /// <param name="posz">final position z</param> | ||
113 | public override void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
114 | { | ||
115 | string url = string.Empty; | ||
116 | if ((m_localUserServices != null) && !IsForeignUser(userid, out url)) | ||
117 | m_localUserServices.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); | ||
118 | else | ||
119 | base.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); | ||
120 | } | ||
121 | |||
122 | public override UserProfileData GetUserProfile(string firstName, string lastName) | 105 | public override UserProfileData GetUserProfile(string firstName, string lastName) |
123 | { | 106 | { |
124 | if (m_localUserServices != null) | 107 | if (m_localUserServices != null) |
125 | return m_localUserServices.GetUserProfile(firstName, lastName); | 108 | return m_localUserServices.GetUserProfile(firstName, lastName); |
126 | 109 | ||
127 | return GetUserProfile(firstName + " " + lastName); | 110 | return base.GetUserProfile(firstName, lastName); |
128 | } | 111 | } |
129 | 112 | ||
130 | public override List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | 113 | public override List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) |
@@ -140,18 +123,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
140 | /// </summary> | 123 | /// </summary> |
141 | /// <param name="avatarID"></param> | 124 | /// <param name="avatarID"></param> |
142 | /// <returns>null if the request fails</returns> | 125 | /// <returns>null if the request fails</returns> |
143 | public override UserProfileData GetUserProfile(string name) | ||
144 | { | ||
145 | // This doesn't exist in LocalUserServices | ||
146 | |||
147 | return base.GetUserProfile(name); | ||
148 | } | ||
149 | |||
150 | /// <summary> | ||
151 | /// Get a user profile from the user server | ||
152 | /// </summary> | ||
153 | /// <param name="avatarID"></param> | ||
154 | /// <returns>null if the request fails</returns> | ||
155 | public override UserProfileData GetUserProfile(UUID avatarID) | 126 | public override UserProfileData GetUserProfile(UUID avatarID) |
156 | { | 127 | { |
157 | //string url = string.Empty; | 128 | //string url = string.Empty; |
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index a239033..eb60610 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs | |||
@@ -80,6 +80,6 @@ namespace OpenSim.Region.Communications.Local | |||
80 | throw new Exception("[LOCAL USER SERVICES]: Unknown master user UUID. Possible reason: UserServer is not running."); | 80 | throw new Exception("[LOCAL USER SERVICES]: Unknown master user UUID. Possible reason: UserServer is not running."); |
81 | } | 81 | } |
82 | return data; | 82 | return data; |
83 | } | 83 | } |
84 | } | 84 | } |
85 | } | 85 | } |
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index f32b160..ee8562f 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs | |||
@@ -55,7 +55,11 @@ namespace OpenSim.Region.Communications.OGS1 | |||
55 | m_defaultInventoryHost = invService.Host; | 55 | m_defaultInventoryHost = invService.Host; |
56 | } | 56 | } |
57 | 57 | ||
58 | // This plugin arrangement could eventually be configurable rather than hardcoded here. | ||
58 | OGS1UserServices userServices = new OGS1UserServices(this); | 59 | OGS1UserServices userServices = new OGS1UserServices(this); |
60 | OGS1UserDataPlugin userDataPlugin = new OGS1UserDataPlugin(this); | ||
61 | userServices.AddPlugin(userDataPlugin); | ||
62 | |||
59 | m_userService = userServices; | 63 | m_userService = userServices; |
60 | m_messageService = userServices; | 64 | m_messageService = userServices; |
61 | m_avatarService = (IAvatarService)m_userService; | 65 | m_avatarService = (IAvatarService)m_userService; |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs new file mode 100644 index 0000000..f543451 --- /dev/null +++ b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs | |||
@@ -0,0 +1,760 @@ | |||
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 OpenSim 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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using System.Xml.Serialization; | ||
35 | using log4net; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Data; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Framework.Communications.Clients; | ||
42 | |||
43 | namespace OpenSim.Region.Communications.OGS1 | ||
44 | { | ||
45 | public class OGS1UserDataPlugin : IUserDataPlugin | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | protected CommunicationsManager m_commsManager; | ||
50 | |||
51 | public OGS1UserDataPlugin(CommunicationsManager commsManager) | ||
52 | { | ||
53 | m_log.DebugFormat("[OGS1 USER SERVICES]: {0} initialized", Name); | ||
54 | m_commsManager = commsManager; | ||
55 | } | ||
56 | |||
57 | public string Version { get { return "0.1"; } } | ||
58 | public string Name { get { return "Open Grid Services 1 (OGS1) User Data Plugin"; } } | ||
59 | public void Initialise() {} | ||
60 | |||
61 | public void Initialise(string connect) {} | ||
62 | |||
63 | public void Dispose() {} | ||
64 | |||
65 | // Arguably the presence of these means that IUserDataPlugin could be fissioned | ||
66 | public UserAgentData GetUserAgent(string name) { return null; } | ||
67 | public UserAgentData GetAgentByName(string name) { return null; } | ||
68 | public UserAgentData GetAgentByName(string fname, string lname) { return null; } | ||
69 | public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {} | ||
70 | public void AddNewUserProfile(UserProfileData user) {} | ||
71 | public void AddNewUserAgent(UserAgentData agent) {} | ||
72 | public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } | ||
73 | public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; } | ||
74 | public void ResetAttachments(UUID userID) {} | ||
75 | public void LogoutUsers(UUID regionID) {} | ||
76 | |||
77 | public UserProfileData GetUserByUri(Uri uri) | ||
78 | { | ||
79 | WebRequest request = WebRequest.Create(uri); | ||
80 | |||
81 | WebResponse webResponse = request.GetResponse(); | ||
82 | |||
83 | XmlSerializer deserializer = new XmlSerializer(typeof(XmlRpcResponse)); | ||
84 | XmlRpcResponse xmlRpcResponse = (XmlRpcResponse)deserializer.Deserialize(webResponse.GetResponseStream()); | ||
85 | |||
86 | Hashtable respData = (Hashtable)xmlRpcResponse.Value; | ||
87 | |||
88 | return ConvertXMLRPCDataToUserProfile(respData); | ||
89 | } | ||
90 | |||
91 | // public Uri GetUserUri(UserProfileData userProfile) | ||
92 | // { | ||
93 | // throw new NotImplementedException(); | ||
94 | // } | ||
95 | |||
96 | public virtual UserAgentData GetAgentByUUID(UUID userId) | ||
97 | { | ||
98 | try | ||
99 | { | ||
100 | Hashtable param = new Hashtable(); | ||
101 | param["avatar_uuid"] = userId.ToString(); | ||
102 | IList parameters = new ArrayList(); | ||
103 | parameters.Add(param); | ||
104 | XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters); | ||
105 | |||
106 | XmlRpcResponse resp = req.Send(GetUserServerURL(userId), 6000); | ||
107 | Hashtable respData = (Hashtable)resp.Value; | ||
108 | if (respData.Contains("error_type")) | ||
109 | { | ||
110 | //m_log.Warn("[GRID]: " + | ||
111 | // "Error sent by user server when trying to get agent: (" + | ||
112 | // (string) respData["error_type"] + | ||
113 | // "): " + (string)respData["error_desc"]); | ||
114 | return null; | ||
115 | } | ||
116 | UUID sessionid = UUID.Zero; | ||
117 | |||
118 | UserAgentData userAgent = new UserAgentData(); | ||
119 | userAgent.Handle = Convert.ToUInt64((string)respData["handle"]); | ||
120 | UUID.TryParse((string)respData["sessionid"], out sessionid); | ||
121 | userAgent.SessionID = sessionid; | ||
122 | |||
123 | if ((string)respData["agent_online"] == "TRUE") | ||
124 | { | ||
125 | userAgent.AgentOnline = true; | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | userAgent.AgentOnline = false; | ||
130 | } | ||
131 | |||
132 | return userAgent; | ||
133 | } | ||
134 | catch (Exception e) | ||
135 | { | ||
136 | m_log.ErrorFormat( | ||
137 | "[OGS1 USER SERVICES]: Error when trying to fetch agent data by uuid from remote user server: {0}", | ||
138 | e); | ||
139 | } | ||
140 | |||
141 | return null; | ||
142 | } | ||
143 | |||
144 | public virtual UserProfileData GetUserByName(string firstName, string lastName) | ||
145 | { | ||
146 | return GetUserProfile(firstName + " " + lastName); | ||
147 | } | ||
148 | |||
149 | public virtual List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) | ||
150 | { | ||
151 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); | ||
152 | Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]"); | ||
153 | try | ||
154 | { | ||
155 | Hashtable param = new Hashtable(); | ||
156 | param["queryid"] = (string)queryID.ToString(); | ||
157 | param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty); | ||
158 | IList parameters = new ArrayList(); | ||
159 | parameters.Add(param); | ||
160 | XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters); | ||
161 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
162 | Hashtable respData = (Hashtable)resp.Value; | ||
163 | pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData); | ||
164 | } | ||
165 | catch (WebException e) | ||
166 | { | ||
167 | m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar Picker Response: " + | ||
168 | e.Message); | ||
169 | // Return Empty picker list (no results) | ||
170 | } | ||
171 | return pickerlist; | ||
172 | } | ||
173 | |||
174 | /// <summary> | ||
175 | /// Get a user profile from the user server | ||
176 | /// </summary> | ||
177 | /// <param name="avatarID"></param> | ||
178 | /// <returns>null if the request fails</returns> | ||
179 | protected virtual UserProfileData GetUserProfile(string name) | ||
180 | { | ||
181 | try | ||
182 | { | ||
183 | Hashtable param = new Hashtable(); | ||
184 | param["avatar_name"] = name; | ||
185 | IList parameters = new ArrayList(); | ||
186 | parameters.Add(param); | ||
187 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters); | ||
188 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); | ||
189 | Hashtable respData = (Hashtable)resp.Value; | ||
190 | |||
191 | return ConvertXMLRPCDataToUserProfile(respData); | ||
192 | } | ||
193 | catch (WebException e) | ||
194 | { | ||
195 | m_log.ErrorFormat( | ||
196 | "[OGS1 USER SERVICES]: Error when trying to fetch profile data by name from remote user server: {0}", | ||
197 | e); | ||
198 | } | ||
199 | |||
200 | return null; | ||
201 | } | ||
202 | |||
203 | /// <summary> | ||
204 | /// Get a user profile from the user server | ||
205 | /// </summary> | ||
206 | /// <param name="avatarID"></param> | ||
207 | /// <returns>null if the request fails</returns> | ||
208 | public virtual UserProfileData GetUserByUUID(UUID avatarID) | ||
209 | { | ||
210 | try | ||
211 | { | ||
212 | Hashtable param = new Hashtable(); | ||
213 | param["avatar_uuid"] = avatarID.ToString(); | ||
214 | IList parameters = new ArrayList(); | ||
215 | parameters.Add(param); | ||
216 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); | ||
217 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); | ||
218 | Hashtable respData = (Hashtable)resp.Value; | ||
219 | |||
220 | return ConvertXMLRPCDataToUserProfile(respData); | ||
221 | } | ||
222 | catch (Exception e) | ||
223 | { | ||
224 | m_log.ErrorFormat( | ||
225 | "[OGS1 USER SERVICES]: Error when trying to fetch profile data by uuid from remote user server: {0}", | ||
226 | e); | ||
227 | } | ||
228 | |||
229 | return null; | ||
230 | } | ||
231 | |||
232 | public virtual bool UpdateUserProfile(UserProfileData userProfile) | ||
233 | { | ||
234 | m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile."); | ||
235 | |||
236 | Hashtable param = new Hashtable(); | ||
237 | param["avatar_uuid"] = userProfile.ID.ToString(); | ||
238 | //param["AllowPublish"] = userProfile.ToString(); | ||
239 | param["FLImageID"] = userProfile.FirstLifeImage.ToString(); | ||
240 | param["ImageID"] = userProfile.Image.ToString(); | ||
241 | //param["MaturePublish"] = MaturePublish.ToString(); | ||
242 | param["AboutText"] = userProfile.AboutText; | ||
243 | param["FLAboutText"] = userProfile.FirstLifeAboutText; | ||
244 | //param["ProfileURL"] = userProfile.ProfileURL.ToString(); | ||
245 | |||
246 | param["home_region"] = userProfile.HomeRegion.ToString(); | ||
247 | param["home_region_id"] = userProfile.HomeRegionID.ToString(); | ||
248 | |||
249 | param["home_pos_x"] = userProfile.HomeLocationX.ToString(); | ||
250 | param["home_pos_y"] = userProfile.HomeLocationY.ToString(); | ||
251 | param["home_pos_z"] = userProfile.HomeLocationZ.ToString(); | ||
252 | param["home_look_x"] = userProfile.HomeLookAtX.ToString(); | ||
253 | param["home_look_y"] = userProfile.HomeLookAtY.ToString(); | ||
254 | param["home_look_z"] = userProfile.HomeLookAtZ.ToString(); | ||
255 | param["user_flags"] = userProfile.UserFlags.ToString(); | ||
256 | param["god_level"] = userProfile.GodLevel.ToString(); | ||
257 | param["custom_type"] = userProfile.CustomType.ToString(); | ||
258 | param["partner"] = userProfile.Partner.ToString(); | ||
259 | |||
260 | IList parameters = new ArrayList(); | ||
261 | parameters.Add(param); | ||
262 | |||
263 | XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters); | ||
264 | XmlRpcResponse resp = req.Send(GetUserServerURL(userProfile.ID), 3000); | ||
265 | Hashtable respData = (Hashtable)resp.Value; | ||
266 | if (respData != null) | ||
267 | { | ||
268 | if (respData.Contains("returnString")) | ||
269 | { | ||
270 | if (((string)respData["returnString"]).ToUpper() != "TRUE") | ||
271 | { | ||
272 | m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue"); | ||
273 | return false; | ||
274 | } | ||
275 | } | ||
276 | else | ||
277 | { | ||
278 | m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!"); | ||
279 | return false; | ||
280 | } | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!"); | ||
285 | return false; | ||
286 | } | ||
287 | |||
288 | return true; | ||
289 | } | ||
290 | |||
291 | /// <summary> | ||
292 | /// Adds a new friend to the database for XUser | ||
293 | /// </summary> | ||
294 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> | ||
295 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> | ||
296 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
297 | public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
298 | { | ||
299 | try | ||
300 | { | ||
301 | Hashtable param = new Hashtable(); | ||
302 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
303 | param["friendID"] = friend.Guid.ToString(); | ||
304 | param["friendPerms"] = perms.ToString(); | ||
305 | IList parameters = new ArrayList(); | ||
306 | parameters.Add(param); | ||
307 | |||
308 | XmlRpcRequest req = new XmlRpcRequest("add_new_user_friend", parameters); | ||
309 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
310 | Hashtable respData = (Hashtable)resp.Value; | ||
311 | if (respData != null) | ||
312 | { | ||
313 | if (respData.Contains("returnString")) | ||
314 | { | ||
315 | if ((string)respData["returnString"] == "TRUE") | ||
316 | { | ||
317 | |||
318 | } | ||
319 | else | ||
320 | { | ||
321 | m_log.Warn("[GRID]: Unable to add new friend, User Server Reported an issue"); | ||
322 | } | ||
323 | } | ||
324 | else | ||
325 | { | ||
326 | m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!"); | ||
327 | } | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!"); | ||
332 | |||
333 | } | ||
334 | } | ||
335 | catch (WebException e) | ||
336 | { | ||
337 | m_log.Warn("[GRID]: Error when trying to AddNewUserFriend: " + | ||
338 | e.Message); | ||
339 | |||
340 | } | ||
341 | } | ||
342 | |||
343 | /// <summary> | ||
344 | /// Delete friend on friendlistowner's friendlist. | ||
345 | /// </summary> | ||
346 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
347 | /// <param name="friend">The Ex-friend agent</param> | ||
348 | public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
349 | { | ||
350 | try | ||
351 | { | ||
352 | Hashtable param = new Hashtable(); | ||
353 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
354 | param["friendID"] = friend.Guid.ToString(); | ||
355 | |||
356 | IList parameters = new ArrayList(); | ||
357 | parameters.Add(param); | ||
358 | |||
359 | XmlRpcRequest req = new XmlRpcRequest("remove_user_friend", parameters); | ||
360 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
361 | Hashtable respData = (Hashtable)resp.Value; | ||
362 | if (respData != null) | ||
363 | { | ||
364 | if (respData.Contains("returnString")) | ||
365 | { | ||
366 | if ((string)respData["returnString"] == "TRUE") | ||
367 | { | ||
368 | |||
369 | } | ||
370 | else | ||
371 | { | ||
372 | m_log.Warn("[GRID]: Unable to remove friend, User Server Reported an issue"); | ||
373 | } | ||
374 | } | ||
375 | else | ||
376 | { | ||
377 | m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!"); | ||
378 | } | ||
379 | } | ||
380 | else | ||
381 | { | ||
382 | m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!"); | ||
383 | |||
384 | } | ||
385 | } | ||
386 | catch (WebException e) | ||
387 | { | ||
388 | m_log.Warn("[GRID]: Error when trying to RemoveUserFriend: " + | ||
389 | e.Message); | ||
390 | |||
391 | } | ||
392 | } | ||
393 | |||
394 | /// <summary> | ||
395 | /// Update permissions for friend on friendlistowner's friendlist. | ||
396 | /// </summary> | ||
397 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
398 | /// <param name="friend">The agent that is getting or loosing permissions</param> | ||
399 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
400 | public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
401 | { | ||
402 | try | ||
403 | { | ||
404 | Hashtable param = new Hashtable(); | ||
405 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
406 | param["friendID"] = friend.Guid.ToString(); | ||
407 | param["friendPerms"] = perms.ToString(); | ||
408 | IList parameters = new ArrayList(); | ||
409 | parameters.Add(param); | ||
410 | |||
411 | XmlRpcRequest req = new XmlRpcRequest("update_user_friend_perms", parameters); | ||
412 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
413 | Hashtable respData = (Hashtable)resp.Value; | ||
414 | if (respData != null) | ||
415 | { | ||
416 | if (respData.Contains("returnString")) | ||
417 | { | ||
418 | if ((string)respData["returnString"] == "TRUE") | ||
419 | { | ||
420 | |||
421 | } | ||
422 | else | ||
423 | { | ||
424 | m_log.Warn("[GRID]: Unable to update_user_friend_perms, User Server Reported an issue"); | ||
425 | } | ||
426 | } | ||
427 | else | ||
428 | { | ||
429 | m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!"); | ||
430 | } | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!"); | ||
435 | |||
436 | } | ||
437 | } | ||
438 | catch (WebException e) | ||
439 | { | ||
440 | m_log.Warn("[GRID]: Error when trying to update_user_friend_perms: " + | ||
441 | e.Message); | ||
442 | } | ||
443 | } | ||
444 | /// <summary> | ||
445 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner | ||
446 | /// </summary> | ||
447 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> | ||
448 | public virtual List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
449 | { | ||
450 | List<FriendListItem> buddylist = new List<FriendListItem>(); | ||
451 | |||
452 | try | ||
453 | { | ||
454 | Hashtable param = new Hashtable(); | ||
455 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
456 | |||
457 | IList parameters = new ArrayList(); | ||
458 | parameters.Add(param); | ||
459 | XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters); | ||
460 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); | ||
461 | Hashtable respData = (Hashtable)resp.Value; | ||
462 | |||
463 | if (respData != null && respData.Contains("avcount")) | ||
464 | { | ||
465 | buddylist = ConvertXMLRPCDataToFriendListItemList(respData); | ||
466 | } | ||
467 | |||
468 | } | ||
469 | catch (WebException e) | ||
470 | { | ||
471 | m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar's friends list: " + | ||
472 | e.Message); | ||
473 | // Return Empty list (no friends) | ||
474 | } | ||
475 | return buddylist; | ||
476 | } | ||
477 | |||
478 | public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) | ||
479 | { | ||
480 | Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>(); | ||
481 | |||
482 | // ask MessageServer about the current on-/offline status and regions the friends are in | ||
483 | ArrayList parameters = new ArrayList(); | ||
484 | Hashtable map = new Hashtable(); | ||
485 | |||
486 | ArrayList list = new ArrayList(); | ||
487 | foreach (UUID uuid in uuids) | ||
488 | { | ||
489 | list.Add(uuid.ToString()); | ||
490 | list.Add(uuid.ToString()); | ||
491 | } | ||
492 | map["uuids"] = list; | ||
493 | |||
494 | map["recv_key"] = m_commsManager.NetworkServersInfo.UserRecvKey; | ||
495 | map["send_key"] = m_commsManager.NetworkServersInfo.UserSendKey; | ||
496 | |||
497 | parameters.Add(map); | ||
498 | |||
499 | try | ||
500 | { | ||
501 | XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters); | ||
502 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000); | ||
503 | Hashtable respData = resp != null ? (Hashtable)resp.Value : null; | ||
504 | |||
505 | if (respData == null || respData.ContainsKey("faultMessage")) | ||
506 | { | ||
507 | m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessagingServer about user-regions resulted in error: {0}", | ||
508 | respData == null ? "<unknown error>" : respData["faultMessage"]); | ||
509 | } | ||
510 | else if (!respData.ContainsKey("count")) | ||
511 | { | ||
512 | m_log.WarnFormat("[OGS1 USER SERVICES]: Wrong format in response for MessagingServer request get_presence_info_bulk: missing 'count' field"); | ||
513 | } | ||
514 | else | ||
515 | { | ||
516 | int count = (int)respData["count"]; | ||
517 | m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count); | ||
518 | for (int i = 0; i < count; ++i) | ||
519 | { | ||
520 | if (respData.ContainsKey("uuid_" + i) && respData.ContainsKey("isOnline_" + i) && respData.ContainsKey("regionHandle_" + i)) | ||
521 | { | ||
522 | UUID uuid; | ||
523 | if (UUID.TryParse((string)respData["uuid_" + i], out uuid)) | ||
524 | { | ||
525 | FriendRegionInfo info = new FriendRegionInfo(); | ||
526 | info.isOnline = (bool)respData["isOnline_" + i]; | ||
527 | if (info.isOnline) | ||
528 | { | ||
529 | // TODO remove this after the next protocol update (say, r7800?) | ||
530 | info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]); | ||
531 | |||
532 | // accept missing id | ||
533 | if (respData.ContainsKey("regionID_" + i)) | ||
534 | UUID.TryParse((string)respData["regionID_" + i], out info.regionID); | ||
535 | } | ||
536 | |||
537 | result.Add(uuid, info); | ||
538 | } | ||
539 | } | ||
540 | else | ||
541 | { | ||
542 | m_log.WarnFormat("[OGS1 USER SERVICES]: Response to get_presence_info_bulk contained an error in entry {0}", i); | ||
543 | } | ||
544 | } | ||
545 | } | ||
546 | } | ||
547 | catch (WebException e) | ||
548 | { | ||
549 | m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message); | ||
550 | } | ||
551 | |||
552 | m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count); | ||
553 | |||
554 | return result; | ||
555 | } | ||
556 | |||
557 | public virtual AvatarAppearance GetUserAppearance(UUID user) | ||
558 | { | ||
559 | AvatarAppearance appearance = null; | ||
560 | |||
561 | try | ||
562 | { | ||
563 | Hashtable param = new Hashtable(); | ||
564 | param["owner"] = user.ToString(); | ||
565 | |||
566 | IList parameters = new ArrayList(); | ||
567 | parameters.Add(param); | ||
568 | XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters); | ||
569 | XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); | ||
570 | Hashtable respData = (Hashtable)resp.Value; | ||
571 | |||
572 | return ConvertXMLRPCDataToAvatarAppearance(respData); | ||
573 | } | ||
574 | catch (WebException e) | ||
575 | { | ||
576 | m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch appearance for avatar {0}, {1}", user, e.Message); | ||
577 | } | ||
578 | |||
579 | return appearance; | ||
580 | } | ||
581 | |||
582 | public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | ||
583 | { | ||
584 | try | ||
585 | { | ||
586 | Hashtable param = appearance.ToHashTable(); | ||
587 | param["owner"] = user.ToString(); | ||
588 | |||
589 | IList parameters = new ArrayList(); | ||
590 | parameters.Add(param); | ||
591 | XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters); | ||
592 | XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); | ||
593 | Hashtable respData = (Hashtable)resp.Value; | ||
594 | |||
595 | if (respData != null) | ||
596 | { | ||
597 | if (respData.Contains("returnString")) | ||
598 | { | ||
599 | if ((string)respData["returnString"] == "TRUE") | ||
600 | { | ||
601 | |||
602 | } | ||
603 | else | ||
604 | { | ||
605 | m_log.Warn("[GRID]: Unable to update_user_appearance, User Server Reported an issue"); | ||
606 | } | ||
607 | } | ||
608 | else | ||
609 | { | ||
610 | m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!"); | ||
611 | } | ||
612 | } | ||
613 | else | ||
614 | { | ||
615 | m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!"); | ||
616 | } | ||
617 | } | ||
618 | catch (WebException e) | ||
619 | { | ||
620 | m_log.Warn("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance: " + | ||
621 | e.Message); | ||
622 | // Return Empty list (no friends) | ||
623 | } | ||
624 | } | ||
625 | |||
626 | protected virtual string GetUserServerURL(UUID userID) | ||
627 | { | ||
628 | return m_commsManager.NetworkServersInfo.UserURL; | ||
629 | } | ||
630 | |||
631 | protected UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) | ||
632 | { | ||
633 | if (data.Contains("error_type")) | ||
634 | { | ||
635 | m_log.Warn("[GRID]: " + | ||
636 | "Error sent by user server when trying to get user profile: (" + | ||
637 | data["error_type"] + | ||
638 | "): " + data["error_desc"]); | ||
639 | return null; | ||
640 | } | ||
641 | |||
642 | UserProfileData userData = new UserProfileData(); | ||
643 | userData.FirstName = (string)data["firstname"]; | ||
644 | userData.SurName = (string)data["lastname"]; | ||
645 | userData.ID = new UUID((string)data["uuid"]); | ||
646 | userData.Created = Convert.ToInt32(data["profile_created"]); | ||
647 | userData.UserInventoryURI = (string)data["server_inventory"]; | ||
648 | userData.UserAssetURI = (string)data["server_asset"]; | ||
649 | userData.FirstLifeAboutText = (string)data["profile_firstlife_about"]; | ||
650 | userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]); | ||
651 | userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]); | ||
652 | userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]); | ||
653 | userData.AboutText = (string)data["profile_about"]; | ||
654 | userData.Image = new UUID((string)data["profile_image"]); | ||
655 | userData.LastLogin = Convert.ToInt32((string)data["profile_lastlogin"]); | ||
656 | userData.HomeRegion = Convert.ToUInt64((string)data["home_region"]); | ||
657 | if (data.Contains("home_region_id")) | ||
658 | userData.HomeRegionID = new UUID((string)data["home_region_id"]); | ||
659 | else | ||
660 | userData.HomeRegionID = UUID.Zero; | ||
661 | userData.HomeLocation = | ||
662 | new Vector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), | ||
663 | (float)Convert.ToDecimal((string)data["home_coordinates_y"]), | ||
664 | (float)Convert.ToDecimal((string)data["home_coordinates_z"])); | ||
665 | userData.HomeLookAt = | ||
666 | new Vector3((float)Convert.ToDecimal((string)data["home_look_x"]), | ||
667 | (float)Convert.ToDecimal((string)data["home_look_y"]), | ||
668 | (float)Convert.ToDecimal((string)data["home_look_z"])); | ||
669 | if (data.Contains("user_flags")) | ||
670 | userData.UserFlags = Convert.ToInt32((string)data["user_flags"]); | ||
671 | if (data.Contains("god_level")) | ||
672 | userData.GodLevel = Convert.ToInt32((string)data["god_level"]); | ||
673 | |||
674 | if (data.Contains("custom_type")) | ||
675 | userData.CustomType = (string)data["custom_type"]; | ||
676 | else | ||
677 | userData.CustomType = ""; | ||
678 | if (userData.CustomType == null) | ||
679 | userData.CustomType = ""; | ||
680 | |||
681 | if (data.Contains("partner")) | ||
682 | userData.Partner = new UUID((string)data["partner"]); | ||
683 | else | ||
684 | userData.Partner = UUID.Zero; | ||
685 | |||
686 | return userData; | ||
687 | } | ||
688 | |||
689 | protected AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data) | ||
690 | { | ||
691 | if (data != null) | ||
692 | { | ||
693 | if (data.Contains("error_type")) | ||
694 | { | ||
695 | m_log.Warn("[GRID]: " + | ||
696 | "Error sent by user server when trying to get user appearance: (" + | ||
697 | data["error_type"] + | ||
698 | "): " + data["error_desc"]); | ||
699 | return null; | ||
700 | } | ||
701 | else | ||
702 | { | ||
703 | return new AvatarAppearance(data); | ||
704 | } | ||
705 | } | ||
706 | else | ||
707 | { | ||
708 | m_log.Error("[GRID]: The avatar appearance is null, something bad happenend"); | ||
709 | return null; | ||
710 | } | ||
711 | } | ||
712 | |||
713 | protected List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data) | ||
714 | { | ||
715 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); | ||
716 | int pickercount = Convert.ToInt32((string)data["avcount"]); | ||
717 | UUID respqueryID = new UUID((string)data["queryid"]); | ||
718 | if (queryID == respqueryID) | ||
719 | { | ||
720 | for (int i = 0; i < pickercount; i++) | ||
721 | { | ||
722 | AvatarPickerAvatar apicker = new AvatarPickerAvatar(); | ||
723 | UUID avatarID = new UUID((string)data["avatarid" + i.ToString()]); | ||
724 | string firstname = (string)data["firstname" + i.ToString()]; | ||
725 | string lastname = (string)data["lastname" + i.ToString()]; | ||
726 | apicker.AvatarID = avatarID; | ||
727 | apicker.firstName = firstname; | ||
728 | apicker.lastName = lastname; | ||
729 | pickerlist.Add(apicker); | ||
730 | } | ||
731 | } | ||
732 | else | ||
733 | { | ||
734 | m_log.Warn("[OGS1 USER SERVICES]: Got invalid queryID from userServer"); | ||
735 | } | ||
736 | return pickerlist; | ||
737 | } | ||
738 | |||
739 | protected List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data) | ||
740 | { | ||
741 | List<FriendListItem> buddylist = new List<FriendListItem>(); | ||
742 | int buddycount = Convert.ToInt32((string)data["avcount"]); | ||
743 | |||
744 | |||
745 | for (int i = 0; i < buddycount; i++) | ||
746 | { | ||
747 | FriendListItem buddylistitem = new FriendListItem(); | ||
748 | |||
749 | buddylistitem.FriendListOwner = new UUID((string)data["ownerID" + i.ToString()]); | ||
750 | buddylistitem.Friend = new UUID((string)data["friendID" + i.ToString()]); | ||
751 | buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]); | ||
752 | buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]); | ||
753 | |||
754 | buddylist.Add(buddylistitem); | ||
755 | } | ||
756 | |||
757 | return buddylist; | ||
758 | } | ||
759 | } | ||
760 | } | ||
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 1836328..5f77107 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | |||
@@ -35,229 +35,36 @@ using System.Xml.Serialization; | |||
35 | using log4net; | 35 | using log4net; |
36 | using Nwc.XmlRpc; | 36 | using Nwc.XmlRpc; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenSim.Data; | ||
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Framework.Communications.Clients; | 41 | using OpenSim.Framework.Communications.Clients; |
41 | 42 | ||
42 | namespace OpenSim.Region.Communications.OGS1 | 43 | namespace OpenSim.Region.Communications.OGS1 |
43 | { | 44 | { |
44 | public class OGS1UserServices : IUserService, IAvatarService, IMessagingService | 45 | public class OGS1UserServices : UserManagerBase |
45 | { | 46 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 48 | ||
48 | protected CommunicationsManager m_commsManager; | 49 | protected CommunicationsManager m_commsManager; |
49 | 50 | ||
50 | public OGS1UserServices(CommunicationsManager commsManager) | 51 | public OGS1UserServices(CommunicationsManager commsManager) |
52 | : base(commsManager.InterServiceInventoryService) | ||
51 | { | 53 | { |
52 | m_commsManager = commsManager; | 54 | m_commsManager = commsManager; |
53 | } | 55 | } |
54 | 56 | ||
55 | public OGS1UserServices() | 57 | public override void ClearUserAgent(UUID avatarID) |
56 | { | ||
57 | } | ||
58 | |||
59 | public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) | ||
60 | { | ||
61 | if (data.Contains("error_type")) | ||
62 | { | ||
63 | m_log.Warn("[GRID]: " + | ||
64 | "Error sent by user server when trying to get user profile: (" + | ||
65 | data["error_type"] + | ||
66 | "): " + data["error_desc"]); | ||
67 | return null; | ||
68 | } | ||
69 | |||
70 | UserProfileData userData = new UserProfileData(); | ||
71 | userData.FirstName = (string)data["firstname"]; | ||
72 | userData.SurName = (string)data["lastname"]; | ||
73 | userData.ID = new UUID((string)data["uuid"]); | ||
74 | userData.Created = Convert.ToInt32(data["profile_created"]); | ||
75 | userData.UserInventoryURI = (string)data["server_inventory"]; | ||
76 | userData.UserAssetURI = (string)data["server_asset"]; | ||
77 | userData.FirstLifeAboutText = (string)data["profile_firstlife_about"]; | ||
78 | userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]); | ||
79 | userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]); | ||
80 | userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]); | ||
81 | userData.AboutText = (string)data["profile_about"]; | ||
82 | userData.Image = new UUID((string)data["profile_image"]); | ||
83 | userData.LastLogin = Convert.ToInt32((string)data["profile_lastlogin"]); | ||
84 | userData.HomeRegion = Convert.ToUInt64((string)data["home_region"]); | ||
85 | if (data.Contains("home_region_id")) | ||
86 | userData.HomeRegionID = new UUID((string)data["home_region_id"]); | ||
87 | else | ||
88 | userData.HomeRegionID = UUID.Zero; | ||
89 | userData.HomeLocation = | ||
90 | new Vector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), | ||
91 | (float)Convert.ToDecimal((string)data["home_coordinates_y"]), | ||
92 | (float)Convert.ToDecimal((string)data["home_coordinates_z"])); | ||
93 | userData.HomeLookAt = | ||
94 | new Vector3((float)Convert.ToDecimal((string)data["home_look_x"]), | ||
95 | (float)Convert.ToDecimal((string)data["home_look_y"]), | ||
96 | (float)Convert.ToDecimal((string)data["home_look_z"])); | ||
97 | if (data.Contains("user_flags")) | ||
98 | userData.UserFlags = Convert.ToInt32((string)data["user_flags"]); | ||
99 | if (data.Contains("god_level")) | ||
100 | userData.GodLevel = Convert.ToInt32((string)data["god_level"]); | ||
101 | |||
102 | if (data.Contains("custom_type")) | ||
103 | userData.CustomType = (string)data["custom_type"]; | ||
104 | else | ||
105 | userData.CustomType = ""; | ||
106 | if (userData.CustomType == null) | ||
107 | userData.CustomType = ""; | ||
108 | |||
109 | if (data.Contains("partner")) | ||
110 | userData.Partner = new UUID((string)data["partner"]); | ||
111 | else | ||
112 | userData.Partner = UUID.Zero; | ||
113 | |||
114 | return userData; | ||
115 | } | ||
116 | |||
117 | public UserProfileData GetUserProfile(Uri uri) | ||
118 | { | 58 | { |
119 | WebRequest request = WebRequest.Create(uri); | 59 | // TODO: implement |
120 | 60 | // It may be possible to use the UserManagerBase implementation. | |
121 | WebResponse webResponse = request.GetResponse(); | ||
122 | |||
123 | XmlSerializer deserializer = new XmlSerializer(typeof(XmlRpcResponse)); | ||
124 | XmlRpcResponse xmlRpcResponse = (XmlRpcResponse)deserializer.Deserialize(webResponse.GetResponseStream()); | ||
125 | |||
126 | Hashtable respData = (Hashtable)xmlRpcResponse.Value; | ||
127 | |||
128 | return ConvertXMLRPCDataToUserProfile(respData); | ||
129 | } | ||
130 | |||
131 | public Uri GetUserUri(UserProfileData userProfile) | ||
132 | { | ||
133 | throw new NotImplementedException(); | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Get a user agent from the user server | ||
138 | /// </summary> | ||
139 | /// <param name="avatarID"></param> | ||
140 | /// <returns>null if the request fails</returns> | ||
141 | public virtual UserAgentData GetAgentByUUID(UUID userId) | ||
142 | { | ||
143 | try | ||
144 | { | ||
145 | Hashtable param = new Hashtable(); | ||
146 | param["avatar_uuid"] = userId.ToString(); | ||
147 | IList parameters = new ArrayList(); | ||
148 | parameters.Add(param); | ||
149 | XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters); | ||
150 | |||
151 | XmlRpcResponse resp = req.Send(GetUserServerURL(userId), 6000); | ||
152 | Hashtable respData = (Hashtable)resp.Value; | ||
153 | if (respData.Contains("error_type")) | ||
154 | { | ||
155 | //m_log.Warn("[GRID]: " + | ||
156 | // "Error sent by user server when trying to get agent: (" + | ||
157 | // (string) respData["error_type"] + | ||
158 | // "): " + (string)respData["error_desc"]); | ||
159 | return null; | ||
160 | } | ||
161 | UUID sessionid = UUID.Zero; | ||
162 | |||
163 | UserAgentData userAgent = new UserAgentData(); | ||
164 | userAgent.Handle = Convert.ToUInt64((string)respData["handle"]); | ||
165 | UUID.TryParse((string)respData["sessionid"], out sessionid); | ||
166 | userAgent.SessionID = sessionid; | ||
167 | |||
168 | if ((string)respData["agent_online"] == "TRUE") | ||
169 | { | ||
170 | userAgent.AgentOnline = true; | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | userAgent.AgentOnline = false; | ||
175 | } | ||
176 | |||
177 | return userAgent; | ||
178 | } | ||
179 | catch (Exception e) | ||
180 | { | ||
181 | m_log.ErrorFormat( | ||
182 | "[OGS1 USER SERVICES]: Error when trying to fetch agent data by uuid from remote user server: {0}", | ||
183 | e); | ||
184 | } | ||
185 | |||
186 | return null; | ||
187 | } | ||
188 | |||
189 | public AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data) | ||
190 | { | ||
191 | if (data != null) | ||
192 | { | ||
193 | if (data.Contains("error_type")) | ||
194 | { | ||
195 | m_log.Warn("[GRID]: " + | ||
196 | "Error sent by user server when trying to get user appearance: (" + | ||
197 | data["error_type"] + | ||
198 | "): " + data["error_desc"]); | ||
199 | return null; | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | return new AvatarAppearance(data); | ||
204 | } | ||
205 | } | ||
206 | else | ||
207 | { | ||
208 | m_log.Error("[GRID]: The avatar appearance is null, something bad happenend"); | ||
209 | return null; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data) | ||
214 | { | ||
215 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); | ||
216 | int pickercount = Convert.ToInt32((string)data["avcount"]); | ||
217 | UUID respqueryID = new UUID((string)data["queryid"]); | ||
218 | if (queryID == respqueryID) | ||
219 | { | ||
220 | for (int i = 0; i < pickercount; i++) | ||
221 | { | ||
222 | AvatarPickerAvatar apicker = new AvatarPickerAvatar(); | ||
223 | UUID avatarID = new UUID((string)data["avatarid" + i.ToString()]); | ||
224 | string firstname = (string)data["firstname" + i.ToString()]; | ||
225 | string lastname = (string)data["lastname" + i.ToString()]; | ||
226 | apicker.AvatarID = avatarID; | ||
227 | apicker.firstName = firstname; | ||
228 | apicker.lastName = lastname; | ||
229 | pickerlist.Add(apicker); | ||
230 | } | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | m_log.Warn("[OGS1 USER SERVICES]: Got invalid queryID from userServer"); | ||
235 | } | ||
236 | return pickerlist; | ||
237 | } | 61 | } |
238 | 62 | ||
239 | public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data) | 63 | protected virtual string GetUserServerURL(UUID userID) |
240 | { | 64 | { |
241 | List<FriendListItem> buddylist = new List<FriendListItem>(); | 65 | return m_commsManager.NetworkServersInfo.UserURL; |
242 | int buddycount = Convert.ToInt32((string)data["avcount"]); | ||
243 | |||
244 | |||
245 | for (int i = 0; i < buddycount; i++) | ||
246 | { | ||
247 | FriendListItem buddylistitem = new FriendListItem(); | ||
248 | |||
249 | buddylistitem.FriendListOwner = new UUID((string)data["ownerID" + i.ToString()]); | ||
250 | buddylistitem.Friend = new UUID((string)data["friendID" + i.ToString()]); | ||
251 | buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]); | ||
252 | buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]); | ||
253 | |||
254 | buddylist.Add(buddylistitem); | ||
255 | } | ||
256 | |||
257 | |||
258 | return buddylist; | ||
259 | } | 66 | } |
260 | 67 | ||
261 | /// <summary> | 68 | /// <summary> |
262 | /// Logs off a user on the user server | 69 | /// Logs off a user on the user server |
263 | /// </summary> | 70 | /// </summary> |
@@ -266,7 +73,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
266 | /// <param name="regionhandle">regionhandle</param> | 73 | /// <param name="regionhandle">regionhandle</param> |
267 | /// <param name="position">final position</param> | 74 | /// <param name="position">final position</param> |
268 | /// <param name="lookat">final lookat</param> | 75 | /// <param name="lookat">final lookat</param> |
269 | public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | 76 | public override void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) |
270 | { | 77 | { |
271 | Hashtable param = new Hashtable(); | 78 | Hashtable param = new Hashtable(); |
272 | param["avatar_uuid"] = userid.Guid.ToString(); | 79 | param["avatar_uuid"] = userid.Guid.ToString(); |
@@ -290,123 +97,15 @@ namespace OpenSim.Region.Communications.OGS1 | |||
290 | catch (WebException) | 97 | catch (WebException) |
291 | { | 98 | { |
292 | m_log.Warn("[LOGOFF]: Unable to notify grid server of user logoff"); | 99 | m_log.Warn("[LOGOFF]: Unable to notify grid server of user logoff"); |
293 | } | 100 | } |
294 | } | ||
295 | |||
296 | /// <summary> | ||
297 | /// Logs off a user on the user server (deprecated as of 2008-08-27) | ||
298 | /// </summary> | ||
299 | /// <param name="UserID">UUID of the user</param> | ||
300 | /// <param name="regionID">UUID of the Region</param> | ||
301 | /// <param name="regionhandle">regionhandle</param> | ||
302 | /// <param name="posx">final position x</param> | ||
303 | /// <param name="posy">final position y</param> | ||
304 | /// <param name="posz">final position z</param> | ||
305 | public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
306 | { | ||
307 | LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); | ||
308 | } | ||
309 | |||
310 | public virtual UserProfileData GetUserProfile(string firstName, string lastName) | ||
311 | { | ||
312 | return GetUserProfile(firstName + " " + lastName); | ||
313 | } | ||
314 | |||
315 | public virtual List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | ||
316 | { | ||
317 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); | ||
318 | Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]"); | ||
319 | try | ||
320 | { | ||
321 | Hashtable param = new Hashtable(); | ||
322 | param["queryid"] = (string)queryID.ToString(); | ||
323 | param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty); | ||
324 | IList parameters = new ArrayList(); | ||
325 | parameters.Add(param); | ||
326 | XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters); | ||
327 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
328 | Hashtable respData = (Hashtable)resp.Value; | ||
329 | pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData); | ||
330 | } | ||
331 | catch (WebException e) | ||
332 | { | ||
333 | m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar Picker Response: " + | ||
334 | e.Message); | ||
335 | // Return Empty picker list (no results) | ||
336 | } | ||
337 | return pickerlist; | ||
338 | } | ||
339 | |||
340 | /// <summary> | ||
341 | /// Get a user profile from the user server | ||
342 | /// </summary> | ||
343 | /// <param name="avatarID"></param> | ||
344 | /// <returns>null if the request fails</returns> | ||
345 | public virtual UserProfileData GetUserProfile(string name) | ||
346 | { | ||
347 | try | ||
348 | { | ||
349 | Hashtable param = new Hashtable(); | ||
350 | param["avatar_name"] = name; | ||
351 | IList parameters = new ArrayList(); | ||
352 | parameters.Add(param); | ||
353 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters); | ||
354 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); | ||
355 | Hashtable respData = (Hashtable)resp.Value; | ||
356 | |||
357 | return ConvertXMLRPCDataToUserProfile(respData); | ||
358 | } | ||
359 | catch (WebException e) | ||
360 | { | ||
361 | m_log.ErrorFormat( | ||
362 | "[OGS1 USER SERVICES]: Error when trying to fetch profile data by name from remote user server: {0}", | ||
363 | e); | ||
364 | } | ||
365 | |||
366 | return null; | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
370 | /// Get a user profile from the user server | ||
371 | /// </summary> | ||
372 | /// <param name="avatarID"></param> | ||
373 | /// <returns>null if the request fails</returns> | ||
374 | public virtual UserProfileData GetUserProfile(UUID avatarID) | ||
375 | { | ||
376 | try | ||
377 | { | ||
378 | Hashtable param = new Hashtable(); | ||
379 | param["avatar_uuid"] = avatarID.ToString(); | ||
380 | IList parameters = new ArrayList(); | ||
381 | parameters.Add(param); | ||
382 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); | ||
383 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); | ||
384 | Hashtable respData = (Hashtable)resp.Value; | ||
385 | |||
386 | return ConvertXMLRPCDataToUserProfile(respData); | ||
387 | } | ||
388 | catch (Exception e) | ||
389 | { | ||
390 | m_log.ErrorFormat( | ||
391 | "[OGS1 USER SERVICES]: Error when trying to fetch profile data by uuid from remote user server: {0}", | ||
392 | e); | ||
393 | } | ||
394 | |||
395 | return null; | ||
396 | } | ||
397 | |||
398 | |||
399 | public virtual void ClearUserAgent(UUID avatarID) | ||
400 | { | ||
401 | // TODO: implement | ||
402 | } | 101 | } |
403 | 102 | ||
404 | /// <summary> | 103 | /// <summary> |
405 | /// Retrieve the user information for the given master uuid. | 104 | /// Retrieve the user information for the given master uuid. |
406 | /// </summary> | 105 | /// </summary> |
407 | /// <param name="uuid"></param> | 106 | /// <param name="uuid"></param> |
408 | /// <returns></returns> | 107 | /// <returns></returns> |
409 | public virtual UserProfileData SetupMasterUser(string firstName, string lastName) | 108 | public override UserProfileData SetupMasterUser(string firstName, string lastName) |
410 | { | 109 | { |
411 | return SetupMasterUser(firstName, lastName, String.Empty); | 110 | return SetupMasterUser(firstName, lastName, String.Empty); |
412 | } | 111 | } |
@@ -416,7 +115,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
416 | /// </summary> | 115 | /// </summary> |
417 | /// <param name="uuid"></param> | 116 | /// <param name="uuid"></param> |
418 | /// <returns></returns> | 117 | /// <returns></returns> |
419 | public virtual UserProfileData SetupMasterUser(string firstName, string lastName, string password) | 118 | public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) |
420 | { | 119 | { |
421 | UserProfileData profile = GetUserProfile(firstName, lastName); | 120 | UserProfileData profile = GetUserProfile(firstName, lastName); |
422 | return profile; | 121 | return profile; |
@@ -427,7 +126,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
427 | /// </summary> | 126 | /// </summary> |
428 | /// <param name="uuid"></param> | 127 | /// <param name="uuid"></param> |
429 | /// <returns></returns> | 128 | /// <returns></returns> |
430 | public virtual UserProfileData SetupMasterUser(UUID uuid) | 129 | public override UserProfileData SetupMasterUser(UUID uuid) |
431 | { | 130 | { |
432 | UserProfileData data = GetUserProfile(uuid); | 131 | UserProfileData data = GetUserProfile(uuid); |
433 | 132 | ||
@@ -439,424 +138,11 @@ namespace OpenSim.Region.Communications.OGS1 | |||
439 | 138 | ||
440 | return data; | 139 | return data; |
441 | } | 140 | } |
442 | 141 | ||
443 | public virtual UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) | 142 | public override bool VerifySession(UUID userID, UUID sessionID) |
444 | { | ||
445 | throw new Exception("The method or operation is not implemented."); | ||
446 | } | ||
447 | |||
448 | public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword) | ||
449 | { | ||
450 | throw new Exception("The method or operation is not implemented."); | ||
451 | } | ||
452 | |||
453 | public virtual bool UpdateUserProfile(UserProfileData userProfile) | ||
454 | { | ||
455 | m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile."); | ||
456 | Hashtable param = new Hashtable(); | ||
457 | param["avatar_uuid"] = userProfile.ID.ToString(); | ||
458 | //param["AllowPublish"] = userProfile.ToString(); | ||
459 | param["FLImageID"] = userProfile.FirstLifeImage.ToString(); | ||
460 | param["ImageID"] = userProfile.Image.ToString(); | ||
461 | //param["MaturePublish"] = MaturePublish.ToString(); | ||
462 | param["AboutText"] = userProfile.AboutText; | ||
463 | param["FLAboutText"] = userProfile.FirstLifeAboutText; | ||
464 | //param["ProfileURL"] = userProfile.ProfileURL.ToString(); | ||
465 | |||
466 | param["home_region"] = userProfile.HomeRegion.ToString(); | ||
467 | param["home_region_id"] = userProfile.HomeRegionID.ToString(); | ||
468 | |||
469 | param["home_pos_x"] = userProfile.HomeLocationX.ToString(); | ||
470 | param["home_pos_y"] = userProfile.HomeLocationY.ToString(); | ||
471 | param["home_pos_z"] = userProfile.HomeLocationZ.ToString(); | ||
472 | param["home_look_x"] = userProfile.HomeLookAtX.ToString(); | ||
473 | param["home_look_y"] = userProfile.HomeLookAtY.ToString(); | ||
474 | param["home_look_z"] = userProfile.HomeLookAtZ.ToString(); | ||
475 | param["user_flags"] = userProfile.UserFlags.ToString(); | ||
476 | param["god_level"] = userProfile.GodLevel.ToString(); | ||
477 | param["custom_type"] = userProfile.CustomType.ToString(); | ||
478 | param["partner"] = userProfile.Partner.ToString(); | ||
479 | |||
480 | IList parameters = new ArrayList(); | ||
481 | parameters.Add(param); | ||
482 | |||
483 | XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters); | ||
484 | XmlRpcResponse resp = req.Send(GetUserServerURL(userProfile.ID), 3000); | ||
485 | Hashtable respData = (Hashtable)resp.Value; | ||
486 | if (respData != null) | ||
487 | { | ||
488 | if (respData.Contains("returnString")) | ||
489 | { | ||
490 | if (((string)respData["returnString"]).ToUpper() != "TRUE") | ||
491 | { | ||
492 | m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue"); | ||
493 | return false; | ||
494 | } | ||
495 | } | ||
496 | else | ||
497 | { | ||
498 | m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!"); | ||
499 | return false; | ||
500 | } | ||
501 | } | ||
502 | else | ||
503 | { | ||
504 | m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!"); | ||
505 | return false; | ||
506 | } | ||
507 | |||
508 | return true; | ||
509 | } | ||
510 | |||
511 | #region IUserServices Friend Methods | ||
512 | /// <summary> | ||
513 | /// Adds a new friend to the database for XUser | ||
514 | /// </summary> | ||
515 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> | ||
516 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> | ||
517 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
518 | public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
519 | { | ||
520 | try | ||
521 | { | ||
522 | Hashtable param = new Hashtable(); | ||
523 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
524 | param["friendID"] = friend.Guid.ToString(); | ||
525 | param["friendPerms"] = perms.ToString(); | ||
526 | IList parameters = new ArrayList(); | ||
527 | parameters.Add(param); | ||
528 | |||
529 | XmlRpcRequest req = new XmlRpcRequest("add_new_user_friend", parameters); | ||
530 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
531 | Hashtable respData = (Hashtable)resp.Value; | ||
532 | if (respData != null) | ||
533 | { | ||
534 | if (respData.Contains("returnString")) | ||
535 | { | ||
536 | if ((string)respData["returnString"] == "TRUE") | ||
537 | { | ||
538 | |||
539 | } | ||
540 | else | ||
541 | { | ||
542 | m_log.Warn("[GRID]: Unable to add new friend, User Server Reported an issue"); | ||
543 | } | ||
544 | } | ||
545 | else | ||
546 | { | ||
547 | m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!"); | ||
548 | } | ||
549 | } | ||
550 | else | ||
551 | { | ||
552 | m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!"); | ||
553 | |||
554 | } | ||
555 | } | ||
556 | catch (WebException e) | ||
557 | { | ||
558 | m_log.Warn("[GRID]: Error when trying to AddNewUserFriend: " + | ||
559 | e.Message); | ||
560 | |||
561 | } | ||
562 | |||
563 | } | ||
564 | |||
565 | /// <summary> | ||
566 | /// Delete friend on friendlistowner's friendlist. | ||
567 | /// </summary> | ||
568 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
569 | /// <param name="friend">The Ex-friend agent</param> | ||
570 | public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
571 | { | ||
572 | try | ||
573 | { | ||
574 | Hashtable param = new Hashtable(); | ||
575 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
576 | param["friendID"] = friend.Guid.ToString(); | ||
577 | |||
578 | IList parameters = new ArrayList(); | ||
579 | parameters.Add(param); | ||
580 | |||
581 | XmlRpcRequest req = new XmlRpcRequest("remove_user_friend", parameters); | ||
582 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
583 | Hashtable respData = (Hashtable)resp.Value; | ||
584 | if (respData != null) | ||
585 | { | ||
586 | if (respData.Contains("returnString")) | ||
587 | { | ||
588 | if ((string)respData["returnString"] == "TRUE") | ||
589 | { | ||
590 | |||
591 | } | ||
592 | else | ||
593 | { | ||
594 | m_log.Warn("[GRID]: Unable to remove friend, User Server Reported an issue"); | ||
595 | } | ||
596 | } | ||
597 | else | ||
598 | { | ||
599 | m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!"); | ||
600 | } | ||
601 | } | ||
602 | else | ||
603 | { | ||
604 | m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!"); | ||
605 | |||
606 | } | ||
607 | } | ||
608 | catch (WebException e) | ||
609 | { | ||
610 | m_log.Warn("[GRID]: Error when trying to RemoveUserFriend: " + | ||
611 | e.Message); | ||
612 | |||
613 | } | ||
614 | } | ||
615 | |||
616 | /// <summary> | ||
617 | /// Update permissions for friend on friendlistowner's friendlist. | ||
618 | /// </summary> | ||
619 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
620 | /// <param name="friend">The agent that is getting or loosing permissions</param> | ||
621 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
622 | public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
623 | { | ||
624 | try | ||
625 | { | ||
626 | Hashtable param = new Hashtable(); | ||
627 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
628 | param["friendID"] = friend.Guid.ToString(); | ||
629 | param["friendPerms"] = perms.ToString(); | ||
630 | IList parameters = new ArrayList(); | ||
631 | parameters.Add(param); | ||
632 | |||
633 | XmlRpcRequest req = new XmlRpcRequest("update_user_friend_perms", parameters); | ||
634 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | ||
635 | Hashtable respData = (Hashtable)resp.Value; | ||
636 | if (respData != null) | ||
637 | { | ||
638 | if (respData.Contains("returnString")) | ||
639 | { | ||
640 | if ((string)respData["returnString"] == "TRUE") | ||
641 | { | ||
642 | |||
643 | } | ||
644 | else | ||
645 | { | ||
646 | m_log.Warn("[GRID]: Unable to update_user_friend_perms, User Server Reported an issue"); | ||
647 | } | ||
648 | } | ||
649 | else | ||
650 | { | ||
651 | m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!"); | ||
652 | } | ||
653 | } | ||
654 | else | ||
655 | { | ||
656 | m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!"); | ||
657 | |||
658 | } | ||
659 | } | ||
660 | catch (WebException e) | ||
661 | { | ||
662 | m_log.Warn("[GRID]: Error when trying to update_user_friend_perms: " + | ||
663 | e.Message); | ||
664 | } | ||
665 | } | ||
666 | /// <summary> | ||
667 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner | ||
668 | /// </summary> | ||
669 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> | ||
670 | public virtual List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
671 | { | ||
672 | List<FriendListItem> buddylist = new List<FriendListItem>(); | ||
673 | |||
674 | try | ||
675 | { | ||
676 | Hashtable param = new Hashtable(); | ||
677 | param["ownerID"] = friendlistowner.Guid.ToString(); | ||
678 | |||
679 | IList parameters = new ArrayList(); | ||
680 | parameters.Add(param); | ||
681 | XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters); | ||
682 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); | ||
683 | Hashtable respData = (Hashtable)resp.Value; | ||
684 | |||
685 | if (respData != null && respData.Contains("avcount")) | ||
686 | { | ||
687 | buddylist = ConvertXMLRPCDataToFriendListItemList(respData); | ||
688 | } | ||
689 | |||
690 | } | ||
691 | catch (WebException e) | ||
692 | { | ||
693 | m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar's friends list: " + | ||
694 | e.Message); | ||
695 | // Return Empty list (no friends) | ||
696 | } | ||
697 | return buddylist; | ||
698 | } | ||
699 | |||
700 | public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) | ||
701 | { | ||
702 | Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>(); | ||
703 | |||
704 | // ask MessageServer about the current on-/offline status and regions the friends are in | ||
705 | ArrayList parameters = new ArrayList(); | ||
706 | Hashtable map = new Hashtable(); | ||
707 | |||
708 | ArrayList list = new ArrayList(); | ||
709 | foreach (UUID uuid in uuids) | ||
710 | { | ||
711 | list.Add(uuid.ToString()); | ||
712 | list.Add(uuid.ToString()); | ||
713 | } | ||
714 | map["uuids"] = list; | ||
715 | |||
716 | map["recv_key"] = m_commsManager.NetworkServersInfo.UserRecvKey; | ||
717 | map["send_key"] = m_commsManager.NetworkServersInfo.UserSendKey; | ||
718 | |||
719 | parameters.Add(map); | ||
720 | |||
721 | try | ||
722 | { | ||
723 | XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters); | ||
724 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000); | ||
725 | Hashtable respData = resp != null ? (Hashtable)resp.Value : null; | ||
726 | |||
727 | if (respData == null || respData.ContainsKey("faultMessage")) | ||
728 | { | ||
729 | m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessagingServer about user-regions resulted in error: {0}", | ||
730 | respData == null ? "<unknown error>" : respData["faultMessage"]); | ||
731 | } | ||
732 | else if (!respData.ContainsKey("count")) | ||
733 | { | ||
734 | m_log.WarnFormat("[OGS1 USER SERVICES]: Wrong format in response for MessagingServer request get_presence_info_bulk: missing 'count' field"); | ||
735 | } | ||
736 | else | ||
737 | { | ||
738 | int count = (int)respData["count"]; | ||
739 | m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count); | ||
740 | for (int i = 0; i < count; ++i) | ||
741 | { | ||
742 | if (respData.ContainsKey("uuid_" + i) && respData.ContainsKey("isOnline_" + i) && respData.ContainsKey("regionHandle_" + i)) | ||
743 | { | ||
744 | UUID uuid; | ||
745 | if (UUID.TryParse((string)respData["uuid_" + i], out uuid)) | ||
746 | { | ||
747 | FriendRegionInfo info = new FriendRegionInfo(); | ||
748 | info.isOnline = (bool)respData["isOnline_" + i]; | ||
749 | if (info.isOnline) | ||
750 | { | ||
751 | // TODO remove this after the next protocol update (say, r7800?) | ||
752 | info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]); | ||
753 | |||
754 | // accept missing id | ||
755 | if (respData.ContainsKey("regionID_" + i)) | ||
756 | UUID.TryParse((string)respData["regionID_" + i], out info.regionID); | ||
757 | } | ||
758 | |||
759 | result.Add(uuid, info); | ||
760 | } | ||
761 | } | ||
762 | else | ||
763 | { | ||
764 | m_log.WarnFormat("[OGS1 USER SERVICES]: Response to get_presence_info_bulk contained an error in entry {0}", i); | ||
765 | } | ||
766 | } | ||
767 | } | ||
768 | } | ||
769 | catch (WebException e) | ||
770 | { | ||
771 | m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message); | ||
772 | } | ||
773 | |||
774 | m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count); | ||
775 | return result; | ||
776 | } | ||
777 | |||
778 | #endregion | ||
779 | |||
780 | /// Appearance | ||
781 | public virtual AvatarAppearance GetUserAppearance(UUID user) | ||
782 | { | ||
783 | AvatarAppearance appearance = null; | ||
784 | |||
785 | try | ||
786 | { | ||
787 | Hashtable param = new Hashtable(); | ||
788 | param["owner"] = user.ToString(); | ||
789 | |||
790 | IList parameters = new ArrayList(); | ||
791 | parameters.Add(param); | ||
792 | XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters); | ||
793 | XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); | ||
794 | Hashtable respData = (Hashtable)resp.Value; | ||
795 | |||
796 | return ConvertXMLRPCDataToAvatarAppearance(respData); | ||
797 | } | ||
798 | catch (WebException e) | ||
799 | { | ||
800 | m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch appearance for avatar {0}, {1}", user, e.Message); | ||
801 | } | ||
802 | |||
803 | return appearance; | ||
804 | } | ||
805 | |||
806 | public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | ||
807 | { | ||
808 | try | ||
809 | { | ||
810 | Hashtable param = appearance.ToHashTable(); | ||
811 | param["owner"] = user.ToString(); | ||
812 | |||
813 | IList parameters = new ArrayList(); | ||
814 | parameters.Add(param); | ||
815 | XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters); | ||
816 | XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); | ||
817 | Hashtable respData = (Hashtable)resp.Value; | ||
818 | |||
819 | if (respData != null) | ||
820 | { | ||
821 | if (respData.Contains("returnString")) | ||
822 | { | ||
823 | if ((string)respData["returnString"] == "TRUE") | ||
824 | { | ||
825 | |||
826 | } | ||
827 | else | ||
828 | { | ||
829 | m_log.Warn("[GRID]: Unable to update_user_appearance, User Server Reported an issue"); | ||
830 | } | ||
831 | } | ||
832 | else | ||
833 | { | ||
834 | m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!"); | ||
835 | } | ||
836 | } | ||
837 | else | ||
838 | { | ||
839 | m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!"); | ||
840 | } | ||
841 | } | ||
842 | catch (WebException e) | ||
843 | { | ||
844 | m_log.Warn("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance: " + | ||
845 | e.Message); | ||
846 | // Return Empty list (no friends) | ||
847 | } | ||
848 | } | ||
849 | |||
850 | public virtual bool VerifySession(UUID userID, UUID sessionID) | ||
851 | { | 143 | { |
852 | m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID); | 144 | m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID); |
853 | return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID); | 145 | return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID); |
854 | } | 146 | } |
855 | |||
856 | protected virtual string GetUserServerURL(UUID userID) | ||
857 | { | ||
858 | return m_commsManager.NetworkServersInfo.UserURL; | ||
859 | } | ||
860 | |||
861 | } | 147 | } |
862 | } | 148 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs index 73e8a09..58996e2 100644 --- a/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestUserDataPlugin.cs | |||
@@ -86,6 +86,8 @@ namespace OpenSim.Tests.Common.Mock | |||
86 | 86 | ||
87 | return userProfile; | 87 | return userProfile; |
88 | } | 88 | } |
89 | |||
90 | public UserProfileData GetUserByUri(Uri uri) { return null; } | ||
89 | 91 | ||
90 | public bool UpdateUserProfile(UserProfileData user) | 92 | public bool UpdateUserProfile(UserProfileData user) |
91 | { | 93 | { |