Merge commit 'eda770e978c09c756d15ba62dbbf6ee34a61b2f5' into bigmerge

Conflicts:
	OpenSim/Region/Framework/Scenes/Scene.cs
avinationmerge
Melanie 2011-12-08 03:24:25 +00:00
commit 50aa89dae6
19 changed files with 231 additions and 108 deletions

View File

@ -135,16 +135,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController
availableMethods["admin_restart"] = XmlRpcRestartMethod;
availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod;
// Agent management
availableMethods["admin_teleport_agent"] = XmlRpcTeleportAgentMethod;
// User management
availableMethods["admin_create_user"] = XmlRpcCreateUserMethod;
availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod;
availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod;
availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod;
// Region state management
availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod;
availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod;
availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod;
availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod;
// Estate access list management
availableMethods["admin_acl_clear"] = XmlRpcAccessListClear;
availableMethods["admin_acl_add"] = XmlRpcAccessListAdd;
@ -3073,6 +3079,112 @@ namespace OpenSim.ApplicationPlugins.RemoteController
return response;
}
public XmlRpcResponse XmlRpcTeleportAgentMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
try
{
responseData["success"] = true;
Hashtable requestData = (Hashtable)request.Params[0];
CheckStringParameters(request, new string[] {"password"});
FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString());
UUID agentId;
string regionName = null;
Vector3 pos, lookAt;
bool agentSpecified = false;
ScenePresence sp = null;
if (requestData.Contains("agent_first_name") && requestData.Contains("agent_last_name"))
{
string firstName = requestData["agent_first_name"].ToString();
string lastName = requestData["agent_last_name"].ToString();
m_application.SceneManager.TryGetRootScenePresenceByName(firstName, lastName, out sp);
if (sp == null)
throw new Exception(
string.Format(
"No agent found with agent_first_name {0} and agent_last_name {1}", firstName, lastName));
}
else if (requestData.Contains("agent_id"))
{
string rawAgentId = (string)requestData["agent_id"];
if (!UUID.TryParse(rawAgentId, out agentId))
throw new Exception(string.Format("agent_id {0} does not have the correct id format", rawAgentId));
m_application.SceneManager.TryGetRootScenePresence(agentId, out sp);
if (sp == null)
throw new Exception(string.Format("No agent with agent_id {0} found in this simulator", agentId));
}
else
{
throw new Exception("No agent_id or agent_first_name and agent_last_name parameters specified");
}
if (requestData.Contains("region_name"))
regionName = (string)requestData["region_name"];
pos.X = ParseFloat(requestData, "pos_x", sp.AbsolutePosition.X);
pos.Y = ParseFloat(requestData, "pos_y", sp.AbsolutePosition.Y);
pos.Z = ParseFloat(requestData, "pos_z", sp.AbsolutePosition.Z);
lookAt.X = ParseFloat(requestData, "lookat_x", sp.Lookat.X);
lookAt.Y = ParseFloat(requestData, "lookat_y", sp.Lookat.Y);
lookAt.Z = ParseFloat(requestData, "lookat_z", sp.Lookat.Z);
sp.Scene.RequestTeleportLocation(
sp.ControllingClient, regionName, pos, lookAt, (uint)Constants.TeleportFlags.ViaLocation);
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN]: admin_teleport_agent exception: {0}{1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
}
finally
{
response.Value = responseData;
}
return response;
}
/// <summary>
/// Parse a float with the given parameter name from a request data hash table.
/// </summary>
/// <remarks>
/// Will throw an exception if parameter is not a float.
/// Will not throw if parameter is not found, passes back default value instead.
/// </remarks>
/// <param name="requestData"></param>
/// <param name="paramName"></param>
/// <param name="defaultVal"></param>
/// <returns></returns>
private static float ParseFloat(Hashtable requestData, string paramName, float defaultVal)
{
if (requestData.Contains(paramName))
{
string rawVal = (string)requestData[paramName];
float val;
if (!float.TryParse(rawVal, out val))
throw new Exception(string.Format("{0} {1} is not a valid float", paramName, rawVal));
else
return val;
}
else
{
return defaultVal;
}
}
private static void CheckStringParameters(XmlRpcRequest request, string[] param)
{
Hashtable requestData = (Hashtable) request.Params[0];
@ -3252,6 +3364,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
return false;
}
}
private bool LoadHeightmap(string file, UUID regionID)
{
m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file);

View File

