More refactoring of the UserServer.
							parent
							
								
									756d49d3db
								
							
						
					
					
						commit
						2a91f21d08
					
				|  | @ -0,0 +1,43 @@ | ||||||
|  | /* | ||||||
|  |  * Copyright (c) Contributors, http://opensimulator.org/ | ||||||
|  |  * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||||||
|  |  * | ||||||
|  |  * Redistribution and use in source and binary forms, with or without | ||||||
|  |  * modification, are permitted provided that the following conditions are met: | ||||||
|  |  *     * Redistributions of source code must retain the above copyright | ||||||
|  |  *       notice, this list of conditions and the following disclaimer. | ||||||
|  |  *     * Redistributions in binary form must reproduce the above copyright | ||||||
|  |  *       notice, this list of conditions and the following disclaimer in the | ||||||
|  |  *       documentation and/or other materials provided with the distribution. | ||||||
|  |  *     * Neither the name of the OpenSimulator Project nor the | ||||||
|  |  *       names of its contributors may be used to endorse or promote products | ||||||
|  |  *       derived from this software without specific prior written permission. | ||||||
|  |  * | ||||||
|  |  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||||||
|  |  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||||
|  |  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
|  |  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||||||
|  |  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||||||
|  |  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||||||
|  |  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||||||
|  |  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||||
|  |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||||||
|  |  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Text; | ||||||
|  | using OpenSim.Framework.Servers; | ||||||
|  | 
 | ||||||
|  | namespace OpenSim.Grid.UserServer | ||||||
|  | { | ||||||
|  |     public interface IUGAIMCore | ||||||
|  |     { | ||||||
|  |         T Get<T>(); | ||||||
|  |         void RegisterInterface<T>(T iface); | ||||||
|  |         bool TryGet<T>(out T iface); | ||||||
|  |         BaseHttpServer GetHttpServer(); | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -46,7 +46,7 @@ namespace OpenSim.Grid.UserServer | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Grid user server main class |     /// Grid user server main class | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     public class OpenUser_Main : BaseOpenSimServer |     public class OpenUser_Main : BaseOpenSimServer, IUGAIMCore | ||||||
|     { |     { | ||||||
|         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||||||
| 
 | 
 | ||||||
|  | @ -55,6 +55,10 @@ namespace OpenSim.Grid.UserServer | ||||||
|         protected UserDataBaseService m_userDataBaseService; |         protected UserDataBaseService m_userDataBaseService; | ||||||
| 
 | 
 | ||||||
|         public UserManager m_userManager; |         public UserManager m_userManager; | ||||||
|  | 
 | ||||||
|  |         protected UserServerAvatarAppearanceModule m_avatarAppearanceModule; | ||||||
|  |         protected UserServerFriendsModule m_friendsModule; | ||||||
|  | 
 | ||||||
|         public UserLoginService m_loginService; |         public UserLoginService m_loginService; | ||||||
|         public GridInfoService m_gridInfoService; |         public GridInfoService m_gridInfoService; | ||||||
|         public MessageServersConnector m_messagesService; |         public MessageServersConnector m_messagesService; | ||||||
|  | @ -99,17 +103,64 @@ namespace OpenSim.Grid.UserServer | ||||||
|              |              | ||||||
|             IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); |             IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); | ||||||
| 
 | 
 | ||||||
|  |             //setup database access service | ||||||
|             m_userDataBaseService = new UserDataBaseService(inventoryService); |             m_userDataBaseService = new UserDataBaseService(inventoryService); | ||||||
|             m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); |             m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); | ||||||
| 
 | 
 | ||||||
|             StartupUserManager(inventoryService); |             //Register the database access service so modules can fetch it | ||||||
|  |             // RegisterInterface<UserDataBaseService>(m_userDataBaseService); | ||||||
|  | 
 | ||||||
|  |             //setup services/modules | ||||||
|  |             StartupUserServerModules(); | ||||||
| 
 | 
 | ||||||
|             m_gridInfoService = new GridInfoService(); |             m_gridInfoService = new GridInfoService(); | ||||||
| 
 | 
 | ||||||
|             StartupLoginService(inventoryService); |             StartupLoginService(inventoryService); | ||||||
|  |             // | ||||||
|  |             // Get the minimum defaultLevel to access to the grid | ||||||
|  |             // | ||||||
|  |             m_loginService.setloginlevel((int)Cfg.DefaultUserLevel); | ||||||
| 
 | 
 | ||||||
|             m_messagesService = new MessageServersConnector(); |             m_messagesService = new MessageServersConnector(); | ||||||
| 
 | 
 | ||||||
|  |             //register event handlers | ||||||
|  |             RegisterEventHandlers(); | ||||||
|  | 
 | ||||||
|  |             //register http handlers and start http server | ||||||
|  |             m_log.Info("[STARTUP]: Starting HTTP process"); | ||||||
|  |             m_httpServer = new BaseHttpServer(Cfg.HttpPort); | ||||||
|  |             RegisterHttpHandlers(); | ||||||
|  |             m_httpServer.Start(); | ||||||
|  |              | ||||||
|  |             base.StartupSpecific(); | ||||||
|  | 
 | ||||||
|  |             //register Console command handlers | ||||||
|  |             RegisterConsoleCommands(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// Start up the user manager | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="inventoryService"></param> | ||||||
|  |         protected virtual void StartupUserServerModules() | ||||||
|  |         { | ||||||
|  |             m_userManager = new UserManager(m_userDataBaseService); | ||||||
|  |             m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService); | ||||||
|  |             m_friendsModule = new UserServerFriendsModule(m_userDataBaseService); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// Start up the login service | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="inventoryService"></param> | ||||||
|  |         protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) | ||||||
|  |         { | ||||||
|  |             m_loginService = new UserLoginService( | ||||||
|  |                 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         protected virtual void RegisterEventHandlers() | ||||||
|  |         { | ||||||
|             m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; |             m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; | ||||||
|             m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; |             m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; | ||||||
| 
 | 
 | ||||||
|  | @ -117,15 +168,10 @@ namespace OpenSim.Grid.UserServer | ||||||
|             m_messagesService.OnAgentLeaving += HandleAgentLeaving; |             m_messagesService.OnAgentLeaving += HandleAgentLeaving; | ||||||
|             m_messagesService.OnRegionStartup += HandleRegionStartup; |             m_messagesService.OnRegionStartup += HandleRegionStartup; | ||||||
|             m_messagesService.OnRegionShutdown += HandleRegionShutdown; |             m_messagesService.OnRegionShutdown += HandleRegionShutdown; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|             m_log.Info("[STARTUP]: Starting HTTP process"); |         protected virtual void RegisterConsoleCommands() | ||||||
| 
 |         { | ||||||
|             m_httpServer = new BaseHttpServer(Cfg.HttpPort); |  | ||||||
|             AddHttpHandlers(); |  | ||||||
|             m_httpServer.Start(); |  | ||||||
|              |  | ||||||
|             base.StartupSpecific(); |  | ||||||
| 
 |  | ||||||
|             m_console.Commands.AddCommand("userserver", false, "create user", |             m_console.Commands.AddCommand("userserver", false, "create user", | ||||||
|                     "create user [<first> [<last> [<x> <y> [email]]]]", |                     "create user [<first> [<last> [<x> <y> [email]]]]", | ||||||
|                     "Create a new user account", RunCommand); |                     "Create a new user account", RunCommand); | ||||||
|  | @ -156,80 +202,67 @@ namespace OpenSim.Grid.UserServer | ||||||
|                     "Log off a named user", RunCommand); |                     "Log off a named user", RunCommand); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         protected virtual void RegisterHttpHandlers() | ||||||
|         /// Start up the user manager |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="inventoryService"></param> |  | ||||||
|         protected virtual void StartupUserManager(IInterServiceInventoryServices inventoryService) |  | ||||||
|         { |         { | ||||||
|             m_userManager = new UserManager(inventoryService, m_userDataBaseService); |             m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); | ||||||
|         } |  | ||||||
|             |             | ||||||
|         /// <summary> |             m_userManager.RegisterHandlers(m_httpServer); | ||||||
|         /// Start up the login service |             m_friendsModule.RegisterHandlers(m_httpServer); | ||||||
|         /// </summary> |             m_avatarAppearanceModule.RegisterHandlers(m_httpServer); | ||||||
|         /// <param name="inventoryService"></param> |             m_messagesService.RegisterHandlers(m_httpServer); | ||||||
|         protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) |  | ||||||
|         { |  | ||||||
|             m_loginService = new UserLoginService( |  | ||||||
|                 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         protected virtual void AddHttpHandlers() |  | ||||||
|         { |  | ||||||
|             m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); |  | ||||||
| 
 |  | ||||||
|             m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); |  | ||||||
|             // |  | ||||||
|             // Get the minimum defaultLevel to access to the grid |  | ||||||
|             // |  | ||||||
|             m_loginService.setloginlevel((int)Cfg.DefaultUserLevel); |  | ||||||
| 
 |  | ||||||
|             if (Cfg.EnableLLSDLogin) |  | ||||||
|             { |  | ||||||
|                 m_httpServer.SetDefaultLLSDHandler(m_loginService.LLSDLoginMethod); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("update_user_friend_perms", |  | ||||||
|                                           m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("get_avatar_appearance", m_userManager.XmlRPCGetAvatarAppearance); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("update_avatar_appearance", m_userManager.XmlRPCUpdateAvatarAppearance); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("update_user_current_region", m_userManager.XmlRPCAtRegion); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", m_userManager.XmlRPCGetAgentMethodUUID); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("check_auth_session", m_userManager.XmlRPCCheckAuthSession); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("set_login_params", m_loginService.XmlRPCSetLoginParams); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("region_startup", m_messagesService.RegionStartup); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("region_shutdown", m_messagesService.RegionShutdown); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("agent_location", m_messagesService.AgentLocation); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("agent_leaving", m_messagesService.AgentLeaving); |  | ||||||
|             // Message Server ---> User Server |  | ||||||
|             m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion); |  | ||||||
|             m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer); |  | ||||||
| 
 | 
 | ||||||
|             m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", |             m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", | ||||||
|                                                                 m_gridInfoService.RestGetGridInfoMethod)); |                                                                 m_gridInfoService.RestGetGridInfoMethod)); | ||||||
|             m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod); |             m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod); | ||||||
| 
 |  | ||||||
|             m_httpServer.AddStreamHandler( |  | ||||||
|                 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); |  | ||||||
| 
 |  | ||||||
|             m_httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile); |  | ||||||
| 
 |  | ||||||
|             // Handler for OpenID avatar identity pages |  | ||||||
|             m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", m_loginService)); |  | ||||||
|             // Handlers for the OpenID endpoint server |  | ||||||
|             m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", m_loginService)); |  | ||||||
|             m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", m_loginService)); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public override void ShutdownSpecific() | ||||||
|  |         { | ||||||
|  |             m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         #region IUGAIMCore | ||||||
|  |         private readonly Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>(); | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// Register an Module interface. | ||||||
|  |         /// </summary> | ||||||
|  |         /// <typeparam name="T"></typeparam> | ||||||
|  |         /// <param name="iface"></param> | ||||||
|  |         public void RegisterInterface<T>(T iface) | ||||||
|  |         { | ||||||
|  |             lock (m_moduleInterfaces) | ||||||
|  |             { | ||||||
|  |                 if (!m_moduleInterfaces.ContainsKey(typeof(T))) | ||||||
|  |                 { | ||||||
|  |                     m_moduleInterfaces.Add(typeof(T), iface); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public bool TryGet<T>(out T iface) | ||||||
|  |         { | ||||||
|  |             if (m_moduleInterfaces.ContainsKey(typeof(T))) | ||||||
|  |             { | ||||||
|  |                 iface = (T)m_moduleInterfaces[typeof(T)]; | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |             iface = default(T); | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public T Get<T>() | ||||||
|  |         { | ||||||
|  |             return (T)m_moduleInterfaces[typeof(T)]; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public BaseHttpServer GetHttpServer() | ||||||
|  |         { | ||||||
|  |             return m_httpServer; | ||||||
|  |         } | ||||||
|  |         #endregion | ||||||
|  | 
 | ||||||
|  |         #region Console Command Handlers | ||||||
|         public void do_create(string[] args) |         public void do_create(string[] args) | ||||||
|         { |         { | ||||||
|             switch (args[0]) |             switch (args[0]) | ||||||
|  | @ -470,17 +503,14 @@ namespace OpenSim.Grid.UserServer | ||||||
|             m_console.Notice("login-text <text to print during the login>"); |             m_console.Notice("login-text <text to print during the login>"); | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
| 
 |         #endregion | ||||||
|         public override void ShutdownSpecific() |  | ||||||
|         { |  | ||||||
|             m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         public void TestResponse(List<InventoryFolderBase> resp) |         public void TestResponse(List<InventoryFolderBase> resp) | ||||||
|         { |         { | ||||||
|             m_console.Notice("response got"); |             m_console.Notice("response got"); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         #region Event Handlers | ||||||
|         public void NotifyMessageServersUserLoggOff(UUID agentID) |         public void NotifyMessageServersUserLoggOff(UUID agentID) | ||||||
|         { |         { | ||||||
|             m_messagesService.TellMessageServersAboutUserLogoff(agentID); |             m_messagesService.TellMessageServersAboutUserLogoff(agentID); | ||||||
|  | @ -531,5 +561,6 @@ namespace OpenSim.Grid.UserServer | ||||||
|             m_userManager.HandleRegionShutdown(regionID); |             m_userManager.HandleRegionShutdown(regionID); | ||||||
|             m_messagesService.TellMessageServersAboutRegionShutdown(regionID); |             m_messagesService.TellMessageServersAboutRegionShutdown(regionID); | ||||||
|         } |         } | ||||||
|  |         #endregion | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -71,6 +71,8 @@ namespace OpenSim.Grid.UserServer | ||||||
| 
 | 
 | ||||||
|         public Dictionary<string, MessageServerInfo> MessageServers; |         public Dictionary<string, MessageServerInfo> MessageServers; | ||||||
| 
 | 
 | ||||||
|  |         private BaseHttpServer m_httpServer; | ||||||
|  | 
 | ||||||
|         private BlockingQueue<PresenceNotification> m_NotifyQueue = |         private BlockingQueue<PresenceNotification> m_NotifyQueue = | ||||||
|                 new BlockingQueue<PresenceNotification>(); |                 new BlockingQueue<PresenceNotification>(); | ||||||
| 
 | 
 | ||||||
|  | @ -88,6 +90,30 @@ namespace OpenSim.Grid.UserServer | ||||||
|             m_NotifyThread.Start(); |             m_NotifyThread.Start(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public void Initialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void PostInitialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void RegisterHandlers(BaseHttpServer httpServer) | ||||||
|  |         { | ||||||
|  |             m_httpServer = httpServer; | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving); | ||||||
|  |             // Message Server ---> User Server | ||||||
|  |             m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         public void RegisterMessageServer(string URI, MessageServerInfo serverData) |         public void RegisterMessageServer(string URI, MessageServerInfo serverData) | ||||||
|         { |         { | ||||||
|             lock (MessageServers) |             lock (MessageServers) | ||||||
|  |  | ||||||
|  | @ -38,6 +38,7 @@ using OpenSim.Framework; | ||||||
| using OpenSim.Framework.Communications; | using OpenSim.Framework.Communications; | ||||||
| using OpenSim.Framework.Communications.Cache; | using OpenSim.Framework.Communications.Cache; | ||||||
| using OpenSim.Framework.Communications.Capabilities; | using OpenSim.Framework.Communications.Capabilities; | ||||||
|  | using OpenSim.Framework.Servers; | ||||||
| 
 | 
 | ||||||
| namespace OpenSim.Grid.UserServer | namespace OpenSim.Grid.UserServer | ||||||
| { | { | ||||||
|  | @ -61,6 +62,8 @@ namespace OpenSim.Grid.UserServer | ||||||
|         public UserConfig m_config; |         public UserConfig m_config; | ||||||
|         private readonly IRegionProfileService m_regionProfileService; |         private readonly IRegionProfileService m_regionProfileService; | ||||||
| 
 | 
 | ||||||
|  |         protected BaseHttpServer m_httpServer; | ||||||
|  | 
 | ||||||
|         public UserLoginService( |         public UserLoginService( | ||||||
|             UserManagerBase userManager, IInterServiceInventoryServices inventoryService, |             UserManagerBase userManager, IInterServiceInventoryServices inventoryService, | ||||||
|             LibraryRootFolder libraryRootFolder, |             LibraryRootFolder libraryRootFolder, | ||||||
|  | @ -72,6 +75,29 @@ namespace OpenSim.Grid.UserServer | ||||||
|             m_regionProfileService = regionProfileService; |             m_regionProfileService = regionProfileService; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) | ||||||
|  |         { | ||||||
|  |             m_httpServer = httpServer; | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod); | ||||||
|  |             m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams); | ||||||
|  | 
 | ||||||
|  |             if (registerLLSDHandler) | ||||||
|  |             { | ||||||
|  |                 m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if (registerOpenIDHandlers) | ||||||
|  |             { | ||||||
|  |                 // Handler for OpenID avatar identity pages | ||||||
|  |                 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", this)); | ||||||
|  |                 // Handlers for the OpenID endpoint server | ||||||
|  |                 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", this)); | ||||||
|  |                 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|         public  void  setloginlevel(int level) |         public  void  setloginlevel(int level) | ||||||
|         { |         { | ||||||
|               m_minLoginLevel = level; |               m_minLoginLevel = level; | ||||||
|  |  | ||||||
|  | @ -48,16 +48,45 @@ namespace OpenSim.Grid.UserServer | ||||||
|         private logOffUser handlerLogOffUser; |         private logOffUser handlerLogOffUser; | ||||||
| 
 | 
 | ||||||
|         private UserDataBaseService m_userDataBaseService; |         private UserDataBaseService m_userDataBaseService; | ||||||
|  |         private BaseHttpServer m_httpServer; | ||||||
|          |          | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Constructor |         ///  | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="interServiceInventoryService"></param> |         /// <param name="userDataBaseService"></param> | ||||||
|         public UserManager(IInterServiceInventoryServices interServiceInventoryService, UserDataBaseService userDataBaseService) |         public UserManager( UserDataBaseService userDataBaseService) | ||||||
|         { |         { | ||||||
|             m_userDataBaseService = userDataBaseService; |             m_userDataBaseService = userDataBaseService; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public void Initialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void PostInitialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void RegisterHandlers(BaseHttpServer httpServer) | ||||||
|  |         { | ||||||
|  |             m_httpServer = httpServer; | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession); | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile); | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod)); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Deletes an active agent session |         /// Deletes an active agent session | ||||||
|         /// </summary> |         /// </summary> | ||||||
|  | @ -109,26 +138,6 @@ namespace OpenSim.Grid.UserServer | ||||||
|             return response; |             return response; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers) |  | ||||||
|         { |  | ||||||
|             XmlRpcResponse response = new XmlRpcResponse(); |  | ||||||
|             Hashtable responseData = new Hashtable(); |  | ||||||
|             // Query Result Information |  | ||||||
| 
 |  | ||||||
|             responseData["avcount"] = returnUsers.Count.ToString(); |  | ||||||
| 
 |  | ||||||
|             for (int i = 0; i < returnUsers.Count; i++) |  | ||||||
|             { |  | ||||||
|                 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString(); |  | ||||||
|                 responseData["friendID" + i] = returnUsers[i].Friend.ToString(); |  | ||||||
|                 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString(); |  | ||||||
|                 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString(); |  | ||||||
|             } |  | ||||||
|             response.Value = responseData; |  | ||||||
| 
 |  | ||||||
|             return response; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Converts a user profile to an XML element which can be returned |         /// Converts a user profile to an XML element which can be returned | ||||||
|         /// </summary> |         /// </summary> | ||||||
|  | @ -230,138 +239,6 @@ namespace OpenSim.Grid.UserServer | ||||||
|             return response; |             return response; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) |  | ||||||
|         { |  | ||||||
|             XmlRpcResponse response = new XmlRpcResponse(); |  | ||||||
|             Hashtable requestData = (Hashtable) request.Params[0]; |  | ||||||
|             Hashtable responseData = new Hashtable(); |  | ||||||
|             string returnString = "FALSE"; |  | ||||||
|             // Query Result Information |  | ||||||
| 
 |  | ||||||
|             if (requestData.Contains("ownerID") && requestData.Contains("friendID") && |  | ||||||
|                 requestData.Contains("friendPerms")) |  | ||||||
|             { |  | ||||||
|                 // UserManagerBase.AddNewuserFriend |  | ||||||
|                 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]), |  | ||||||
|                                  new UUID((string) requestData["friendID"]), |  | ||||||
|                                  (uint) Convert.ToInt32((string) requestData["friendPerms"])); |  | ||||||
|                 returnString = "TRUE"; |  | ||||||
|             } |  | ||||||
|             responseData["returnString"] = returnString; |  | ||||||
|             response.Value = responseData; |  | ||||||
|             return response; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request) |  | ||||||
|         { |  | ||||||
|             XmlRpcResponse response = new XmlRpcResponse(); |  | ||||||
|             Hashtable requestData = (Hashtable) request.Params[0]; |  | ||||||
|             Hashtable responseData = new Hashtable(); |  | ||||||
|             string returnString = "FALSE"; |  | ||||||
|             // Query Result Information |  | ||||||
| 
 |  | ||||||
|             if (requestData.Contains("ownerID") && requestData.Contains("friendID")) |  | ||||||
|             { |  | ||||||
|                 // UserManagerBase.AddNewuserFriend |  | ||||||
|                 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]), |  | ||||||
|                                  new UUID((string) requestData["friendID"])); |  | ||||||
|                 returnString = "TRUE"; |  | ||||||
|             } |  | ||||||
|             responseData["returnString"] = returnString; |  | ||||||
|             response.Value = responseData; |  | ||||||
|             return response; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) |  | ||||||
|         { |  | ||||||
|             XmlRpcResponse response = new XmlRpcResponse(); |  | ||||||
|             Hashtable requestData = (Hashtable) request.Params[0]; |  | ||||||
|             Hashtable responseData = new Hashtable(); |  | ||||||
|             string returnString = "FALSE"; |  | ||||||
| 
 |  | ||||||
|             if (requestData.Contains("ownerID") && requestData.Contains("friendID") && |  | ||||||
|                 requestData.Contains("friendPerms")) |  | ||||||
|             { |  | ||||||
|                 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]), |  | ||||||
|                                       new UUID((string) requestData["friendID"]), |  | ||||||
|                                       (uint) Convert.ToInt32((string) requestData["friendPerms"])); |  | ||||||
|                 // UserManagerBase. |  | ||||||
|                 returnString = "TRUE"; |  | ||||||
|             } |  | ||||||
|             responseData["returnString"] = returnString; |  | ||||||
|             response.Value = responseData; |  | ||||||
|             return response; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request) |  | ||||||
|         { |  | ||||||
|             // XmlRpcResponse response = new XmlRpcResponse(); |  | ||||||
|             Hashtable requestData = (Hashtable) request.Params[0]; |  | ||||||
|             // Hashtable responseData = new Hashtable(); |  | ||||||
| 
 |  | ||||||
|             List<FriendListItem> returndata = new List<FriendListItem>(); |  | ||||||
| 
 |  | ||||||
|             if (requestData.Contains("ownerID")) |  | ||||||
|             { |  | ||||||
|                 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"])); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             return FriendListItemListtoXmlRPCResponse(returndata); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request) |  | ||||||
|         { |  | ||||||
|             XmlRpcResponse response = new XmlRpcResponse(); |  | ||||||
|             Hashtable requestData = (Hashtable) request.Params[0]; |  | ||||||
|             AvatarAppearance appearance; |  | ||||||
|             Hashtable responseData; |  | ||||||
|             if (requestData.Contains("owner")) |  | ||||||
|             { |  | ||||||
|                 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"])); |  | ||||||
|                 if (appearance == null) |  | ||||||
|                 { |  | ||||||
|                     responseData = new Hashtable(); |  | ||||||
|                     responseData["error_type"] = "no appearance"; |  | ||||||
|                     responseData["error_desc"] = "There was no appearance found for this avatar"; |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     responseData = appearance.ToHashTable(); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 responseData = new Hashtable(); |  | ||||||
|                 responseData["error_type"] = "unknown_avatar"; |  | ||||||
|                 responseData["error_desc"] = "The avatar appearance requested is not in the database"; |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             response.Value = responseData; |  | ||||||
|             return response; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request) |  | ||||||
|         { |  | ||||||
|             XmlRpcResponse response = new XmlRpcResponse(); |  | ||||||
|             Hashtable requestData = (Hashtable) request.Params[0]; |  | ||||||
|             Hashtable responseData; |  | ||||||
|             if (requestData.Contains("owner")) |  | ||||||
|             { |  | ||||||
|                 AvatarAppearance appearance = new AvatarAppearance(requestData); |  | ||||||
|                 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance); |  | ||||||
|                 responseData = new Hashtable(); |  | ||||||
|                 responseData["returnString"] = "TRUE"; |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 responseData = new Hashtable(); |  | ||||||
|                 responseData["error_type"] = "unknown_avatar"; |  | ||||||
|                 responseData["error_desc"] = "The avatar appearance requested is not in the database"; |  | ||||||
|             } |  | ||||||
|             response.Value = responseData; |  | ||||||
|             return response; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) |         public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) | ||||||
|         { |         { | ||||||
|             // XmlRpcResponse response = new XmlRpcResponse(); |             // XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |  | ||||||
|  | @ -0,0 +1,124 @@ | ||||||
|  | /* | ||||||
|  |  * Copyright (c) Contributors, http://opensimulator.org/ | ||||||
|  |  * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||||||
|  |  * | ||||||
|  |  * Redistribution and use in source and binary forms, with or without | ||||||
|  |  * modification, are permitted provided that the following conditions are met: | ||||||
|  |  *     * Redistributions of source code must retain the above copyright | ||||||
|  |  *       notice, this list of conditions and the following disclaimer. | ||||||
|  |  *     * Redistributions in binary form must reproduce the above copyright | ||||||
|  |  *       notice, this list of conditions and the following disclaimer in the | ||||||
|  |  *       documentation and/or other materials provided with the distribution. | ||||||
|  |  *     * Neither the name of the OpenSim Project nor the | ||||||
|  |  *       names of its contributors may be used to endorse or promote products | ||||||
|  |  *       derived from this software without specific prior written permission. | ||||||
|  |  * | ||||||
|  |  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||||||
|  |  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||||
|  |  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
|  |  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||||||
|  |  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||||||
|  |  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||||||
|  |  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||||||
|  |  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||||
|  |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||||||
|  |  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | using System; | ||||||
|  | using System.Collections; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Reflection; | ||||||
|  | using log4net; | ||||||
|  | using Nwc.XmlRpc; | ||||||
|  | using OpenMetaverse; | ||||||
|  | using OpenSim.Framework; | ||||||
|  | using OpenSim.Framework.Communications; | ||||||
|  | using OpenSim.Framework.Servers; | ||||||
|  | 
 | ||||||
|  | namespace OpenSim.Grid.UserServer | ||||||
|  | { | ||||||
|  |     public class UserServerAvatarAppearanceModule | ||||||
|  |     { | ||||||
|  |         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||||||
|  | 
 | ||||||
|  |         private UserDataBaseService m_userDataBaseService; | ||||||
|  |         private BaseHttpServer m_httpServer; | ||||||
|  | 
 | ||||||
|  |         public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService) | ||||||
|  |         { | ||||||
|  |             m_userDataBaseService = userDataBaseService; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void Initialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void PostInitialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void RegisterHandlers(BaseHttpServer httpServer) | ||||||
|  |         { | ||||||
|  |             m_httpServer = httpServer; | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request) | ||||||
|  |         { | ||||||
|  |             XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |             Hashtable requestData = (Hashtable)request.Params[0]; | ||||||
|  |             AvatarAppearance appearance; | ||||||
|  |             Hashtable responseData; | ||||||
|  |             if (requestData.Contains("owner")) | ||||||
|  |             { | ||||||
|  |                 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"])); | ||||||
|  |                 if (appearance == null) | ||||||
|  |                 { | ||||||
|  |                     responseData = new Hashtable(); | ||||||
|  |                     responseData["error_type"] = "no appearance"; | ||||||
|  |                     responseData["error_desc"] = "There was no appearance found for this avatar"; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     responseData = appearance.ToHashTable(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 responseData = new Hashtable(); | ||||||
|  |                 responseData["error_type"] = "unknown_avatar"; | ||||||
|  |                 responseData["error_desc"] = "The avatar appearance requested is not in the database"; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             response.Value = responseData; | ||||||
|  |             return response; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request) | ||||||
|  |         { | ||||||
|  |             XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |             Hashtable requestData = (Hashtable)request.Params[0]; | ||||||
|  |             Hashtable responseData; | ||||||
|  |             if (requestData.Contains("owner")) | ||||||
|  |             { | ||||||
|  |                 AvatarAppearance appearance = new AvatarAppearance(requestData); | ||||||
|  |                 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance); | ||||||
|  |                 responseData = new Hashtable(); | ||||||
|  |                 responseData["returnString"] = "TRUE"; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 responseData = new Hashtable(); | ||||||
|  |                 responseData["error_type"] = "unknown_avatar"; | ||||||
|  |                 responseData["error_desc"] = "The avatar appearance requested is not in the database"; | ||||||
|  |             } | ||||||
|  |             response.Value = responseData; | ||||||
|  |             return response; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,173 @@ | ||||||
|  | /* | ||||||
|  |  * Copyright (c) Contributors, http://opensimulator.org/ | ||||||
|  |  * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||||||
|  |  * | ||||||
|  |  * Redistribution and use in source and binary forms, with or without | ||||||
|  |  * modification, are permitted provided that the following conditions are met: | ||||||
|  |  *     * Redistributions of source code must retain the above copyright | ||||||
|  |  *       notice, this list of conditions and the following disclaimer. | ||||||
|  |  *     * Redistributions in binary form must reproduce the above copyright | ||||||
|  |  *       notice, this list of conditions and the following disclaimer in the | ||||||
|  |  *       documentation and/or other materials provided with the distribution. | ||||||
|  |  *     * Neither the name of the OpenSim Project nor the | ||||||
|  |  *       names of its contributors may be used to endorse or promote products | ||||||
|  |  *       derived from this software without specific prior written permission. | ||||||
|  |  * | ||||||
|  |  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||||||
|  |  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||||
|  |  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
|  |  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||||||
|  |  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||||||
|  |  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||||||
|  |  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||||||
|  |  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||||
|  |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||||||
|  |  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | using System; | ||||||
|  | using System.Collections; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.Reflection; | ||||||
|  | using log4net; | ||||||
|  | using Nwc.XmlRpc; | ||||||
|  | using OpenMetaverse; | ||||||
|  | using OpenSim.Framework; | ||||||
|  | using OpenSim.Framework.Communications; | ||||||
|  | using OpenSim.Framework.Servers; | ||||||
|  | 
 | ||||||
|  | namespace OpenSim.Grid.UserServer | ||||||
|  | { | ||||||
|  |     public class UserServerFriendsModule | ||||||
|  |     { | ||||||
|  |         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||||||
|  | 
 | ||||||
|  |         private UserDataBaseService m_userDataBaseService; | ||||||
|  | 
 | ||||||
|  |         private BaseHttpServer m_httpServer; | ||||||
|  | 
 | ||||||
|  |         public UserServerFriendsModule(UserDataBaseService userDataBaseService) | ||||||
|  |         { | ||||||
|  |             m_userDataBaseService = userDataBaseService; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void Initialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void PostInitialise() | ||||||
|  |         { | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public void RegisterHandlers(BaseHttpServer httpServer) | ||||||
|  |         { | ||||||
|  |             m_httpServer = httpServer; | ||||||
|  | 
 | ||||||
|  |             m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms); | ||||||
|  |             m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers) | ||||||
|  |         { | ||||||
|  |             XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |             Hashtable responseData = new Hashtable(); | ||||||
|  |             // Query Result Information | ||||||
|  | 
 | ||||||
|  |             responseData["avcount"] = returnUsers.Count.ToString(); | ||||||
|  | 
 | ||||||
|  |             for (int i = 0; i < returnUsers.Count; i++) | ||||||
|  |             { | ||||||
|  |                 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString(); | ||||||
|  |                 responseData["friendID" + i] = returnUsers[i].Friend.ToString(); | ||||||
|  |                 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString(); | ||||||
|  |                 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString(); | ||||||
|  |             } | ||||||
|  |             response.Value = responseData; | ||||||
|  | 
 | ||||||
|  |             return response; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) | ||||||
|  |         { | ||||||
|  |             XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |             Hashtable requestData = (Hashtable)request.Params[0]; | ||||||
|  |             Hashtable responseData = new Hashtable(); | ||||||
|  |             string returnString = "FALSE"; | ||||||
|  |             // Query Result Information | ||||||
|  | 
 | ||||||
|  |             if (requestData.Contains("ownerID") && requestData.Contains("friendID") && | ||||||
|  |                 requestData.Contains("friendPerms")) | ||||||
|  |             { | ||||||
|  |                 // UserManagerBase.AddNewuserFriend | ||||||
|  |                 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]), | ||||||
|  |                                  new UUID((string)requestData["friendID"]), | ||||||
|  |                                  (uint)Convert.ToInt32((string)requestData["friendPerms"])); | ||||||
|  |                 returnString = "TRUE"; | ||||||
|  |             } | ||||||
|  |             responseData["returnString"] = returnString; | ||||||
|  |             response.Value = responseData; | ||||||
|  |             return response; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request) | ||||||
|  |         { | ||||||
|  |             XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |             Hashtable requestData = (Hashtable)request.Params[0]; | ||||||
|  |             Hashtable responseData = new Hashtable(); | ||||||
|  |             string returnString = "FALSE"; | ||||||
|  |             // Query Result Information | ||||||
|  | 
 | ||||||
|  |             if (requestData.Contains("ownerID") && requestData.Contains("friendID")) | ||||||
|  |             { | ||||||
|  |                 // UserManagerBase.AddNewuserFriend | ||||||
|  |                 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]), | ||||||
|  |                                  new UUID((string)requestData["friendID"])); | ||||||
|  |                 returnString = "TRUE"; | ||||||
|  |             } | ||||||
|  |             responseData["returnString"] = returnString; | ||||||
|  |             response.Value = responseData; | ||||||
|  |             return response; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) | ||||||
|  |         { | ||||||
|  |             XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |             Hashtable requestData = (Hashtable)request.Params[0]; | ||||||
|  |             Hashtable responseData = new Hashtable(); | ||||||
|  |             string returnString = "FALSE"; | ||||||
|  | 
 | ||||||
|  |             if (requestData.Contains("ownerID") && requestData.Contains("friendID") && | ||||||
|  |                 requestData.Contains("friendPerms")) | ||||||
|  |             { | ||||||
|  |                 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]), | ||||||
|  |                                       new UUID((string)requestData["friendID"]), | ||||||
|  |                                       (uint)Convert.ToInt32((string)requestData["friendPerms"])); | ||||||
|  |                 // UserManagerBase. | ||||||
|  |                 returnString = "TRUE"; | ||||||
|  |             } | ||||||
|  |             responseData["returnString"] = returnString; | ||||||
|  |             response.Value = responseData; | ||||||
|  |             return response; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request) | ||||||
|  |         { | ||||||
|  |             // XmlRpcResponse response = new XmlRpcResponse(); | ||||||
|  |             Hashtable requestData = (Hashtable)request.Params[0]; | ||||||
|  |             // Hashtable responseData = new Hashtable(); | ||||||
|  | 
 | ||||||
|  |             List<FriendListItem> returndata = new List<FriendListItem>(); | ||||||
|  | 
 | ||||||
|  |             if (requestData.Contains("ownerID")) | ||||||
|  |             { | ||||||
|  |                 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"])); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             return FriendListItemListtoXmlRPCResponse(returndata); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	 MW
						MW