aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2009-02-22 11:01:26 +0000
committerMW2009-02-22 11:01:26 +0000
commit9b0b0b5e28065155b2662a9c275f2236f3db3a26 (patch)
tree29102e0bec1414fc36dc1be012ac5b13ac81c5ec /OpenSim
parent* And a little more (diff)
downloadopensim-SC-9b0b0b5e28065155b2662a9c275f2236f3db3a26.zip
opensim-SC-9b0b0b5e28065155b2662a9c275f2236f3db3a26.tar.gz
opensim-SC-9b0b0b5e28065155b2662a9c275f2236f3db3a26.tar.bz2
opensim-SC-9b0b0b5e28065155b2662a9c275f2236f3db3a26.tar.xz
Part 1 of refactoring the userserver. Changed it so instead of subclassing the User dataBase access class (UserManagerBase) and then adding the http handlers to that. There is now a UserDataBaseService that is passed to the other classes so they can access the db. This should make it easier to have multiple "modules" that can register http handlers and access the db.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs16
-rw-r--r--OpenSim/Grid/UserServer/UserDataBaseService.cs68
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs69
3 files changed, 107 insertions, 46 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 2199e93..1e6504d 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -52,6 +52,8 @@ namespace OpenSim.Grid.UserServer
52 52
53 protected UserConfig Cfg; 53 protected UserConfig Cfg;
54 54
55 protected UserDataBaseService m_userDataBaseService;
56
55 public UserManager m_userManager; 57 public UserManager m_userManager;
56 public UserLoginService m_loginService; 58 public UserLoginService m_loginService;
57 public GridInfoService m_gridInfoService; 59 public GridInfoService m_gridInfoService;
@@ -97,8 +99,10 @@ namespace OpenSim.Grid.UserServer
97 99
98 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); 100 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
99 101
102 m_userDataBaseService = new UserDataBaseService(inventoryService);
103 m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect);
104
100 StartupUserManager(inventoryService); 105 StartupUserManager(inventoryService);
101 m_userManager.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect);
102 106
103 m_gridInfoService = new GridInfoService(); 107 m_gridInfoService = new GridInfoService();
104 108
@@ -158,7 +162,7 @@ namespace OpenSim.Grid.UserServer
158 /// <param name="inventoryService"></param> 162 /// <param name="inventoryService"></param>
159 protected virtual void StartupUserManager(IInterServiceInventoryServices inventoryService) 163 protected virtual void StartupUserManager(IInterServiceInventoryServices inventoryService)
160 { 164 {
161 m_userManager = new UserManager(new OGS1InterServiceInventoryService(Cfg.InventoryUrl)); 165 m_userManager = new UserManager(inventoryService, m_userDataBaseService);
162 } 166 }
163 167
164 /// <summary> 168 /// <summary>
@@ -168,7 +172,7 @@ namespace OpenSim.Grid.UserServer
168 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) 172 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
169 { 173 {
170 m_loginService = new UserLoginService( 174 m_loginService = new UserLoginService(
171 m_userManager, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); 175 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
172 } 176 }
173 177
174 protected virtual void AddHttpHandlers() 178 protected virtual void AddHttpHandlers()
@@ -297,9 +301,9 @@ namespace OpenSim.Grid.UserServer
297 email = MainConsole.Instance.CmdPrompt("Email", ""); 301 email = MainConsole.Instance.CmdPrompt("Email", "");
298 else email = cmdparams[6]; 302 else email = cmdparams[6];
299 303
300 if (null == m_userManager.GetUserProfile(firstName, lastName)) 304 if (null == m_userDataBaseService.GetUserProfile(firstName, lastName))
301 { 305 {
302 m_lastCreatedUser = m_userManager.AddUser(firstName, lastName, password, email, regX, regY); 306 m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY);
303 } 307 }
304 else 308 else
305 { 309 {
@@ -329,7 +333,7 @@ namespace OpenSim.Grid.UserServer
329 newPassword = MainConsole.Instance.PasswdPrompt("New password"); 333 newPassword = MainConsole.Instance.PasswdPrompt("New password");
330 else newPassword = cmdparams[4]; 334 else newPassword = cmdparams[4];
331 335
332 m_userManager.ResetUserPassword(firstName, lastName, newPassword); 336 m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword);
333 } 337 }
334 338
335 private void HandleLoginCommand(string module, string[] cmd) 339 private void HandleLoginCommand(string module, string[] cmd)
diff --git a/OpenSim/Grid/UserServer/UserDataBaseService.cs b/OpenSim/Grid/UserServer/UserDataBaseService.cs
new file mode 100644
index 0000000..6c144d9
--- /dev/null
+++ b/OpenSim/Grid/UserServer/UserDataBaseService.cs
@@ -0,0 +1,68 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using Nwc.XmlRpc;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers;
38
39namespace OpenSim.Grid.UserServer
40{
41 public class UserDataBaseService : UserManagerBase
42 {
43 public UserDataBaseService()
44 : base(null)
45 {
46 }
47
48 public UserDataBaseService(IInterServiceInventoryServices interServiceInventoryService)
49 : base(interServiceInventoryService)
50 {
51 }
52
53 public override UserProfileData SetupMasterUser(string firstName, string lastName)
54 {
55 throw new Exception("The method or operation is not implemented.");
56 }
57
58 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
59 {
60 throw new Exception("The method or operation is not implemented.");
61 }
62
63 public override UserProfileData SetupMasterUser(UUID uuid)
64 {
65 throw new Exception("The method or operation is not implemented.");
66 }
67 }
68}
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 0a60eff..f3e9884 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -40,20 +40,23 @@ namespace OpenSim.Grid.UserServer
40{ 40{
41 public delegate void logOffUser(UUID AgentID); 41 public delegate void logOffUser(UUID AgentID);
42 42
43 public class UserManager : UserManagerBase 43 public class UserManager
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 public event logOffUser OnLogOffUser; 47 public event logOffUser OnLogOffUser;
48 private logOffUser handlerLogOffUser; 48 private logOffUser handlerLogOffUser;
49
50 private UserDataBaseService m_userDataBaseService;
49 51
50 /// <summary> 52 /// <summary>
51 /// Constructor 53 /// Constructor
52 /// </summary> 54 /// </summary>
53 /// <param name="interServiceInventoryService"></param> 55 /// <param name="interServiceInventoryService"></param>
54 public UserManager(IInterServiceInventoryServices interServiceInventoryService) 56 public UserManager(IInterServiceInventoryServices interServiceInventoryService, UserDataBaseService userDataBaseService)
55 : base(interServiceInventoryService) 57 {
56 {} 58 m_userDataBaseService = userDataBaseService;
59 }
57 60
58 /// <summary> 61 /// <summary>
59 /// Deletes an active agent session 62 /// Deletes an active agent session
@@ -185,7 +188,7 @@ namespace OpenSim.Grid.UserServer
185 if (requestData.Contains("avquery") && requestData.Contains("queryid")) 188 if (requestData.Contains("avquery") && requestData.Contains("queryid"))
186 { 189 {
187 queryID = new UUID((string) requestData["queryid"]); 190 queryID = new UUID((string) requestData["queryid"]);
188 returnAvatar = GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]); 191 returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]);
189 } 192 }
190 193
191 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]); 194 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]);
@@ -211,11 +214,11 @@ namespace OpenSim.Grid.UserServer
211 214
212 if (avatarUUID != UUID.Zero) 215 if (avatarUUID != UUID.Zero)
213 { 216 {
214 UserProfileData userProfile = GetUserProfile(avatarUUID); 217 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID);
215 userProfile.CurrentAgent.Region = regionUUID; 218 userProfile.CurrentAgent.Region = regionUUID;
216 userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]); 219 userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]);
217 //userProfile.CurrentAgent. 220 //userProfile.CurrentAgent.
218 CommitAgent(ref userProfile); 221 m_userDataBaseService.CommitAgent(ref userProfile);
219 //setUserProfile(userProfile); 222 //setUserProfile(userProfile);
220 223
221 224
@@ -239,7 +242,7 @@ namespace OpenSim.Grid.UserServer
239 requestData.Contains("friendPerms")) 242 requestData.Contains("friendPerms"))
240 { 243 {
241 // UserManagerBase.AddNewuserFriend 244 // UserManagerBase.AddNewuserFriend
242 AddNewUserFriend(new UUID((string) requestData["ownerID"]), 245 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]),
243 new UUID((string) requestData["friendID"]), 246 new UUID((string) requestData["friendID"]),
244 (uint) Convert.ToInt32((string) requestData["friendPerms"])); 247 (uint) Convert.ToInt32((string) requestData["friendPerms"]));
245 returnString = "TRUE"; 248 returnString = "TRUE";
@@ -260,7 +263,7 @@ namespace OpenSim.Grid.UserServer
260 if (requestData.Contains("ownerID") && requestData.Contains("friendID")) 263 if (requestData.Contains("ownerID") && requestData.Contains("friendID"))
261 { 264 {
262 // UserManagerBase.AddNewuserFriend 265 // UserManagerBase.AddNewuserFriend
263 RemoveUserFriend(new UUID((string) requestData["ownerID"]), 266 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]),
264 new UUID((string) requestData["friendID"])); 267 new UUID((string) requestData["friendID"]));
265 returnString = "TRUE"; 268 returnString = "TRUE";
266 } 269 }
@@ -279,7 +282,7 @@ namespace OpenSim.Grid.UserServer
279 if (requestData.Contains("ownerID") && requestData.Contains("friendID") && 282 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
280 requestData.Contains("friendPerms")) 283 requestData.Contains("friendPerms"))
281 { 284 {
282 UpdateUserFriendPerms(new UUID((string) requestData["ownerID"]), 285 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]),
283 new UUID((string) requestData["friendID"]), 286 new UUID((string) requestData["friendID"]),
284 (uint) Convert.ToInt32((string) requestData["friendPerms"])); 287 (uint) Convert.ToInt32((string) requestData["friendPerms"]));
285 // UserManagerBase. 288 // UserManagerBase.
@@ -300,7 +303,7 @@ namespace OpenSim.Grid.UserServer
300 303
301 if (requestData.Contains("ownerID")) 304 if (requestData.Contains("ownerID"))
302 { 305 {
303 returndata = GetUserFriendList(new UUID((string) requestData["ownerID"])); 306 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"]));
304 } 307 }
305 308
306 return FriendListItemListtoXmlRPCResponse(returndata); 309 return FriendListItemListtoXmlRPCResponse(returndata);
@@ -314,7 +317,7 @@ namespace OpenSim.Grid.UserServer
314 Hashtable responseData; 317 Hashtable responseData;
315 if (requestData.Contains("owner")) 318 if (requestData.Contains("owner"))
316 { 319 {
317 appearance = GetUserAppearance(new UUID((string) requestData["owner"])); 320 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
318 if (appearance == null) 321 if (appearance == null)
319 { 322 {
320 responseData = new Hashtable(); 323 responseData = new Hashtable();
@@ -345,7 +348,7 @@ namespace OpenSim.Grid.UserServer
345 if (requestData.Contains("owner")) 348 if (requestData.Contains("owner"))
346 { 349 {
347 AvatarAppearance appearance = new AvatarAppearance(requestData); 350 AvatarAppearance appearance = new AvatarAppearance(requestData);
348 UpdateUserAppearance(new UUID((string) requestData["owner"]), appearance); 351 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
349 responseData = new Hashtable(); 352 responseData = new Hashtable();
350 responseData["returnString"] = "TRUE"; 353 responseData["returnString"] = "TRUE";
351 } 354 }
@@ -374,7 +377,7 @@ namespace OpenSim.Grid.UserServer
374 377
375 if (querysplit.Length == 2) 378 if (querysplit.Length == 2)
376 { 379 {
377 userProfile = GetUserProfile(querysplit[0], querysplit[1]); 380 userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]);
378 if (userProfile == null) 381 if (userProfile == null)
379 { 382 {
380 return CreateUnknownUserErrorResponse(); 383 return CreateUnknownUserErrorResponse();
@@ -406,7 +409,7 @@ namespace OpenSim.Grid.UserServer
406 { 409 {
407 UUID guess = new UUID((string) requestData["avatar_uuid"]); 410 UUID guess = new UUID((string) requestData["avatar_uuid"]);
408 411
409 userProfile = GetUserProfile(guess); 412 userProfile = m_userDataBaseService.GetUserProfile(guess);
410 } 413 }
411 catch (FormatException) 414 catch (FormatException)
412 { 415 {
@@ -444,7 +447,7 @@ namespace OpenSim.Grid.UserServer
444 return CreateUnknownUserErrorResponse(); 447 return CreateUnknownUserErrorResponse();
445 } 448 }
446 449
447 userProfile = GetUserProfile(guess); 450 userProfile = m_userDataBaseService.GetUserProfile(guess);
448 451
449 if (userProfile == null) 452 if (userProfile == null)
450 { 453 {
@@ -497,7 +500,7 @@ namespace OpenSim.Grid.UserServer
497 { 500 {
498 return CreateUnknownUserErrorResponse(); 501 return CreateUnknownUserErrorResponse();
499 } 502 }
500 userProfile = GetUserProfile(guess_aid); 503 userProfile = m_userDataBaseService.GetUserProfile(guess_aid);
501 if (userProfile != null && userProfile.CurrentAgent != null && 504 if (userProfile != null && userProfile.CurrentAgent != null &&
502 userProfile.CurrentAgent.SessionID == guess_sid) 505 userProfile.CurrentAgent.SessionID == guess_sid)
503 { 506 {
@@ -529,7 +532,7 @@ namespace OpenSim.Grid.UserServer
529 } 532 }
530 533
531 UUID UserUUID = new UUID((string) requestData["avatar_uuid"]); 534 UUID UserUUID = new UUID((string) requestData["avatar_uuid"]);
532 UserProfileData userProfile = GetUserProfile(UserUUID); 535 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID);
533 if (null == userProfile) 536 if (null == userProfile)
534 { 537 {
535 return CreateUnknownUserErrorResponse(); 538 return CreateUnknownUserErrorResponse();
@@ -703,7 +706,7 @@ namespace OpenSim.Grid.UserServer
703 } 706 }
704 707
705 // call plugin! 708 // call plugin!
706 bool ret = UpdateUserProfile(userProfile); 709 bool ret = m_userDataBaseService.UpdateUserProfile(userProfile);
707 responseData["returnString"] = ret.ToString(); 710 responseData["returnString"] = ret.ToString();
708 response.Value = responseData; 711 response.Value = responseData;
709 return response; 712 return response;
@@ -734,7 +737,7 @@ namespace OpenSim.Grid.UserServer
734 if (handlerLogOffUser != null) 737 if (handlerLogOffUser != null)
735 handlerLogOffUser(userUUID); 738 handlerLogOffUser(userUUID);
736 739
737 LogOffUser(userUUID, RegionID, regionhandle, position, lookat); 740 m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat);
738 } 741 }
739 catch (FormatException) 742 catch (FormatException)
740 { 743 {
@@ -752,35 +755,21 @@ namespace OpenSim.Grid.UserServer
752 755
753 #endregion 756 #endregion
754 757
755 public override UserProfileData SetupMasterUser(string firstName, string lastName)
756 {
757 throw new Exception("The method or operation is not implemented.");
758 }
759
760 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
761 {
762 throw new Exception("The method or operation is not implemented.");
763 }
764
765 public override UserProfileData SetupMasterUser(UUID uuid)
766 {
767 throw new Exception("The method or operation is not implemented.");
768 }
769 758
770 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) 759 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
771 { 760 {
772 UserProfileData userProfile = GetUserProfile(agentID); 761 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
773 if (userProfile != null) 762 if (userProfile != null)
774 { 763 {
775 userProfile.CurrentAgent.Region = regionID; 764 userProfile.CurrentAgent.Region = regionID;
776 userProfile.CurrentAgent.Handle = regionHandle; 765 userProfile.CurrentAgent.Handle = regionHandle;
777 CommitAgent(ref userProfile); 766 m_userDataBaseService.CommitAgent(ref userProfile);
778 } 767 }
779 } 768 }
780 769
781 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) 770 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
782 { 771 {
783 UserProfileData userProfile = GetUserProfile(agentID); 772 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
784 if (userProfile != null) 773 if (userProfile != null)
785 { 774 {
786 if (userProfile.CurrentAgent.Region == regionID) 775 if (userProfile.CurrentAgent.Region == regionID)
@@ -797,7 +786,7 @@ namespace OpenSim.Grid.UserServer
797 userAgent.Handle = regionHandle; 786 userAgent.Handle = regionHandle;
798 userProfile.LastLogin = userAgent.LogoutTime; 787 userProfile.LastLogin = userAgent.LogoutTime;
799 788
800 CommitAgent(ref userProfile); 789 m_userDataBaseService.CommitAgent(ref userProfile);
801 790
802 handlerLogOffUser = OnLogOffUser; 791 handlerLogOffUser = OnLogOffUser;
803 if (handlerLogOffUser != null) 792 if (handlerLogOffUser != null)
@@ -809,12 +798,12 @@ namespace OpenSim.Grid.UserServer
809 798
810 public void HandleRegionStartup(UUID regionID) 799 public void HandleRegionStartup(UUID regionID)
811 { 800 {
812 LogoutUsers(regionID); 801 m_userDataBaseService.LogoutUsers(regionID);
813 } 802 }
814 803
815 public void HandleRegionShutdown(UUID regionID) 804 public void HandleRegionShutdown(UUID regionID)
816 { 805 {
817 LogoutUsers(regionID); 806 m_userDataBaseService.LogoutUsers(regionID);
818 } 807 }
819 } 808 }
820} 809}