@ -51,11 +51,10 @@ namespace OpenSim.Framework.Capabilities
/// supplied BaseHttpServer.
/// </summary>
/// <param name="httpListener">base HTTP server</param>
/// <param name="httpListenerHostname">host name of the HTTP
/// server</param>
/// <param name="httpListenerHostname">host name of the HTTP server</param>
/// <param name="httpListenerPort">HTTP port</param>
public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort)
: this (httpListener,httpListenerHostname,httpListenerPort, false)
: this(httpListener,httpListenerHostname,httpListenerPort, false)
{
}
@ -88,44 +87,52 @@ namespace OpenSim.Framework.Capabilities
/// handler to be removed</param>
public void Remove(string capsName)
{
m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path);
m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path);
m_capsHandlers.Remove(capsName);
lock (m_capsHandlers)
{
m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path);
m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path);
m_capsHandlers.Remove(capsName);
}
}
public bool ContainsCap(string cap)
{
return m_capsHandlers.ContainsKey(cap);
lock (m_capsHandlers)
return m_capsHandlers.ContainsKey(cap);
}
/// <summary>
/// The indexer allows us to treat the CapsHandlers object
/// in an intuitive dictionary like way.
/// </summary>
/// <Remarks>
/// <remarks>
/// The indexer will throw an exception when you try to
/// retrieve a cap handler for a cap that is not contained in
/// CapsHandlers.
/// </Remarks>
/// </remarks>
public IRequestHandler this[string idx]
{
get
{
return m_capsHandlers[idx];
lock (m_capsHandlers)
return m_capsHandlers[idx];
}
set
{
if (m_capsHandlers.ContainsKey(idx))
lock (m_capsHandlers)
{
m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path);
m_capsHandlers.Remove(idx);
if (m_capsHandlers.ContainsKey(idx))
{
m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path);
m_capsHandlers.Remove(idx);
}
if (null == value) return;
m_capsHandlers[idx] = value;
m_httpListener.AddStreamHandler(value);
}
if (null == value) return;
m_capsHandlers[idx] = value;
m_httpListener.AddStreamHandler(value);
}
}
@ -137,9 +144,12 @@ namespace OpenSim.Framework.Capabilities
{
get
{
string[] __keys = new string[m_capsHandlers.Keys.Count];
m_capsHandlers.Keys.CopyTo(__keys, 0);
return __keys;
lock (m_capsHandlers)
{
string[] __keys = new string[m_capsHandlers.Keys.Count];
m_capsHandlers.Keys.CopyTo(__keys, 0);
return __keys;
}
}
}
@ -157,15 +167,19 @@ namespace OpenSim.Framework.Capabilities
protocol = "https://";
string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString();
foreach (string capsName in m_capsHandlers.Keys)
{
if (excludeSeed && "SEED" == capsName)
continue;
caps[capsName] = baseUrl + m_capsHandlers[capsName].Path;
lock (m_capsHandlers)
{
foreach (string capsName in m_capsHandlers.Keys)
{
if (excludeSeed && "SEED" == capsName)
continue;
caps[capsName] = baseUrl + m_capsHandlers[capsName].Path;
}
}
return caps;
}
}
}
}

View File

@ -77,8 +77,6 @@ namespace OpenSim.Capabilities.Handlers
{
try
{
// m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName);
string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");

View File

@ -232,9 +232,8 @@ namespace OpenSim.Framework.Console
string uri = "/ReadResponses/" + sessionID.ToString() + "/";
m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll,
new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents,
sessionID));
m_Server.AddPollServiceHTTPHandler(
uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID));
XmlDocument xmldoc = new XmlDocument();
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
@ -266,11 +265,6 @@ namespace OpenSim.Framework.Console
return reply;
}
private Hashtable HandleHttpPoll(Hashtable request)
{
return new Hashtable();
}
private Hashtable HandleHttpCloseSession(Hashtable request)
{
DoExpire();

View File

@ -90,9 +90,9 @@ namespace OpenSim.Framework
/// <summary>
/// Is the agent denoted by the given agentID a child presence in this scene?
/// </summary>
///
/// <remarks>
/// Used by ClientView when a 'kick everyone' or 'estate message' occurs
///
/// </remarks>
/// <param name="avatarID">AvatarID to lookup</param>
/// <returns>true if the presence is a child agent, false if the presence is a root exception</returns>
/// <exception cref="System.NullReferenceException">

View File

@ -227,21 +227,17 @@ namespace OpenSim.Framework.Servers.HttpServer
return new List<string>(m_HTTPHandlers.Keys);
}
public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args)
public bool AddPollServiceHTTPHandler(string methodName, PollServiceEventArgs args)
{
bool pollHandlerResult = false;
lock (m_pollHandlers)
{
if (!m_pollHandlers.ContainsKey(methodName))
{
m_pollHandlers.Add(methodName,args);
pollHandlerResult = true;
m_pollHandlers.Add(methodName, args);
return true;
}
}
if (pollHandlerResult)
return AddHTTPHandler(methodName, handler);
return false;
}
@ -1871,8 +1867,6 @@ namespace OpenSim.Framework.Servers.HttpServer
{
lock (m_pollHandlers)
m_pollHandlers.Remove(path);
RemoveHTTPHandler(httpMethod, path);
}
public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler)

View File

@ -77,8 +77,8 @@ namespace OpenSim.Framework.Servers.HttpServer
/// true if the handler was successfully registered, false if a handler with the same name already existed.
/// </returns>
bool AddHTTPHandler(string methodName, GenericHTTPMethod handler);
bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args);
bool AddPollServiceHTTPHandler(string methodName, PollServiceEventArgs args);
/// <summary>
/// Adds a LLSD handler, yay.

View File

@ -62,6 +62,7 @@ namespace OpenSim
// These are the names of the plugin-points extended by this
// class during system startup.
//
private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache";
private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient";

