* Rex merges, user server.

afrisby-3
Adam Frisby 2008-02-23 02:57:50 +00:00
parent 7caa40e301
commit b526c42d06
5 changed files with 1268 additions and 1188 deletions

View File

@ -1,315 +1,331 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the * * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework.Statistics;
namespace OpenSim.Grid.UserServer
{ namespace OpenSim.Grid.UserServer
/// <summary> {
/// </summary> /// <summary>
public class OpenUser_Main : conscmd_callback /// </summary>
{ public class OpenUser_Main : BaseOpenSimServer, conscmd_callback
private UserConfig Cfg; {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public UserManager m_userManager; private UserConfig Cfg;
public UserLoginService m_loginService;
public MessageServersConnector m_messagesService; public UserManager m_userManager;
public UserLoginService m_loginService;
private LogBase m_console; public MessageServersConnector m_messagesService;
private LLUUID m_lastCreatedUser = LLUUID.Random();
private LLUUID m_lastCreatedUser = LLUUID.Random();
private Boolean m_rexMode;
private Boolean m_rexMode;
[STAThread]
public static void Main(string[] args) [STAThread]
{ public static void Main(string[] args)
Console.WriteLine("Launching UserServer..."); {
log4net.Config.XmlConfigurator.Configure();
OpenUser_Main userserver = new OpenUser_Main();
m_log.Info("Launching UserServer...");
userserver.Startup();
userserver.Work(); OpenUser_Main userserver = new OpenUser_Main();
}
userserver.Startup();
private OpenUser_Main() userserver.Work();
{ }
if (!Directory.Exists(Util.logDir()))
{ private OpenUser_Main()
Directory.CreateDirectory(Util.logDir()); {
} m_console = new ConsoleBase("OpenUser", this);
m_console = MainConsole.Instance = m_console;
new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true); }
MainLog.Instance = m_console;
} private void Work()
{
private void Work() m_console.Notice("Enter help for a list of commands\n");
{
m_console.Notice("Enter help for a list of commands\n"); while (true)
{
while (true) m_console.Prompt();
{ }
m_console.MainLogPrompt(); }
}
} public void Startup()
{
public void Startup() Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
{
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); StatsManager.StartCollectingUserStats();
MainLog.Instance.Verbose("REGION", "Establishing data connection"); m_log.Info("[REGION]: Establishing data connection");
m_userManager = new UserManager(); m_userManager = new UserManager();
m_userManager._config = Cfg; m_userManager._config = Cfg;
m_userManager.AddPlugin(Cfg.DatabaseProvider); m_userManager.AddPlugin(Cfg.DatabaseProvider);
m_loginService = new UserLoginService( m_loginService = new UserLoginService(
m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
m_rexMode = Cfg.RexMode; m_rexMode = Cfg.RexMode;
m_messagesService = new MessageServersConnector(MainLog.Instance); m_messagesService = new MessageServersConnector();
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
MainLog.Instance.Verbose("REGION", "Starting HTTP process"); m_log.Info("[REGION]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
if (!m_rexMode) { httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar);
httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend);
httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
// Message Server ---> User Server httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion); // Message Server ---> User Server
httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer); httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
} httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
else { httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
httpServer.AddXmlRPCHandler("get_user_by_name", new RexRemoteHandler("get_user_by_name").rexRemoteXmlRPCHandler);
httpServer.AddXmlRPCHandler("get_user_by_uuid", new RexRemoteHandler("get_user_by_uuid").rexRemoteXmlRPCHandler); // Message Server ---> User Server
httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", new RexRemoteHandler("get_avatar_picker_avatar").rexRemoteXmlRPCHandler); httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
httpServer.AddXmlRPCHandler("add_new_user_friend", new RexRemoteHandler("add_new_user_friend").rexRemoteXmlRPCHandler); httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
httpServer.AddXmlRPCHandler("remove_user_friend", new RexRemoteHandler("remove_user_friend").rexRemoteXmlRPCHandler); httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
httpServer.AddXmlRPCHandler("update_user_friend_perms", new RexRemoteHandler("update_user_friend_perms").rexRemoteXmlRPCHandler); }
httpServer.AddXmlRPCHandler("get_user_friend_list", new RexRemoteHandler("get_user_friend_list").rexRemoteXmlRPCHandler); else {
httpServer.AddXmlRPCHandler("get_user_by_name", new RexRemoteHandler("get_user_by_name").rexRemoteXmlRPCHandler);
// Message Server ---> User Server httpServer.AddXmlRPCHandler("get_user_by_uuid", new RexRemoteHandler("get_user_by_uuid").rexRemoteXmlRPCHandler);
httpServer.AddXmlRPCHandler("register_messageserver", new RexRemoteHandler("register_messageserver").rexRemoteXmlRPCHandler); httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", new RexRemoteHandler("get_avatar_picker_avatar").rexRemoteXmlRPCHandler);
httpServer.AddXmlRPCHandler("agent_change_region", new RexRemoteHandler("agent_change_region").rexRemoteXmlRPCHandler); httpServer.AddXmlRPCHandler("add_new_user_friend", new RexRemoteHandler("add_new_user_friend").rexRemoteXmlRPCHandler);
httpServer.AddXmlRPCHandler("deregister_messageserver", new RexRemoteHandler("deregister_messageserver").rexRemoteXmlRPCHandler); httpServer.AddXmlRPCHandler("remove_user_friend", new RexRemoteHandler("remove_user_friend").rexRemoteXmlRPCHandler);
} httpServer.AddXmlRPCHandler("update_user_friend_perms", new RexRemoteHandler("update_user_friend_perms").rexRemoteXmlRPCHandler);
httpServer.AddXmlRPCHandler("get_user_friend_list", new RexRemoteHandler("get_user_friend_list").rexRemoteXmlRPCHandler);
httpServer.AddStreamHandler(
new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); // Message Server ---> User Server
httpServer.AddXmlRPCHandler("register_messageserver", new RexRemoteHandler("register_messageserver").rexRemoteXmlRPCHandler);
httpServer.Start(); httpServer.AddXmlRPCHandler("agent_change_region", new RexRemoteHandler("agent_change_region").rexRemoteXmlRPCHandler);
m_console.Status("SERVER", "Userserver 0.4 - Startup complete"); httpServer.AddXmlRPCHandler("deregister_messageserver", new RexRemoteHandler("deregister_messageserver").rexRemoteXmlRPCHandler);
} }
httpServer.AddStreamHandler(
public void do_create(string what) new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
{
switch (what) httpServer.Start();
{ m_log.Info("[SERVER]: Userserver 0.5 - Startup complete");
case "user": }
string tempfirstname;
string templastname; public void do_create(string what)
string tempMD5Passwd; {
uint regX = 1000; switch (what)
uint regY = 1000; {
case "user":
tempfirstname = m_console.CmdPrompt("First name"); string tempfirstname;
templastname = m_console.CmdPrompt("Last name"); string templastname;
tempMD5Passwd = m_console.PasswdPrompt("Password"); string tempMD5Passwd;
regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); uint regX = 1000;
regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); uint regY = 1000;
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); tempfirstname = m_console.CmdPrompt("First name");
templastname = m_console.CmdPrompt("Last name");
LLUUID userID = new LLUUID(); //tempMD5Passwd = m_console.PasswdPrompt("Password");
try tempMD5Passwd = m_console.CmdPrompt("Password");
{ regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
userID = regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
} catch (Exception ex) if (null != m_userManager.GetUserProfile(tempfirstname, templastname))
{ {
m_console.Error("SERVER", "Error creating user: {0}", ex.ToString()); m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
} break;
}
try
{ tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/",
userID.UUID); LLUUID userID = new LLUUID();
} try
catch (Exception ex) {
{ userID =
m_console.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
} } catch (Exception ex)
m_lastCreatedUser = userID; {
break; m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
} }
}
try
public void RunCmd(string cmd, string[] cmdparams) {
{ RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/",
switch (cmd) userID.UUID);
{ }
case "help": catch (Exception ex)
m_console.Notice("create user - create a new user"); {
m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", ex.ToString());
break; }
m_lastCreatedUser = userID;
case "create": break;
do_create(cmdparams[0]); }
break; }
case "shutdown": public override void RunCmd(string cmd, string[] cmdparams)
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; {
m_console.Close(); base.RunCmd(cmd, cmdparams);
Environment.Exit(0);
break; switch (cmd)
{
case "test-inventory": case "help":
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); m_console.Notice("create user - create a new user");
// requester.ReturnResponseVal = TestResponse; m_console.Notice("stats - statistical information for this server");
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
List<InventoryFolderBase> folders = break;
SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
m_userManager. case "create":
_config. do_create(cmdparams[0]);
InventoryUrl + break;
"RootFolders/",
m_lastCreatedUser); case "shutdown":
break; m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
} m_console.Close();
} Environment.Exit(0);
break;
public void TestResponse(List<InventoryFolderBase> resp)
{ case "stats":
Console.WriteLine("response got"); m_console.Notice(StatsManager.UserStats.Report());
} break;
public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
{ case "test-inventory":
m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position); // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
} // requester.ReturnResponseVal = TestResponse;
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
/*private void ConfigDB(IGenericConfig configData) SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
{ m_userManager.
try _config.
{ InventoryUrl +
string attri = ""; "RootFolders/",
attri = configData.GetAttribute("DataBaseProvider"); m_lastCreatedUser);
if (attri == "") break;
{ }
StorageDll = "OpenSim.Framework.Data.DB4o.dll"; }
configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");
} public void TestResponse(List<InventoryFolderBase> resp)
else {
{ m_console.Notice("response got");
StorageDll = attri; }
}
configData.Commit(); public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
} {
catch m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position);
{ }
} /*private void ConfigDB(IGenericConfig configData)
}*/ {
try
public void Show(string ShowWhat) {
{ string attri = String.Empty;
} attri = configData.GetAttribute("DataBaseProvider");
} if (attri == String.Empty)
{
/// <summary> StorageDll = "OpenSim.Framework.Data.DB4o.dll";
/// for forwarding some requests to authentication server configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");
/// </summary> }
class RexRemoteHandler else
{ {
private string methodName; StorageDll = attri;
}
public RexRemoteHandler(String method) configData.Commit();
{ }
methodName = method; catch
} {
public XmlRpcResponse rexRemoteXmlRPCHandler(XmlRpcRequest request) }
{ }*/
Hashtable requestData = (Hashtable)request.Params[0]; }
string authAddr;
if (requestData.Contains("AuthenticationAddress") && requestData["AuthenticationAddress"] != null) /// <summary>
{ /// for forwarding some requests to authentication server
authAddr = (string)requestData["AuthenticationAddress"]; /// </summary>
} class RexRemoteHandler
else {
{ private string methodName;
return CreateErrorResponse("unknown_authentication",
"Request did not contain authentication address"); public RexRemoteHandler(String method)
} {
methodName = method;
ArrayList SendParams = new ArrayList(); }
foreach (Object obj in request.Params)
{ public XmlRpcResponse rexRemoteXmlRPCHandler(XmlRpcRequest request)
SendParams.Add(obj); {
} Hashtable requestData = (Hashtable)request.Params[0];
XmlRpcRequest req = new XmlRpcRequest(methodName, SendParams); string authAddr;
if(!authAddr.StartsWith("http://")) if (requestData.Contains("AuthenticationAddress") && requestData["AuthenticationAddress"] != null)
authAddr = "http://"+ authAddr; {
XmlRpcResponse res = req.Send(authAddr, 30000); authAddr = (string)requestData["AuthenticationAddress"];
return res; }
} else
{
public XmlRpcResponse CreateErrorResponse(string type, string desc) return CreateErrorResponse("unknown_authentication",
{ "Request did not contain authentication address");
XmlRpcResponse response = new XmlRpcResponse(); }
Hashtable responseData = new Hashtable();
responseData["error_type"] = type; ArrayList SendParams = new ArrayList();
responseData["error_desc"] = desc; foreach (Object obj in request.Params)
{
response.Value = responseData; SendParams.Add(obj);
return response; }
} XmlRpcRequest req = new XmlRpcRequest(methodName, SendParams);
} if(!authAddr.StartsWith("http://"))
authAddr = "http://"+ authAddr;
} XmlRpcResponse res = req.Send(authAddr, 30000);
return res;
}
public XmlRpcResponse CreateErrorResponse(string type, string desc)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
responseData["error_type"] = type;
responseData["error_desc"] = desc;
response.Value = responseData;
return response;
}
}
}

