This changeset is the step 1 of 2 in refactoring

OpenSim.Region.Environment into a "framework" part and a modules only
part. This first changeset refactors OpenSim.Region.Environment.Scenes,
OpenSim.Region.Environment.Interfaces, and OpenSim.Region.Interfaces
into OpenSim.Region.Framework.{Interfaces,Scenes} leaving only region
modules in OpenSim.Region.Environment.

The next step will be to move region modules up from
OpenSim.Region.Environment.Modules to OpenSim.Region.CoreModules and
then sort out which modules are really core modules and which should
move out to forge.

I've been very careful to NOT BREAK anything. i hope i've
succeeded. as this is the work of a whole week i hope i managed to
keep track with the applied patches of the last week --- could any of
you that did check in stuff have a look at whether it survived? thx!
This commit is contained in:
Dr Scofield
2009-02-06 16:55:34 +00:00
parent 3bc6eb1ff0
commit 9b66108081
327 changed files with 1102 additions and 919 deletions

View File

@@ -33,8 +33,8 @@ using OpenMetaverse;
using OpenMetaverse.Imaging;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
{

View File

@@ -31,8 +31,8 @@ using System.Collections.Generic;
using System.Text.RegularExpressions;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using log4net;
using Nini.Config;
using DotNetOpenMail;

View File

@@ -35,8 +35,8 @@ using OpenMetaverse;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using System.Collections;
/*****************************************************
@@ -84,14 +84,14 @@ using System.Collections;
namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
{
public class HttpRequestModule : IRegionModule, IHttpRequests
public class HttpRequestModule : IRegionModule, IHttpRequestModule
{
private object HttpListLock = new object();
private int httpTimeout = 30000;
private string m_name = "HttpScriptRequests";
private string m_proxyurl = "";
private string m_proxyexcepts = "";
private string m_proxyurl = "";
private string m_proxyexcepts = "";
// <request id, HttpRequestClass>
private Dictionary<UUID, HttpRequestClass> m_pendingRequests;
@@ -102,7 +102,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
{
}
#region IHttpRequests Members
#region IHttpRequestModule Members
public UUID MakeHttpRequest(string url, string parameters, string body)
{
@@ -125,22 +125,22 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
{
switch (Int32.Parse(parms[i]))
{
case HttpRequestClass.HTTP_METHOD:
case (int)HttpRequestConstants.HTTP_METHOD:
htc.httpMethod = parms[i + 1];
htc.HttpMethod = parms[i + 1];
break;
case HttpRequestClass.HTTP_MIMETYPE:
case (int)HttpRequestConstants.HTTP_MIMETYPE:
htc.httpMIMEType = parms[i + 1];
htc.HttpMIMEType = parms[i + 1];
break;
case HttpRequestClass.HTTP_BODY_MAXLENGTH:
case (int)HttpRequestConstants.HTTP_BODY_MAXLENGTH:
// TODO implement me
break;
case HttpRequestClass.HTTP_VERIFY_CERT:
case (int)HttpRequestConstants.HTTP_VERIFY_CERT:
// TODO implement me
break;
@@ -148,22 +148,22 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
}
}
htc.localID = localID;
htc.itemID = itemID;
htc.url = url;
htc.reqID = reqID;
htc.httpTimeout = httpTimeout;
htc.outbound_body = body;
htc.response_headers = headers;
htc.proxyurl = m_proxyurl;
htc.proxyexcepts = m_proxyexcepts;
htc.LocalID = localID;
htc.ItemID = itemID;
htc.Url = url;
htc.ReqID = reqID;
htc.HttpTimeout = httpTimeout;
htc.OutboundBody = body;
htc.ResponseHeaders = headers;
htc.proxyurl = m_proxyurl;
htc.proxyexcepts = m_proxyexcepts;
lock (HttpListLock)
{
m_pendingRequests.Add(reqID, htc);
}
htc.process();
htc.Process();
return reqID;
}
@@ -193,7 +193,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
* it will need some refactoring and this works 'enough' right now
*/
public HttpRequestClass GetNextCompletedRequest()
public IServiceRequest GetNextCompletedRequest()
{
lock (HttpListLock)
{
@@ -203,7 +203,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
if (m_pendingRequests.TryGetValue(luid, out tmpReq))
{
if (tmpReq.finished)
if (tmpReq.Finished)
{
return tmpReq;
}
@@ -235,10 +235,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
{
m_scene = scene;
m_scene.RegisterModuleInterface<IHttpRequests>(this);
m_scene.RegisterModuleInterface<IHttpRequestModule>(this);
m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
}
@@ -264,45 +264,64 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
#endregion
}
public class HttpRequestClass
public class HttpRequestClass: IServiceRequest
{
// Constants for parameters
public const int HTTP_BODY_MAXLENGTH = 2;
public const int HTTP_METHOD = 0;
public const int HTTP_MIMETYPE = 1;
public const int HTTP_VERIFY_CERT = 3;
public bool finished;
public int httpBodyMaxLen = 2048; // not implemented
// public const int HTTP_BODY_MAXLENGTH = 2;
// public const int HTTP_METHOD = 0;
// public const int HTTP_MIMETYPE = 1;
// public const int HTTP_VERIFY_CERT = 3;
private bool _finished;
public bool Finished
{
get { return _finished; }
}
// public int HttpBodyMaxLen = 2048; // not implemented
// Parameter members and default values
public string httpMethod = "GET";
public string httpMIMEType = "text/plain;charset=utf-8";
public string HttpMethod = "GET";
public string HttpMIMEType = "text/plain;charset=utf-8";
public int HttpTimeout;
// public bool HttpVerifyCert = true; // not implemented
private Thread httpThread;
public int httpTimeout;
public bool httpVerifyCert = true; // not implemented
// Request info
public UUID itemID;
public uint localID;
public DateTime next;
public string outbound_body;
public UUID reqID;
public HttpWebRequest request;
public string response_body;
public List<string> response_metadata;
public Dictionary<string, string> response_headers;
public int status;
public string url;
private UUID _itemID;
public UUID ItemID
{
get { return _itemID; }
set { _itemID = value; }
}
private uint _localID;
public uint LocalID
{
get { return _localID; }
set { _localID = value; }
}
public DateTime Next;
public string proxyurl;
public string proxyexcepts;
public string OutboundBody;
private UUID _reqID;
public UUID ReqID
{
get { return _reqID; }
set { _reqID = value; }
}
public HttpWebRequest Request;
public string ResponseBody;
public List<string> ResponseMetadata;
public Dictionary<string, string> ResponseHeaders;
public int Status;
public string Url;
public void process()
public void Process()
{
httpThread = new Thread(SendRequest);
httpThread.Name = "HttpRequestThread";
httpThread.Priority = ThreadPriority.BelowNormal;
httpThread.IsBackground = true;
finished = false;
_finished = false;
httpThread.Start();
ThreadTracker.Add(httpThread);
}
@@ -322,37 +341,35 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
try
{
request = (HttpWebRequest)
WebRequest.Create(url);
request.Method = httpMethod;
request.ContentType = httpMIMEType;
if (proxyurl.Length > 0)
{
if (proxyexcepts.Length > 0) {
string[] elist = proxyexcepts.Split(';');
request.Proxy = new WebProxy(proxyurl,true,elist);
} else {
request.Proxy = new WebProxy(proxyurl,true);
}
}
Request = (HttpWebRequest) WebRequest.Create(Url);
Request.Method = HttpMethod;
Request.ContentType = HttpMIMEType;
if (proxyurl.Length > 0)
{
if (proxyexcepts.Length > 0) {
string[] elist = proxyexcepts.Split(';');
Request.Proxy = new WebProxy(proxyurl,true,elist);
} else {
Request.Proxy = new WebProxy(proxyurl,true);
}
}
foreach (KeyValuePair<string, string> entry in response_headers)
request.Headers[entry.Key] = entry.Value;
foreach (KeyValuePair<string, string> entry in ResponseHeaders)
Request.Headers[entry.Key] = entry.Value;
// Encode outbound data
if (outbound_body.Length > 0) {
byte[] data = Encoding.UTF8.GetBytes(outbound_body);
if (OutboundBody.Length > 0) {
byte[] data = Encoding.UTF8.GetBytes(OutboundBody);
request.ContentLength = data.Length;
Stream bstream = request.GetRequestStream();
Request.ContentLength = data.Length;
Stream bstream = Request.GetRequestStream();
bstream.Write(data, 0, data.Length);
bstream.Close();
}
request.Timeout = httpTimeout;
Request.Timeout = HttpTimeout;
// execute the request
response = (HttpWebResponse)
request.GetResponse();
response = (HttpWebResponse) Request.GetResponse();
Stream resStream = response.GetResponseStream();
@@ -372,23 +389,23 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
}
} while (count > 0); // any more data to read?
response_body = sb.ToString();
ResponseBody = sb.ToString();
}
catch (Exception e)
{
if (e is WebException && ((WebException)e).Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
status = (int)webRsp.StatusCode;
response_body = webRsp.StatusDescription;
Status = (int)webRsp.StatusCode;
ResponseBody = webRsp.StatusDescription;
}
else
{
status = (int)OSHttpStatusCode.ClientErrorJoker;
response_body = e.Message;
Status = (int)OSHttpStatusCode.ClientErrorJoker;
ResponseBody = e.Message;
}
finished = true;
_finished = true;
return;
}
finally
@@ -397,8 +414,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
response.Close();
}
status = (int)OSHttpStatusCode.SuccessOk;
finished = true;
Status = (int)OSHttpStatusCode.SuccessOk;
_finished = true;
}
public void Stop()

View File

@@ -32,8 +32,8 @@ using System.Net;
using OpenMetaverse;
using OpenMetaverse.Imaging;
using Nini.Config;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
{

View File

@@ -34,8 +34,8 @@ using System.Net;
using OpenMetaverse;
using OpenMetaverse.Imaging;
using Nini.Config;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
//using Cairo;

View File

@@ -31,8 +31,8 @@ using System.Collections.Generic;
using OpenMetaverse;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
// using log4net;
// using System.Reflection;
@@ -313,7 +313,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
/// Pop the first availlable listen event from the queue
/// </summary>
/// <returns>ListenerInfo with filter filled in</returns>
public ListenerInfo GetNextMessage()
public IWorldCommListenerInfo GetNextMessage()
{
ListenerInfo li = null;
@@ -608,7 +608,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
}
}
public class ListenerInfo
public class ListenerInfo: IWorldCommListenerInfo
{
private bool m_active; // Listener is active or not
private int m_handle; // Assigned handle of this listener

View File

@@ -37,8 +37,8 @@ using Nini.Config;
using Nwc.XmlRpc;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
/*****************************************************
*
@@ -302,7 +302,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
}
}
public RPCRequestInfo GetNextCompletedRequest()
public IXmlRpcRequestInfo GetNextCompletedRequest()
{
if (m_rpcPending != null)
{
@@ -345,10 +345,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
localID, itemID, channel, dest, idata, sdata
);
m_pendingSRDResponses.Add(req.GetReqID(), req);
return req.process();
req.Process();
return req.ReqID;
}
public SendRemoteDataRequest GetNextCompletedSRDRequest()
public IServiceRequest GetNextCompletedSRDRequest()
{
if (m_pendingSRDResponses != null)
{
@@ -360,7 +361,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
if (m_pendingSRDResponses.TryGetValue(luid, out tmpReq))
{
if (tmpReq.finished)
if (tmpReq.Finished)
return tmpReq;
}
}
@@ -389,7 +390,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{
foreach (SendRemoteDataRequest li in m_pendingSRDResponses.Values)
{
if (li.m_itemID.Equals(itemID))
if (li.ItemID.Equals(itemID))
m_pendingSRDResponses.Remove(li.GetReqID());
}
}
@@ -460,7 +461,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
}
}
public class RPCRequestInfo
public class RPCRequestInfo: IXmlRpcRequestInfo
{
private UUID m_ChannelKey;
private string m_IntVal;
@@ -575,45 +576,64 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
}
}
public class SendRemoteDataRequest
public class SendRemoteDataRequest: IServiceRequest
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public string channel;
public string destURL;
public bool finished;
public string Channel;
public string DestURL;
private bool _finished;
public bool Finished
{
get { return _finished; }
set { _finished = value; }
}
private Thread httpThread;
public int idata;
public UUID m_itemID;
public uint m_localID;
public UUID reqID;
public XmlRpcRequest request;
public int response_idata;
public string response_sdata;
public string sdata;
public int Idata;
private UUID _itemID;
public UUID ItemID
{
get { return _itemID; }
set { _itemID = value; }
}
private uint _localID;
public uint LocalID
{
get { return _localID; }
set { _localID = value; }
}
private UUID _reqID;
public UUID ReqID
{
get { return _reqID; }
set { _reqID = value; }
}
public XmlRpcRequest Request;
public int ResponseIdata;
public string ResponseSdata;
public string Sdata;
public SendRemoteDataRequest(uint localID, UUID itemID, string channel, string dest, int idata, string sdata)
{
this.channel = channel;
destURL = dest;
this.idata = idata;
this.sdata = sdata;
m_itemID = itemID;
m_localID = localID;
this.Channel = channel;
DestURL = dest;
this.Idata = idata;
this.Sdata = sdata;
ItemID = itemID;
LocalID = localID;
reqID = UUID.Random();
ReqID = UUID.Random();
}
public UUID process()
public void Process()
{
httpThread = new Thread(SendRequest);
httpThread.Name = "HttpRequestThread";
httpThread.Priority = ThreadPriority.BelowNormal;
httpThread.IsBackground = true;
finished = false;
_finished = false;
httpThread.Start();
ThreadTracker.Add(httpThread);
return reqID;
}
/*
@@ -629,21 +649,21 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
// if not, use as method name
UUID parseUID;
string mName = "llRemoteData";
if ((channel != null) && (channel != ""))
if (!UUID.TryParse(channel, out parseUID))
mName = channel;
if ((Channel != null) && (Channel != ""))
if (!UUID.TryParse(Channel, out parseUID))
mName = Channel;
else
param["Channel"] = channel;
param["Channel"] = Channel;
param["StringValue"] = sdata;
param["IntValue"] = Convert.ToString(idata);
param["StringValue"] = Sdata;
param["IntValue"] = Convert.ToString(Idata);
ArrayList parameters = new ArrayList();
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest(mName, parameters);
try
{
XmlRpcResponse resp = req.Send(destURL, 30000);
XmlRpcResponse resp = req.Send(DestURL, 30000);
if (resp != null)
{
Hashtable respParms;
@@ -660,31 +680,31 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{
if (respParms.Contains("StringValue"))
{
sdata = (string) respParms["StringValue"];
Sdata = (string) respParms["StringValue"];
}
if (respParms.Contains("IntValue"))
{
idata = Convert.ToInt32((string) respParms["IntValue"]);
Idata = Convert.ToInt32((string) respParms["IntValue"]);
}
if (respParms.Contains("faultString"))
{
sdata = (string) respParms["faultString"];
Sdata = (string) respParms["faultString"];
}
if (respParms.Contains("faultCode"))
{
idata = Convert.ToInt32(respParms["faultCode"]);
Idata = Convert.ToInt32(respParms["faultCode"]);
}
}
}
}
catch (Exception we)
{
sdata = we.Message;
Sdata = we.Message;
m_log.Warn("[SendRemoteDataRequest]: Request failed");
m_log.Warn(we.StackTrace);
}
finished = true;
_finished = true;
}
public void Stop()
@@ -700,7 +720,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
public UUID GetReqID()
{
return reqID;
return ReqID;
}
}
}