View File

@ -361,7 +361,6 @@ namespace OpenSim.Region.ClientStack.Linden
// This will persist this beyond the expiry of the caps handlers
MainServer.Instance.AddPollServiceHTTPHandler(
capsBase + EventQueueGetUUID.ToString() + "/",
EventQueuePoll,
new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
Random rnd = new Random(Environment.TickCount);
@ -578,11 +577,6 @@ namespace OpenSim.Region.ClientStack.Linden
// return responsedata;
// }
public Hashtable EventQueuePoll(Hashtable request)
{
return new Hashtable();
}
// public Hashtable EventQueuePath2(Hashtable request)
// {
// string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");

View File

@ -104,7 +104,7 @@ namespace OpenSim.Region.ClientStack.Linden
"UploadBakedTexture",
new RestStreamHandler(
"POST",
"/CAPS/" + m_uploadBakedTexturePath,
"/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath,
new UploadBakedTextureHandler(
caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture));
}

View File

@ -91,11 +91,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
get { return null; }
}
private Hashtable HandleHttpPoll(Hashtable request)
{
return new Hashtable();
}
public string Name
{
get { return "UrlModule"; }
@ -171,9 +166,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
string uri = "/lslhttp/" + urlcode.ToString();
m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
urlcode));
m_HttpServer.AddPollServiceHTTPHandler(
uri,
new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode));
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
}
@ -213,9 +208,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
string uri = "/lslhttps/" + urlcode.ToString() + "/";
m_HttpsServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
urlcode));
m_HttpsServer.AddPollServiceHTTPHandler(
uri,
new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode));
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
}

View File

@ -3241,36 +3241,37 @@ namespace OpenSim.Region.Framework.Scenes
// Avatar is already disposed :/
}
m_log.Debug("[Scene] Beginning OnRemovePresence");
m_eventManager.TriggerOnRemovePresence(agentID);
m_log.Debug("[Scene] Finished OnRemovePresence");
if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
AttachmentsModule.SaveChangedAttachments(avatar);
if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
AttachmentsModule.SaveChangedAttachments(avatar);
ForEachClient(
delegate(IClientAPI client)
{
//We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); }
catch (NullReferenceException) { }
});
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
if (agentTransactions != null)
try
{
agentTransactions.RemoveAgentAssetTransactions(agentID);
m_eventManager.TriggerOnRemovePresence(agentID);
if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
AttachmentsModule.SaveChangedAttachments(avatar);
ForEachClient(
delegate(IClientAPI client)
{
//We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); }
catch (NullReferenceException) { }
});
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
if (agentTransactions != null)
{
agentTransactions.RemoveAgentAssetTransactions(agentID);
}
}
finally
{
// Always clean these structures up so that any failure above doesn't cause them to remain in the
// scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
// the same cleanup exception continually.
// TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
// since this would hide the underlying failure and other associated problems.
m_sceneGraph.RemoveScenePresence(agentID);
m_clientManager.Remove(agentID);
}
// Remove the avatar from the scene
m_log.Debug("[Scene] Begin RemoveScenePresence");
m_sceneGraph.RemoveScenePresence(agentID);
m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
m_clientManager.Remove(agentID);
m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
try
{
@ -4390,7 +4391,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="action"></param>
public void ForEachRootScenePresence(Action<ScenePresence> action)
{
if(m_sceneGraph != null)
if (m_sceneGraph != null)
{
m_sceneGraph.ForEachAvatar(action);
}
@ -4470,9 +4471,9 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.GetGroupByPrim(localID);
}
public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
public override bool TryGetScenePresence(UUID agentID, out ScenePresence sp)
{
return m_sceneGraph.TryGetScenePresence(avatarId, out avatar);
return m_sceneGraph.TryGetScenePresence(agentID, out sp);
}
public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)

View File

@ -193,6 +193,12 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
/// <summary>
/// Try to get a scene presence from the scene
/// </summary>
/// <param name="agentID"></param>
/// <param name="scenePresence">null if there is no scene presence with the given agent id</param>
/// <returns>true if there was a scene presence with the given id, false otherwise.</returns>
public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence);
#endregion

View File

@ -545,23 +545,20 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
public bool TryGetAvatarsScene(UUID avatarId, out Scene scene)
public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar)
{
ScenePresence avatar = null;
lock (m_localScenes)
{
foreach (Scene mScene in m_localScenes)
foreach (Scene scene in m_localScenes)
{
if (mScene.TryGetScenePresence(avatarId, out avatar))
{
scene = mScene;
avatar = scene.GetScenePresence(avatarId);
if (avatar != null && !avatar.IsChildAgent)
return true;
}
}
}
scene = null;
avatar = null;
return false;
}
@ -590,6 +587,22 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp)
{
lock (m_localScenes)
{
foreach (Scene scene in m_localScenes)
{
sp = scene.GetScenePresence(firstName, lastName);
if (sp != null && !sp.IsChildAgent)
return true;
}
}
sp = null;
return false;
}
public void ForEachScene(Action<Scene> action)
{
lock (m_localScenes)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.