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>
|
||||
/// Grid user server main class
|
||||
/// </summary>
|
||||
public class OpenUser_Main : BaseOpenSimServer
|
||||
public class OpenUser_Main : BaseOpenSimServer, IUGAIMCore
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -55,6 +55,10 @@ namespace OpenSim.Grid.UserServer
|
|||
protected UserDataBaseService m_userDataBaseService;
|
||||
|
||||
public UserManager m_userManager;
|
||||
|
||||
protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
|
||||
protected UserServerFriendsModule m_friendsModule;
|
||||
|
||||
public UserLoginService m_loginService;
|
||||
public GridInfoService m_gridInfoService;
|
||||
public MessageServersConnector m_messagesService;
|
||||
|
@ -99,17 +103,64 @@ namespace OpenSim.Grid.UserServer
|
|||
|
||||
IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
|
||||
|
||||
//setup database access service
|
||||
m_userDataBaseService = new UserDataBaseService(inventoryService);
|
||||
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();
|
||||
|
||||
StartupLoginService(inventoryService);
|
||||
//
|
||||
// Get the minimum defaultLevel to access to the grid
|
||||
//
|
||||
m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
|
||||
|
||||
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_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
|
||||
|
||||
|
@ -117,15 +168,10 @@ namespace OpenSim.Grid.UserServer
|
|||
m_messagesService.OnAgentLeaving += HandleAgentLeaving;
|
||||
m_messagesService.OnRegionStartup += HandleRegionStartup;
|
||||
m_messagesService.OnRegionShutdown += HandleRegionShutdown;
|
||||
}
|
||||
|
||||
m_log.Info("[STARTUP]: Starting HTTP process");
|
||||
|
||||
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
|
||||
AddHttpHandlers();
|
||||
m_httpServer.Start();
|
||||
|
||||
base.StartupSpecific();
|
||||
|
||||
protected virtual void RegisterConsoleCommands()
|
||||
{
|
||||
m_console.Commands.AddCommand("userserver", false, "create user",
|
||||
"create user [<first> [<last> [<x> <y> [email]]]]",
|
||||
"Create a new user account", RunCommand);
|
||||
|
@ -156,80 +202,67 @@ namespace OpenSim.Grid.UserServer
|
|||
"Log off a named user", RunCommand);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start up the user manager
|
||||
/// </summary>
|
||||
/// <param name="inventoryService"></param>
|
||||
protected virtual void StartupUserManager(IInterServiceInventoryServices inventoryService)
|
||||
protected virtual void RegisterHttpHandlers()
|
||||
{
|
||||
m_userManager = new UserManager(inventoryService, 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 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_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
|
||||
|
||||
m_userManager.RegisterHandlers(m_httpServer);
|
||||
m_friendsModule.RegisterHandlers(m_httpServer);
|
||||
m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
|
||||
m_messagesService.RegisterHandlers(m_httpServer);
|
||||
|
||||
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
|
||||
m_gridInfoService.RestGetGridInfoMethod));
|
||||
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)
|
||||
{
|
||||
switch (args[0])
|
||||
|
@ -468,19 +501,16 @@ namespace OpenSim.Grid.UserServer
|
|||
m_console.Notice("login-level <value> - Set the miminim userlevel allowed To login.");
|
||||
m_console.Notice("login-reset - reset the login level to its default value.");
|
||||
m_console.Notice("login-text <text to print during the login>");
|
||||
|
||||
}
|
||||
|
||||
public override void ShutdownSpecific()
|
||||
{
|
||||
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void TestResponse(List<InventoryFolderBase> resp)
|
||||
{
|
||||
m_console.Notice("response got");
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
public void NotifyMessageServersUserLoggOff(UUID agentID)
|
||||
{
|
||||
m_messagesService.TellMessageServersAboutUserLogoff(agentID);
|
||||
|
@ -531,5 +561,6 @@ namespace OpenSim.Grid.UserServer
|
|||
m_userManager.HandleRegionShutdown(regionID);
|
||||
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ namespace OpenSim.Grid.UserServer
|
|||
|
||||
public Dictionary<string, MessageServerInfo> MessageServers;
|
||||
|
||||
private BaseHttpServer m_httpServer;
|
||||
|
||||
private BlockingQueue<PresenceNotification> m_NotifyQueue =
|
||||
new BlockingQueue<PresenceNotification>();
|
||||
|
||||
|
@ -88,6 +90,30 @@ namespace OpenSim.Grid.UserServer
|
|||
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)
|
||||
{
|
||||
lock (MessageServers)
|
||||
|
|
|
@ -38,6 +38,7 @@ using OpenSim.Framework;
|
|||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Communications.Capabilities;
|
||||
using OpenSim.Framework.Servers;
|
||||
|
||||
namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
|
@ -61,6 +62,8 @@ namespace OpenSim.Grid.UserServer
|
|||
public UserConfig m_config;
|
||||
private readonly IRegionProfileService m_regionProfileService;
|
||||
|
||||
protected BaseHttpServer m_httpServer;
|
||||
|
||||
public UserLoginService(
|
||||
UserManagerBase userManager, IInterServiceInventoryServices inventoryService,
|
||||
LibraryRootFolder libraryRootFolder,
|
||||
|
@ -71,6 +74,29 @@ namespace OpenSim.Grid.UserServer
|
|||
m_inventoryService = inventoryService;
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -48,16 +48,45 @@ namespace OpenSim.Grid.UserServer
|
|||
private logOffUser handlerLogOffUser;
|
||||
|
||||
private UserDataBaseService m_userDataBaseService;
|
||||
private BaseHttpServer m_httpServer;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="interServiceInventoryService"></param>
|
||||
public UserManager(IInterServiceInventoryServices interServiceInventoryService, UserDataBaseService userDataBaseService)
|
||||
/// <param name="userDataBaseService"></param>
|
||||
public UserManager( 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>
|
||||
/// Deletes an active agent session
|
||||
/// </summary>
|
||||
|
@ -109,26 +138,6 @@ namespace OpenSim.Grid.UserServer
|
|||
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>
|
||||
/// Converts a user profile to an XML element which can be returned
|
||||
/// </summary>
|
||||
|
@ -230,138 +239,6 @@ namespace OpenSim.Grid.UserServer
|
|||
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)
|
||||
{
|
||||
// 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