View File

@ -1,184 +1,180 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the * * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
namespace OpenSim.Grid.UserServer namespace OpenSim.Grid.UserServer
{ {
public class MessageServersConnector
public class MessageServersConnector {
{ private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private LogBase m_log;
public Dictionary<string, MessageServerInfo> MessageServers; public Dictionary<string, MessageServerInfo> MessageServers;
public MessageServersConnector(LogBase log) public MessageServersConnector()
{ {
m_log=log; MessageServers = new Dictionary<string, MessageServerInfo>();
MessageServers = new Dictionary<string, MessageServerInfo>(); }
}
public void RegisterMessageServer(string URI, MessageServerInfo serverData)
public void RegisterMessageServer(string URI, MessageServerInfo serverData) {
{ MessageServers.Add(URI, serverData);
MessageServers.Add(URI, serverData); }
}
public void DeRegisterMessageServer(string URI)
public void DeRegisterMessageServer(string URI) {
{ MessageServers.Remove(URI);
MessageServers.Remove(URI); }
}
public void AddResponsibleRegion(string URI, ulong regionhandle)
public void AddResponsibleRegion(string URI, ulong regionhandle) {
{ if (!MessageServers.ContainsKey(URI))
if (!MessageServers.ContainsKey(URI)) {
{ m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered");
m_log.Warn("MSGSERVER", "Got addResponsibleRegion Request for a MessageServer that isn't registered"); }
} else
else {
{ MessageServerInfo msginfo = MessageServers["URI"];
MessageServerInfo msginfo = MessageServers["URI"]; msginfo.responsibleForRegions.Add(regionhandle);
msginfo.responsibleForRegions.Add(regionhandle); MessageServers["URI"] = msginfo;
MessageServers["URI"] = msginfo; }
} }
} public void RemoveResponsibleRegion(string URI, ulong regionhandle)
public void RemoveResponsibleRegion(string URI, ulong regionhandle) {
{ if (!MessageServers.ContainsKey(URI))
if (!MessageServers.ContainsKey(URI)) {
{ m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
m_log.Warn("MSGSERVER", "Got RemoveResponsibleRegion Request for a MessageServer that isn't registered"); }
} else
else {
{ MessageServerInfo msginfo = MessageServers["URI"];
MessageServerInfo msginfo = MessageServers["URI"]; if (msginfo.responsibleForRegions.Contains(regionhandle))
if (msginfo.responsibleForRegions.Contains(regionhandle)) {
{ msginfo.responsibleForRegions.Remove(regionhandle);
msginfo.responsibleForRegions.Remove(regionhandle); MessageServers["URI"] = msginfo;
MessageServers["URI"] = msginfo; }
} }
}
}
} public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) {
{ XmlRpcResponse response = new XmlRpcResponse();
XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0];
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable();
Hashtable responseData = new Hashtable();
if (requestData.Contains("uri"))
if (requestData.Contains("uri")) {
{ string URI = (string)requestData["uri"];
string URI = (string)requestData["uri"]; string sendkey=(string)requestData["sendkey"];
string sendkey=(string)requestData["sendkey"]; string recvkey=(string)requestData["recvkey"];
string recvkey=(string)requestData["recvkey"]; MessageServerInfo m = new MessageServerInfo();
MessageServerInfo m = new MessageServerInfo(); m.URI = URI;
m.URI = URI; m.sendkey = sendkey;
m.sendkey = sendkey; m.recvkey = recvkey;
m.recvkey = recvkey; RegisterMessageServer(URI, m);
RegisterMessageServer(URI, m); responseData["responsestring"] = "TRUE";
responseData["responsestring"] = "TRUE"; response.Value = responseData;
response.Value = responseData; }
} return response;
return response; }
} public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) {
{ XmlRpcResponse response = new XmlRpcResponse();
XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0];
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable();
Hashtable responseData = new Hashtable();
if (requestData.Contains("uri"))
if (requestData.Contains("uri")) {
{ string URI = (string)requestData["URI"];
string URI = (string)requestData["URI"];
DeRegisterMessageServer(URI);
DeRegisterMessageServer(URI); responseData["responsestring"] = "TRUE";
responseData["responsestring"] = "TRUE"; response.Value = responseData;
response.Value = responseData; }
} return response;
return response; }
} public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request)
public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request) {
{ XmlRpcResponse response = new XmlRpcResponse();
XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0];
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable();
Hashtable responseData = new Hashtable();
if (requestData.Contains("fromuri"))
if (requestData.Contains("fromuri")) {
{ string sURI = (string)requestData["fromuri"];
string sURI = (string)requestData["fromuri"]; string sagentID = (string)requestData["agentid"];
string sagentID = (string)requestData["agentid"]; string ssessionID = (string)requestData["sessionid"];
string ssessionID = (string)requestData["sessionid"]; string scurrentRegionID = (string)requestData["regionid"];
string scurrentRegionID = (string)requestData["regionid"]; string sregionhandle = (string)requestData["regionhandle"];
string sregionhandle = (string)requestData["regionhandle"]; string scurrentpos = (string)requestData["currentpos"];
string scurrentpos = (string)requestData["currentpos"]; //LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
//LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); // TODO: Okay now raise event so the user server can pass this data to the Usermanager
// TODO: Okay now raise event so the user server can pass this data to the Usermanager
responseData["responsestring"] = "TRUE";
responseData["responsestring"] = "TRUE"; response.Value = responseData;
response.Value = responseData; }
} return response;
return response; }
}
public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) {
{ // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D )
// Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D ) foreach (MessageServerInfo serv in MessageServers.Values)
foreach (MessageServerInfo serv in MessageServers.Values) {
{ NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position);
NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position); }
} }
}
private void NotifyMessageServerAboutUser(MessageServerInfo serv, LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
private void NotifyMessageServerAboutUser(MessageServerInfo serv, LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) {
{ Hashtable reqparams = new Hashtable();
Hashtable reqparams = new Hashtable(); reqparams["sendkey"] = serv.sendkey;
reqparams["sendkey"] = serv.sendkey; reqparams["agentid"] = agentID.ToString();
reqparams["agentid"] = agentID.ToString(); reqparams["sessionid"] = sessionID.ToString();
reqparams["sessionid"] = sessionID.ToString(); reqparams["regionid"] = RegionID.ToString();
reqparams["regionid"] = RegionID.ToString(); reqparams["regionhandle"] = regionhandle.ToString();
reqparams["regionhandle"] = regionhandle.ToString(); reqparams["position"] = Position.ToString();
reqparams["position"] = Position.ToString();
ArrayList SendParams = new ArrayList();
ArrayList SendParams = new ArrayList(); SendParams.Add(reqparams);
SendParams.Add(reqparams);
XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams); XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000); m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
m_log.Verbose("LOGIN","Notified : " + serv.URI + " about user login"); }
}
} }
}
}

View File

@ -1,36 +1,64 @@
using System.Reflection; /*
using System.Runtime.InteropServices; * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
// General Information about an assembly is controlled through the following *
// set of attributes. Change these attribute values to modify the information * Redistribution and use in source and binary forms, with or without
// associated with an assembly. * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
[assembly : AssemblyTitle("OGS-UserServer")] * notice, this list of conditions and the following disclaimer.
[assembly : AssemblyDescription("")] * * Redistributions in binary form must reproduce the above copyright
[assembly : AssemblyConfiguration("")] * notice, this list of conditions and the following disclaimer in the
[assembly : AssemblyCompany("")] * documentation and/or other materials provided with the distribution.
[assembly : AssemblyProduct("OGS-UserServer")] * * Neither the name of the OpenSim Project nor the
[assembly : AssemblyCopyright("Copyright © 2007")] * names of its contributors may be used to endorse or promote products
[assembly : AssemblyTrademark("")] * derived from this software without specific prior written permission.
[assembly : AssemblyCulture("")] *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
// Setting ComVisible to false makes the types in this assembly not visible * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// to COM components. If you need to access a type in this assembly from * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// COM, set the ComVisible attribute to true on that type. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
[assembly : ComVisible(false)] * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// The following GUID is for the ID of the typelib if this project is exposed to COM * 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
[assembly : Guid("e266513a-090b-4d38-80f6-8599eef68c8c")] * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
// Version information for an assembly consists of the following four values: */
//
// Major Version using System.Reflection;
// Minor Version using System.Runtime.InteropServices;
// Build Number
// Revision // General Information about an assembly is controlled through the following
// // set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")] [assembly : AssemblyTitle("OGS-UserServer")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OGS-UserServer")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -1,305 +1,318 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the * * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Data; using OpenSim.Framework.Data;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.Statistics;
using InventoryFolder=OpenSim.Framework.InventoryFolder; using OpenSim.Framework.UserManagement;
using InventoryFolder=OpenSim.Framework.InventoryFolder;
namespace OpenSim.Grid.UserServer
{ namespace OpenSim.Grid.UserServer
public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position); {
public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position);
public class UserLoginService : LoginService public class UserLoginService : LoginService
{ {
public event UserLoggedInAtLocation OnUserLoggedInAtLocation; private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public UserConfig m_config; public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
public UserLoginService( private UserLoggedInAtLocation handler001 = null;
UserManagerBase userManager, LibraryRootFolder libraryRootFolder, UserConfig config, string welcomeMess)
: base(userManager, libraryRootFolder, welcomeMess, config.RexMode) public UserConfig m_config;
{
m_config = config; public UserLoginService(
} UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
UserConfig config, string welcomeMess)
/// <summary> : base(userManager, libraryRootFolder, welcomeMess, config.RexMode)
/// Customises the login response and fills in missing values. {
/// </summary> m_config = config;
/// <param name="response">The existing response</param> }
/// <param name="theUser">The user profile</param>
public override void CustomiseResponse(LoginResponse response, UserProfileData theUser, string ASaddress) /// <summary>
{ /// Customises the login response and fills in missing values.
bool tryDefault = false; /// </summary>
//CFK: Since the try is always "tried", the "Home Location" message should always appear, so comment this one. /// <param name="response">The existing response</param>
//CFK: MainLog.Instance.Verbose("LOGIN", "Load information from the gridserver"); /// <param name="theUser">The user profile</param>
RegionProfileData SimInfo = new RegionProfileData(); public override void CustomiseResponse(LoginResponse response, UserProfileData theUser, string ASaddress)
try {
{ bool tryDefault = false;
SimInfo = //CFK: Since the try is always "tried", the "Home Location" message should always appear, so comment this one.
SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, //CFK: m_log.Info("[LOGIN]: Load information from the gridserver");
m_config.GridSendKey, m_config.GridRecvKey);
try
// Customise the response {
//CFK: This is redundant and the next message should always appear. RegionProfileData SimInfo =
//CFK: MainLog.Instance.Verbose("LOGIN", "Home Location"); RegionProfileData.RequestSimProfileData(
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + theUser.currentAgent.currentHandle, m_config.GridServerURL,
(SimInfo.regionLocY*256).ToString() + "], " + m_config.GridSendKey, m_config.GridRecvKey);
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + // Customise the response
"'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + //CFK: This is redundant and the next message should always appear.
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; //CFK: m_log.Info("[LOGIN]: Home Location");
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
// Destination (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
//CFK: The "Notifying" message always seems to appear, so subsume the data from this message into "'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
//CFK: the next one for X & Y and comment this one. theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
//CFK: MainLog.Instance.Verbose("LOGIN", "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
//CFK: "; Region Y: " + SimInfo.regionLocY); theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
response.SimPort = (uint) SimInfo.serverPort; // Destination
response.RegionX = SimInfo.regionLocX; //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
response.RegionY = SimInfo.regionLocY; //CFK: the next one for X & Y and comment this one.
//CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
//Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI //CFK: "; Region Y: " + SimInfo.regionLocY);
string capsPath = Util.GetRandomCapsPath(); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; response.SimPort = (uint) SimInfo.serverPort;
response.RegionX = SimInfo.regionLocX;
// Notify the target of an incoming user response.RegionY = SimInfo.regionLocY;
//CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
//CFK: the next one for X & Y and comment this one. //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
//CFK: MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " (" + SimInfo.serverURI + ") " + string capsPath = Util.GetRandomCapsPath();
//CFK: SimInfo.regionLocX + "," + SimInfo.regionLocY); response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
// Prepare notification // Notify the target of an incoming user
Hashtable SimParams = new Hashtable(); //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); //CFK: the next one for X & Y and comment this one.
SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); //CFK: m_log.Info("[LOGIN]: " + SimInfo.regionName + " (" + SimInfo.serverURI + ") " +
SimParams["firstname"] = theUser.username; //CFK: SimInfo.regionLocX + "," + SimInfo.regionLocY);
SimParams["lastname"] = theUser.surname;
SimParams["agent_id"] = theUser.UUID.ToString(); // Prepare notification
SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); Hashtable SimParams = new Hashtable();
SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); SimParams["firstname"] = theUser.username;
SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); SimParams["lastname"] = theUser.surname;
SimParams["caps_path"] = capsPath; SimParams["agent_id"] = theUser.UUID.ToString();
if (m_rexMode) SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode);
{ SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
SimParams["auth_addr"] = theUser.authenticationAddr; SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
SimParams["as_addr"] = ASaddress; SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
} SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
SimParams["caps_path"] = capsPath;
ArrayList SendParams = new ArrayList(); if (m_rexMode)
SendParams.Add(SimParams); {
SimParams["auth_addr"] = theUser.authenticationAddr;
// Update agent with target sim SimParams["as_addr"] = ASaddress;
theUser.currentAgent.currentRegion = SimInfo.UUID; }
theUser.currentAgent.currentHandle = SimInfo.regionHandle;
ArrayList SendParams = new ArrayList();
MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " + SendParams.Add(SimParams);
SimInfo.regionLocX + "," + SimInfo.regionLocY);
// Update agent with target sim
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); theUser.currentAgent.currentRegion = SimInfo.UUID;
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); theUser.currentAgent.currentHandle = SimInfo.regionHandle;
}
catch (Exception) m_log.Info("[LOGIN]: Telling "
{ + SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " +
tryDefault = true; SimInfo.regionLocX + "," + SimInfo.regionLocY + " to expect user connection");
}
if (tryDefault) XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
{ XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
// Send him to default region instead
// Load information from the gridserver if (GridResp.IsFault)
{
ulong defaultHandle = (((ulong) m_config.DefaultX*256) << 32) | ((ulong) m_config.DefaultY*256); m_log.ErrorFormat(
"[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}",
MainLog.Instance.Warn( SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
"LOGIN", }
"Home region not available: sending to default " + defaultHandle.ToString()); }
catch (Exception)
SimInfo = new RegionProfileData(); {
try tryDefault = true;
{ }
SimInfo =
SimInfo.RequestSimProfileData(defaultHandle, m_config.GridServerURL, if (tryDefault)
m_config.GridSendKey, m_config.GridRecvKey); {
// Send him to default region instead
// Customise the response // Load information from the gridserver
MainLog.Instance.Verbose("LOGIN", "Home Location");
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize);
(SimInfo.regionLocY*256).ToString() + "], " +
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" + m_log.Warn(
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString());
"'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; try
{
// Destination RegionProfileData SimInfo = RegionProfileData.RequestSimProfileData(
MainLog.Instance.Verbose("LOGIN", defaultHandle, m_config.GridServerURL,
"CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + m_config.GridSendKey, m_config.GridRecvKey);
SimInfo.regionLocY);
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); // Customise the response
response.SimPort = (uint) SimInfo.serverPort; m_log.Info("[LOGIN]: Home Location");
response.RegionX = SimInfo.regionLocX; response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
response.RegionY = SimInfo.regionLocY; (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
//Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
string capsPath = Util.GetRandomCapsPath(); "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
// Notify the target of an incoming user // Destination
MainLog.Instance.Verbose("LOGIN", "Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); m_log.Info("[LOGIN]: " +
"CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
// Update agent with target sim SimInfo.regionLocY);
theUser.currentAgent.currentRegion = SimInfo.UUID; response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
theUser.currentAgent.currentHandle = SimInfo.regionHandle; response.SimPort = (uint) SimInfo.serverPort;
response.RegionX = SimInfo.regionLocX;
// Prepare notification response.RegionY = SimInfo.regionLocY;
Hashtable SimParams = new Hashtable();
SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); string capsPath = Util.GetRandomCapsPath();
SimParams["firstname"] = theUser.username; response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
SimParams["lastname"] = theUser.surname;
SimParams["agent_id"] = theUser.UUID.ToString(); // Notify the target of an incoming user
SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); m_log.Info("[LOGIN]: Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); // Update agent with target sim
SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); theUser.currentAgent.currentRegion = SimInfo.UUID;
SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); theUser.currentAgent.currentHandle = SimInfo.regionHandle;
SimParams["caps_path"] = capsPath;
if (m_rexMode) // Prepare notification
{ Hashtable SimParams = new Hashtable();
SimParams["auth_addr"] = theUser.authenticationAddr; SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
SimParams["as_addr"] = ASaddress; SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
} SimParams["firstname"] = theUser.username;
SimParams["lastname"] = theUser.surname;
ArrayList SendParams = new ArrayList(); SimParams["agent_id"] = theUser.UUID.ToString();
SendParams.Add(SimParams); SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode);
SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
MainLog.Instance.Verbose("LOGIN", "Informing region at " + SimInfo.httpServerURI); SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
// Send SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); SimParams["caps_path"] = capsPath;
if (OnUserLoggedInAtLocation != null) if (m_rexMode)
{ {
OnUserLoggedInAtLocation(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos); SimParams["auth_addr"] = theUser.authenticationAddr;
} SimParams["as_addr"] = ASaddress;
} }
catch (Exception e) ArrayList SendParams = new ArrayList();
{ SendParams.Add(SimParams);
MainLog.Instance.Warn("LOGIN", "Default region also not available");
MainLog.Instance.Warn("LOGIN", e.ToString()); m_log.Info("[LOGIN]: Informing region at " + SimInfo.httpServerURI);
} // Send
} XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
} XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
handler001 = OnUserLoggedInAtLocation;
protected override InventoryData CreateInventoryData(LLUUID userID) if (handler001 != null)
{ {
List<InventoryFolderBase> folders handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos);
= SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( }
"POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); }
// In theory, the user will only ever be missing a root folder in situations where a grid catch (Exception e)
// which didn't previously run a grid wide inventory server is being transitioned to one {
// which does. m_log.Warn("[LOGIN]: Default region also not available");
if (null == folders | folders.Count == 0) m_log.Warn("[LOGIN]: " + e.ToString());
{ }
MainLog.Instance.Warn( }
"LOGIN", }
"A root inventory folder for user ID " + userID + " was not found. A new set"
+ " of empty inventory folders is being created."); protected override InventoryData CreateInventoryData(LLUUID userID)
{
RestObjectPoster.BeginPostObject<Guid>( List<InventoryFolderBase> folders
m_config.InventoryUrl + "CreateInventory/", userID.UUID); = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
"POST", m_config.InventoryUrl + "RootFolders/", userID.UUID);
// A big delay should be okay here since the recreation of the user's root folders should
// only ever happen once. We need to sleep to let the inventory server do its work - // In theory, the user will only ever be missing a root folder in situations where a grid
// previously 1000ms has been found to be too short. // which didn't previously run a grid wide inventory server is being transitioned to one
Thread.Sleep(10000); // which does.
folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( if (null == folders | folders.Count == 0)
"POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); {
} m_log.Warn(
"[LOGIN]: " +
if (folders.Count > 0) "root inventory folder user " + userID + " not found. Creating.");
{
LLUUID rootID = LLUUID.Zero; RestObjectPoster.BeginPostObject<Guid>(
ArrayList AgentInventoryArray = new ArrayList(); m_config.InventoryUrl + "CreateInventory/", userID.UUID);
Hashtable TempHash;
foreach (InventoryFolderBase InvFolder in folders) // A big delay should be okay here since the recreation of the user's root folders should
{ // only ever happen once. We need to sleep to let the inventory server do its work -
if (InvFolder.parentID == LLUUID.Zero) // previously 1000ms has been found to be too short.
{ Thread.Sleep(10000);
rootID = InvFolder.folderID; folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
} "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID);
TempHash = new Hashtable(); }
TempHash["name"] = InvFolder.name;
TempHash["parent_id"] = InvFolder.parentID.ToString(); if (folders.Count > 0)
TempHash["version"] = (Int32) InvFolder.version; {
TempHash["type_default"] = (Int32) InvFolder.type; LLUUID rootID = LLUUID.Zero;
TempHash["folder_id"] = InvFolder.folderID.ToString(); ArrayList AgentInventoryArray = new ArrayList();
AgentInventoryArray.Add(TempHash); Hashtable TempHash;
} foreach (InventoryFolderBase InvFolder in folders)
return new InventoryData(AgentInventoryArray, rootID); {
} if (InvFolder.parentID == LLUUID.Zero)
else {
{ rootID = InvFolder.folderID;
MainLog.Instance.Warn("LOGIN", "The root inventory folder could still not be retrieved" + }
" for user ID " + userID); TempHash = new Hashtable();
TempHash["name"] = InvFolder.name;
AgentInventory userInventory = new AgentInventory(); TempHash["parent_id"] = InvFolder.parentID.ToString();
userInventory.CreateRootFolder(userID, false); TempHash["version"] = (Int32) InvFolder.version;
TempHash["type_default"] = (Int32) InvFolder.type;
ArrayList AgentInventoryArray = new ArrayList(); TempHash["folder_id"] = InvFolder.folderID.ToString();
Hashtable TempHash; AgentInventoryArray.Add(TempHash);
foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) }
{ return new InventoryData(AgentInventoryArray, rootID);
TempHash = new Hashtable(); }
TempHash["name"] = InvFolder.FolderName; else
TempHash["parent_id"] = InvFolder.ParentID.ToString(); {
TempHash["version"] = (Int32) InvFolder.Version; m_log.Warn("[LOGIN]: The root inventory folder could still not be retrieved" +
TempHash["type_default"] = (Int32) InvFolder.DefaultType; " for user ID " + userID);
TempHash["folder_id"] = InvFolder.FolderID.ToString();
AgentInventoryArray.Add(TempHash); AgentInventory userInventory = new AgentInventory();
} userInventory.CreateRootFolder(userID, false);
return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); ArrayList AgentInventoryArray = new ArrayList();
} Hashtable TempHash;
} foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
} {
} TempHash = new Hashtable();
TempHash["name"] = InvFolder.FolderName;
TempHash["parent_id"] = InvFolder.ParentID.ToString();
TempHash["version"] = (Int32) InvFolder.Version;
TempHash["type_default"] = (Int32) InvFolder.DefaultType;
TempHash["folder_id"] = InvFolder.FolderID.ToString();
AgentInventoryArray.Add(TempHash);
}
return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
}
}
}
}

View File

@ -1,348 +1,375 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the * * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.Statistics;
using OpenSim.Framework.UserManagement;
namespace OpenSim.Grid.UserServer
{ namespace OpenSim.Grid.UserServer
public class UserManager : UserManagerBase {
{ public class UserManager : UserManagerBase
public UserManager() {
{ private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
}
/// <summary>
/// Deletes an active agent session
/// <summary> /// </summary>
/// Deletes an active agent session /// <param name="request">The request</param>
/// </summary> /// <param name="path">The path (eg /bork/narf/test)</param>
/// <param name="request">The request</param> /// <param name="param">Parameters sent</param>
/// <param name="path">The path (eg /bork/narf/test)</param> /// <returns>Success "OK" else error</returns>
/// <param name="param">Parameters sent</param> public string RestDeleteUserSessionMethod(string request, string path, string param)
/// <returns>Success "OK" else error</returns> {
public string RestDeleteUserSessionMethod(string request, string path, string param) // TODO! Important!
{
// TODO! Important! return "OK";
}
return "OK";
} /// <summary>
/// Returns an error message that the user could not be found in the database
/// <summary> /// </summary>
/// Returns an error message that the user could not be found in the database /// <returns>XML string consisting of a error element containing individual error(s)</returns>
/// </summary> public XmlRpcResponse CreateUnknownUserErrorResponse()
/// <returns>XML string consisting of a error element containing individual error(s)</returns> {
public XmlRpcResponse CreateUnknownUserErrorResponse() XmlRpcResponse response = new XmlRpcResponse();
{ Hashtable responseData = new Hashtable();
XmlRpcResponse response = new XmlRpcResponse(); responseData["error_type"] = "unknown_user";
Hashtable responseData = new Hashtable(); responseData["error_desc"] = "The user requested is not in the database";
responseData["error_type"] = "unknown_user";
responseData["error_desc"] = "The user requested is not in the database"; response.Value = responseData;
return response;
response.Value = responseData; }
return response;
} public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(LLUUID queryID, List<AvatarPickerAvatar> returnUsers)
{
public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(LLUUID queryID, List<AvatarPickerAvatar> returnUsers) XmlRpcResponse response = new XmlRpcResponse();
{ Hashtable responseData = new Hashtable();
XmlRpcResponse response = new XmlRpcResponse(); // Query Result Information
Hashtable responseData = new Hashtable(); responseData["queryid"] = (string) queryID.ToString();
// Query Result Information responseData["avcount"] = (string) returnUsers.Count.ToString();
responseData["queryid"] = (string) queryID.ToString();
responseData["avcount"] = (string) returnUsers.Count.ToString(); for (int i = 0; i < returnUsers.Count; i++)
{
for (int i = 0; i < returnUsers.Count; i++) responseData["avatarid" + i.ToString()] = returnUsers[i].AvatarID.ToString();
{ responseData["firstname" + i.ToString()] = returnUsers[i].firstName;
responseData["avatarid" + i.ToString()] = returnUsers[i].AvatarID.ToString(); responseData["lastname" + i.ToString()] = returnUsers[i].lastName;
responseData["firstname" + i.ToString()] = returnUsers[i].firstName; }
responseData["lastname" + i.ToString()] = returnUsers[i].lastName; response.Value = responseData;
}
response.Value = responseData; return response;
}
return response;
} public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers)
{
public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers) XmlRpcResponse response = new XmlRpcResponse();
{ Hashtable responseData = new Hashtable();
XmlRpcResponse response = new XmlRpcResponse(); // Query Result Information
Hashtable responseData = new Hashtable();
// Query Result Information responseData["avcount"] = (string)returnUsers.Count.ToString();
responseData["avcount"] = (string)returnUsers.Count.ToString(); for (int i = 0; i < returnUsers.Count; i++)
{
for (int i = 0; i < returnUsers.Count; i++) responseData["ownerID" + i.ToString()] = returnUsers[i].FriendListOwner.UUID.ToString();
{ responseData["friendID" + i.ToString()] = returnUsers[i].Friend.UUID.ToString();
responseData["ownerID" + i.ToString()] = returnUsers[i].FriendListOwner.UUID.ToString(); responseData["ownerPerms" + i.ToString()] = returnUsers[i].FriendListOwnerPerms.ToString();
responseData["friendID" + i.ToString()] = returnUsers[i].Friend.UUID.ToString(); responseData["friendPerms" + i.ToString()] = returnUsers[i].FriendPerms.ToString();
responseData["ownerPerms" + i.ToString()] = returnUsers[i].FriendListOwnerPerms.ToString(); }
responseData["friendPerms" + i.ToString()] = returnUsers[i].FriendPerms.ToString(); response.Value = responseData;
}
response.Value = responseData; return response;
}
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> /// <param name="profile">The user profile</param>
/// <param name="profile">The user profile</param> /// <returns>A string containing an XML Document of the user profile</returns>
/// <returns>A string containing an XML Document of the user profile</returns> public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) {
{ XmlRpcResponse response = new XmlRpcResponse();
XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable();
Hashtable responseData = new Hashtable();
// Account information
// Account information responseData["firstname"] = profile.username;
responseData["firstname"] = profile.username; responseData["lastname"] = profile.surname;
responseData["lastname"] = profile.surname; responseData["uuid"] = profile.UUID.ToString();
responseData["uuid"] = profile.UUID.ToString(); // Server Information
// Server Information responseData["server_inventory"] = profile.userInventoryURI;
responseData["server_inventory"] = profile.userInventoryURI; responseData["server_asset"] = profile.userAssetURI;
responseData["server_asset"] = profile.userAssetURI; // Profile Information
// Profile Information responseData["profile_about"] = profile.profileAboutText;
responseData["profile_about"] = profile.profileAboutText; responseData["profile_firstlife_about"] = profile.profileFirstText;
responseData["profile_firstlife_about"] = profile.profileFirstText; responseData["profile_firstlife_image"] = profile.profileFirstImage.ToString();
responseData["profile_firstlife_image"] = profile.profileFirstImage.ToString(); responseData["profile_can_do"] = profile.profileCanDoMask.ToString();
responseData["profile_can_do"] = profile.profileCanDoMask.ToString(); responseData["profile_want_do"] = profile.profileWantDoMask.ToString();
responseData["profile_want_do"] = profile.profileWantDoMask.ToString(); responseData["profile_image"] = profile.profileImage.ToString();
responseData["profile_image"] = profile.profileImage.ToString(); responseData["profile_created"] = profile.created.ToString();
responseData["profile_created"] = profile.created.ToString(); responseData["profile_lastlogin"] = profile.lastLogin.ToString();
responseData["profile_lastlogin"] = profile.lastLogin.ToString(); // Home region information
// Home region information responseData["home_coordinates_x"] = profile.homeLocation.X.ToString();
responseData["home_coordinates_x"] = profile.homeLocation.X.ToString(); responseData["home_coordinates_y"] = profile.homeLocation.Y.ToString();
responseData["home_coordinates_y"] = profile.homeLocation.Y.ToString(); responseData["home_coordinates_z"] = profile.homeLocation.Z.ToString();
responseData["home_coordinates_z"] = profile.homeLocation.Z.ToString();
responseData["home_region"] = profile.homeRegion.ToString();
responseData["home_region"] = profile.homeRegion.ToString();
responseData["home_look_x"] = profile.homeLookAt.X.ToString();
responseData["home_look_x"] = profile.homeLookAt.X.ToString(); responseData["home_look_y"] = profile.homeLookAt.Y.ToString();
responseData["home_look_y"] = profile.homeLookAt.Y.ToString(); responseData["home_look_z"] = profile.homeLookAt.Z.ToString();
responseData["home_look_z"] = profile.homeLookAt.Z.ToString(); response.Value = responseData;
response.Value = responseData;
return response;
return response; }
}
#region XMLRPC User Methods
#region XMLRPC User Methods
public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request)
public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) {
{ XmlRpcResponse response = new XmlRpcResponse();
XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable) request.Params[0];
Hashtable requestData = (Hashtable) request.Params[0]; List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>();
List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>(); LLUUID queryID = new LLUUID(LLUUID.Zero.ToString());
LLUUID queryID = new LLUUID(LLUUID.Zero.ToString());
if (requestData.Contains("avquery") && requestData.Contains("queryid"))
if (requestData.Contains("avquery") && requestData.Contains("queryid")) {
{ queryID = new LLUUID((string) requestData["queryid"]);
queryID = new LLUUID((string) requestData["queryid"]); returnAvatar = GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]);
returnAvatar = GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]); }
}
Console.WriteLine("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]);
Console.WriteLine("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]); return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar);
return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); }
}
public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request)
public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) {
{ XmlRpcResponse response = new XmlRpcResponse();
XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0];
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable();
Hashtable responseData = new Hashtable(); string returnString = "FALSE";
string returnString = "FALSE"; // Query Result Information
// Query Result Information
if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms"))
if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) {
{ // UserManagerBase.AddNewuserFriend
// UserManagerBase.AddNewuserFriend AddNewUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"]));
AddNewUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); returnString = "TRUE";
returnString = "TRUE"; }
} responseData["returnString"] = returnString;
responseData["returnString"] = returnString; response.Value = responseData;
response.Value = responseData; return response;
return response; }
}
public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request)
public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request) {
{ XmlRpcResponse response = new XmlRpcResponse();
XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0];
Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable();
Hashtable responseData = new Hashtable(); string returnString = "FALSE";
string returnString = "FALSE"; // Query Result Information
// Query Result Information
if (requestData.Contains("ownerID") && requestData.Contains("friendID"))
if (requestData.Contains("ownerID") && requestData.Contains("friendID")) {
{ // UserManagerBase.AddNewuserFriend
// UserManagerBase.AddNewuserFriend RemoveUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]));
RemoveUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"])); returnString = "TRUE";
returnString = "TRUE"; }
} responseData["returnString"] = returnString;
responseData["returnString"] = returnString; response.Value = responseData;
response.Value = responseData; return response;
return response; }
} public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request)
{
public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) XmlRpcResponse response = new XmlRpcResponse();
{ Hashtable requestData = (Hashtable)request.Params[0];
XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable();
Hashtable requestData = (Hashtable)request.Params[0]; string returnString = "FALSE";
Hashtable responseData = new Hashtable();
string returnString = "FALSE"; if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms"))
{
UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"]));
// UserManagerBase.
if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) returnString = "TRUE";
{ }
UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); responseData["returnString"] = returnString;
// UserManagerBase. response.Value = responseData;
returnString = "TRUE"; return response;
} }
responseData["returnString"] = returnString;
response.Value = responseData; public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request)
return response; {
} XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request) Hashtable responseData = new Hashtable();
{
XmlRpcResponse response = new XmlRpcResponse(); List<FriendListItem> returndata = new List<FriendListItem>();
Hashtable requestData = (Hashtable)request.Params[0];
Hashtable responseData = new Hashtable(); if (requestData.Contains("ownerID"))
{
List<FriendListItem> returndata = new List<FriendListItem>(); returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"]));
}
return FriendListItemListtoXmlRPCResponse(returndata);
if (requestData.Contains("ownerID")) }
{
returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"])); public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
} {
XmlRpcResponse response = new XmlRpcResponse();
return FriendListItemListtoXmlRPCResponse(returndata); Hashtable requestData = (Hashtable) request.Params[0];
} UserProfileData userProfile;
if (requestData.Contains("avatar_name"))
public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) {
{ string query = (string) requestData["avatar_name"];
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable) request.Params[0]; Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
UserProfileData userProfile;
if (requestData.Contains("avatar_name")) string[] querysplit;
{ querysplit = query.Split(' ');
string query = (string) requestData["avatar_name"];
if (querysplit.Length == 2)
Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); {
userProfile = GetUserProfile(querysplit[0], querysplit[1], "");
string[] querysplit; if (userProfile == null)
querysplit = query.Split(' '); {
return CreateUnknownUserErrorResponse();
if (querysplit.Length == 2) }
{ }
userProfile = GetUserProfile(querysplit[0], querysplit[1], ""); else
if (userProfile == null) {
{ return CreateUnknownUserErrorResponse();
return CreateUnknownUserErrorResponse(); }
} }
} else
else {
{ return CreateUnknownUserErrorResponse();
return CreateUnknownUserErrorResponse(); }
}
} return ProfileToXmlRPCResponse(userProfile);
else }
{
return CreateUnknownUserErrorResponse(); public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request)
} {
XmlRpcResponse response = new XmlRpcResponse();
return ProfileToXmlRPCResponse(userProfile); Hashtable requestData = (Hashtable) request.Params[0];
} UserProfileData userProfile;
//CFK: this clogs the UserServer log and is not necessary at this time.
public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) //CFK: Console.WriteLine("METHOD BY UUID CALLED");
{ if (requestData.Contains("avatar_uuid"))
XmlRpcResponse response = new XmlRpcResponse(); {
Hashtable requestData = (Hashtable) request.Params[0];
UserProfileData userProfile; LLUUID guess = new LLUUID();
//CFK: this clogs the UserServer log and is not necessary at this time. try
//CFK: Console.WriteLine("METHOD BY UUID CALLED"); {
if (requestData.Contains("avatar_uuid")) guess = new LLUUID((string)requestData["avatar_uuid"]);
{ //userProfile = GetUserProfile(guess);
string authAddr;
LLUUID guess = new LLUUID(); if (requestData["AuthenticationAddress"] == null)
try authAddr = "";
{ else
guess = new LLUUID((string)requestData["avatar_uuid"]); authAddr = requestData["AuthenticationAddress"].ToString();
//userProfile = GetUserProfile(guess); userProfile = GetUserProfile(guess, authAddr);
string authAddr; }
if (requestData["AuthenticationAddress"] == null) catch (FormatException)
authAddr = ""; {
else return CreateUnknownUserErrorResponse();
authAddr = requestData["AuthenticationAddress"].ToString(); }
userProfile = GetUserProfile(guess, authAddr); catch (NullReferenceException)
} {
catch (FormatException) Console.WriteLine("NullReferenceException occured");
{ return CreateUnknownUserErrorResponse();
return CreateUnknownUserErrorResponse(); }
}
catch (NullReferenceException) if (userProfile == null)
{ {
Console.WriteLine("NullReferenceException occured"); return CreateUnknownUserErrorResponse();
return CreateUnknownUserErrorResponse(); }
} }
else
if (userProfile == null) {
{ return CreateUnknownUserErrorResponse();
return CreateUnknownUserErrorResponse(); }
}
} return ProfileToXmlRPCResponse(userProfile);
else }
{
return CreateUnknownUserErrorResponse(); public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request)
} {
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
return ProfileToXmlRPCResponse(userProfile);
} UserProfileData userProfile;
#endregion if (requestData.Contains("avatar_uuid"))
{
public override UserProfileData SetupMasterUser(string firstName, string lastName) try
{ {
throw new Exception("The method or operation is not implemented."); LLUUID userUUID = new LLUUID((string)requestData["avatar_uuid"]);
} LLUUID RegionID = new LLUUID((string)requestData["region_uuid"]);
ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) float posx = (float)Convert.ToDecimal((string)requestData["region_pos_x"]);
{ float posy = (float)Convert.ToDecimal((string)requestData["region_pos_y"]);
throw new Exception("The method or operation is not implemented."); float posz = (float)Convert.ToDecimal((string)requestData["region_pos_z"]);
}
LogOffUser(userUUID, RegionID, regionhandle, posx, posy, posz);
public override UserProfileData SetupMasterUser(LLUUID uuid) }
{ catch (FormatException)
throw new Exception("The method or operation is not implemented."); {
} m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params");
} return response;
} }
}
else
{
return CreateUnknownUserErrorResponse();
}
return response;
}
#endregion
public override UserProfileData SetupMasterUser(string firstName, string lastName)
{
throw new Exception("The method or operation is not implemented.");
}
public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
{
throw new Exception("The method or operation is not implemented.");
}
public override UserProfileData SetupMasterUser(LLUUID uuid)
{
throw new Exception("The method or operation is not implemented.");
}
}
}