Whitespace cleanup.

ThreadPoolClientBranch
Jeff Ames 2008-01-10 06:49:29 +00:00
parent a962653e04
commit 5a6fd21a2c
11 changed files with 321 additions and 330 deletions

View File

@ -400,7 +400,7 @@ namespace OpenSim.Framework.Communications.Cache
//Console.WriteLine("asset request " + requestID);
if (!Assets.ContainsKey(requestID))
{
//not found asset
//not found asset
// so request from asset server
if (!RequestedAssets.ContainsKey(requestID))
{

View File

@ -72,7 +72,7 @@ namespace OpenSim.Framework
}
// Copied from LibSL, and added a check to avoid overwriting the
// buffer
// buffer
private void ZeroDecodeCommand(byte[] src, byte[] dest)
{
for (int srcPos = 6, destPos = 6; destPos < 10; ++srcPos)
@ -89,8 +89,8 @@ namespace OpenSim.Framework
{
dest[destPos++] = src[srcPos];
}
}
}
}
}
private PacketType GetType(byte[] bytes)
{

View File

@ -222,7 +222,7 @@ namespace OpenSim.Framework
output.Append(": ");
}
output.Append(CleanString(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1)));
output.Append(CleanString(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1)));
}
else
{
@ -414,30 +414,30 @@ namespace OpenSim.Framework
return lluuid.UUID.ToString("n");
}
public static string CleanString(string input)
{
if(input.Length == 0)
return input;
public static string CleanString(string input)
{
if(input.Length == 0)
return input;
int clip=input.Length;
int clip=input.Length;
// Test for ++ string terminator
int pos=input.IndexOf("\0");
if(pos != -1 && pos < clip)
clip=pos;
// Test for ++ string terminator
int pos=input.IndexOf("\0");
if(pos != -1 && pos < clip)
clip=pos;
// Test for CR
pos=input.IndexOf("\r");
if(pos != -1 && pos < clip)
clip=pos;
// Test for CR
pos=input.IndexOf("\r");
if(pos != -1 && pos < clip)
clip=pos;
// Test for LF
pos=input.IndexOf("\n");
if(pos != -1 && pos < clip)
clip=pos;
// Test for LF
pos=input.IndexOf("\n");
if(pos != -1 && pos < clip)
clip=pos;
// Truncate string before first end-of-line character found
return input.Substring(0, clip);
}
// Truncate string before first end-of-line character found
return input.Substring(0, clip);
}
}
}

View File

@ -48,7 +48,7 @@ namespace OpenGrid.Config.GridConfigDb4o
return new DbGridConfig();
}
}
/// <summary>
/// A DB4o based Gridserver configuration object
/// </summary>
@ -57,15 +57,15 @@ namespace OpenGrid.Config.GridConfigDb4o
/// <summary>
/// The DB4o Database
/// </summary>
private IObjectContainer db;
private IObjectContainer db;
/// <summary>
/// User configuration for the Grid Config interfaces
/// </summary>
public void LoadDefaults()
{
MainLog.Instance.Notice("DbGridConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
// About the grid options
this.GridOwner = MainLog.Instance.CmdPrompt("Grid owner", "OGS development team");
@ -139,7 +139,7 @@ namespace OpenGrid.Config.GridConfigDb4o
MainLog.Instance.Warn("DbGridConfig.cs:InitConfig() - Exception occured");
MainLog.Instance.Warn(e.ToString());
}
// Grid Settings
MainLog.Instance.Verbose("DBGRIDCONFIG", "Grid settings loaded:");
MainLog.Instance.Verbose("DBGRIDCONFIG", "Grid owner: " + this.GridOwner);
@ -158,7 +158,7 @@ namespace OpenGrid.Config.GridConfigDb4o
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to send to sims: " + this.SimSendKey);
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to expect from sims: " + this.SimRecvKey);
}
/// <summary>
/// Closes down the database and releases filesystem locks
/// </summary>

View File

@ -31,14 +31,11 @@ using System;
namespace OpenGridServices.Manager
{
public partial class Connect to grid server : Gtk.Dialog
{
public Connect to grid server()
{
this.Build();
}
}
public partial class Connect to grid server : Gtk.Dialog
{
public Connect to grid server()
{
this.Build();
}
}
}

View File

@ -29,29 +29,26 @@
using Gtk;
using System;
namespace OpenGridServices.Manager {
public partial class ConnectToGridServerDialog : Gtk.Dialog
{
public ConnectToGridServerDialog()
{
this.Build();
}
protected virtual void OnResponse(object o, Gtk.ResponseArgs args)
{
switch(args.ResponseId) {
case Gtk.ResponseType.Ok:
MainClass.PendingOperations.Enqueue("connect_to_gridserver " + this.entry1.Text + " " + this.entry2.Text + " " + this.entry3.Text);
break;
case Gtk.ResponseType.Cancel:
break;
}
this.Hide();
}
}
namespace OpenGridServices.Manager
{
public partial class ConnectToGridServerDialog : Gtk.Dialog
{
public ConnectToGridServerDialog()
{
this.Build();
}
protected virtual void OnResponse(object o, Gtk.ResponseArgs args)
{
switch(args.ResponseId) {
case Gtk.ResponseType.Ok:
MainClass.PendingOperations.Enqueue("connect_to_gridserver " + this.entry1.Text + " " + this.entry2.Text + " " + this.entry3.Text);
break;
case Gtk.ResponseType.Cancel:
break;
}
this.Hide();
}
}
}

View File

@ -37,98 +37,98 @@ using libsecondlife;
namespace OpenGridServices.Manager
{
public class GridServerConnectionManager
{
private string ServerURL;
public LLUUID SessionID;
public bool connected=false;
public RegionBlock[][] WorldMap;
public bool Connect(string GridServerURL, string username, string password)
{
try {
this.ServerURL=GridServerURL;
Hashtable LoginParamsHT = new Hashtable();
LoginParamsHT["username"]=username;
LoginParamsHT["password"]=password;
ArrayList LoginParams = new ArrayList();
LoginParams.Add(LoginParamsHT);
XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
if(GridResp.IsFault) {
connected=false;
return false;
} else {
Hashtable gridrespData = (Hashtable)GridResp.Value;
this.SessionID = new LLUUID((string)gridrespData["session_id"]);
connected=true;
return true;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
connected=false;
return false;
}
}
public void DownloadMap()
{
System.Net.WebClient mapdownloader = new WebClient();
Stream regionliststream = mapdownloader.OpenRead(ServerURL + "/regionlist");
RegionBlock TempRegionData;
XmlDocument doc = new XmlDocument();
public class GridServerConnectionManager
{
private string ServerURL;
public LLUUID SessionID;
public bool connected=false;
public RegionBlock[][] WorldMap;
public bool Connect(string GridServerURL, string username, string password)
{
try {
this.ServerURL=GridServerURL;
Hashtable LoginParamsHT = new Hashtable();
LoginParamsHT["username"]=username;
LoginParamsHT["password"]=password;
ArrayList LoginParams = new ArrayList();
LoginParams.Add(LoginParamsHT);
XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
if(GridResp.IsFault) {
connected=false;
return false;
} else {
Hashtable gridrespData = (Hashtable)GridResp.Value;
this.SessionID = new LLUUID((string)gridrespData["session_id"]);
connected=true;
return true;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
connected=false;
return false;
}
}
public void DownloadMap()
{
System.Net.WebClient mapdownloader = new WebClient();
Stream regionliststream = mapdownloader.OpenRead(ServerURL + "/regionlist");
RegionBlock TempRegionData;
XmlDocument doc = new XmlDocument();
doc.Load(regionliststream);
regionliststream.Close();
XmlNode rootnode = doc.FirstChild;
if (rootnode.Name != "regions")
{
// TODO - ERROR!
// TODO - ERROR!
}
for(int i=0; i<=rootnode.ChildNodes.Count; i++)
{
if(rootnode.ChildNodes.Item(i).Name != "region") {
// TODO - ERROR!
// TODO - ERROR!
} else {
TempRegionData = new RegionBlock();
TempRegionData = new RegionBlock();
}
}
}
public bool RestartServer()
{
return true;
}
public bool ShutdownServer()
{
try {
Hashtable ShutdownParamsHT = new Hashtable();
ArrayList ShutdownParams = new ArrayList();
ShutdownParamsHT["session_id"]=this.SessionID.ToString();
ShutdownParams.Add(ShutdownParamsHT);
XmlRpcRequest GridShutdownReq = new XmlRpcRequest("shutdown",ShutdownParams);
XmlRpcResponse GridResp = GridShutdownReq.Send(this.ServerURL,3000);
if(GridResp.IsFault) {
return false;
} else {
connected=false;
return true;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
return false;
}
}
public void DisconnectServer()
{
this.connected=false;
}
}
}
}
public bool RestartServer()
{
return true;
}
public bool ShutdownServer()
{
try {
Hashtable ShutdownParamsHT = new Hashtable();
ArrayList ShutdownParams = new ArrayList();
ShutdownParamsHT["session_id"]=this.SessionID.ToString();
ShutdownParams.Add(ShutdownParamsHT);
XmlRpcRequest GridShutdownReq = new XmlRpcRequest("shutdown",ShutdownParams);
XmlRpcResponse GridResp = GridShutdownReq.Send(this.ServerURL,3000);
if(GridResp.IsFault) {
return false;
} else {
connected=false;
return true;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
return false;
}
}
public void DisconnectServer()
{
this.connected=false;
}
}
}

View File

@ -26,99 +26,98 @@
*
*/
// project created on 5/14/2007 at 2:04 PM
using System;
using System.Threading;
using Gtk;
namespace OpenGridServices.Manager
{
class MainClass
{
class MainClass
{
public static bool QuitReq=false;
public static BlockingQueue<string> PendingOperations = new BlockingQueue<string>();
public static bool QuitReq=false;
public static BlockingQueue<string> PendingOperations = new BlockingQueue<string>();
private static Thread OperationsRunner;
private static GridServerConnectionManager gridserverConn;
private static MainWindow win;
private static Thread OperationsRunner;
private static GridServerConnectionManager gridserverConn;
private static MainWindow win;
public static void DoMainLoop()
{
while(!QuitReq)
{
Application.RunIteration();
}
}
public static void DoMainLoop()
{
while(!QuitReq)
{
Application.RunIteration();
}
}
public static void RunOperations()
{
string operation;
string cmd;
char[] sep = new char[1];
sep[0]=' ';
while(!QuitReq)
{
operation=PendingOperations.Dequeue();
Console.WriteLine(operation);
cmd = operation.Split(sep)[0];
switch(cmd) {
case "connect_to_gridserver":
win.SetStatus("Connecting to grid server...");
if(gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3])) {
win.SetStatus("Connected OK with session ID:" + gridserverConn.SessionID);
win.SetGridServerConnected(true);
Thread.Sleep(3000);
win.SetStatus("Downloading region maps...");
gridserverConn.DownloadMap();
} else {
win.SetStatus("Could not connect");
}
break;
case "restart_gridserver":
win.SetStatus("Restarting grid server...");
if(gridserverConn.RestartServer()) {
win.SetStatus("Restarted server OK");
Thread.Sleep(3000);
win.SetStatus("");
} else {
win.SetStatus("Error restarting grid server!!!");
}
break;
case "shutdown_gridserver":
win.SetStatus("Shutting down grid server...");
if(gridserverConn.ShutdownServer()) {
win.SetStatus("Grid server shutdown");
win.SetGridServerConnected(false);
Thread.Sleep(3000);
win.SetStatus("");
} else {
win.SetStatus("Could not shutdown grid server!!!");
}
break;
case "disconnect_gridserver":
gridserverConn.DisconnectServer();
win.SetGridServerConnected(false);
break;
}
}
}
public static void RunOperations()
{
string operation;
string cmd;
char[] sep = new char[1];
sep[0]=' ';
while(!QuitReq)
{
operation=PendingOperations.Dequeue();
Console.WriteLine(operation);
cmd = operation.Split(sep)[0];
switch(cmd) {
case "connect_to_gridserver":
win.SetStatus("Connecting to grid server...");
if(gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3])) {
win.SetStatus("Connected OK with session ID:" + gridserverConn.SessionID);
win.SetGridServerConnected(true);
Thread.Sleep(3000);
win.SetStatus("Downloading region maps...");
gridserverConn.DownloadMap();
} else {
win.SetStatus("Could not connect");
}
break;
case "restart_gridserver":
win.SetStatus("Restarting grid server...");
if(gridserverConn.RestartServer()) {
win.SetStatus("Restarted server OK");
Thread.Sleep(3000);
win.SetStatus("");
} else {
win.SetStatus("Error restarting grid server!!!");
}
break;
case "shutdown_gridserver":
win.SetStatus("Shutting down grid server...");
if(gridserverConn.ShutdownServer()) {
win.SetStatus("Grid server shutdown");
win.SetGridServerConnected(false);
Thread.Sleep(3000);
win.SetStatus("");
} else {
win.SetStatus("Could not shutdown grid server!!!");
}
break;
case "disconnect_gridserver":
gridserverConn.DisconnectServer();
win.SetGridServerConnected(false);
break;
}
}
}
public static void Main (string[] args)
{
gridserverConn = new GridServerConnectionManager();
Application.Init ();
win = new MainWindow ();
win.Show ();
OperationsRunner = new Thread(new ThreadStart(RunOperations));
OperationsRunner.IsBackground=true;
OperationsRunner.Start();
DoMainLoop();
}
}
public static void Main (string[] args)
{
gridserverConn = new GridServerConnectionManager();
Application.Init ();
win = new MainWindow ();
win.Show ();
OperationsRunner = new Thread(new ThreadStart(RunOperations));
OperationsRunner.IsBackground=true;
OperationsRunner.Start();
DoMainLoop();
}
}
}

View File

@ -29,76 +29,76 @@
using System;
using Gtk;
namespace OpenGridServices.Manager {
public partial class MainWindow: Gtk.Window
{
public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Build ();
}
public void SetStatus(string statustext)
{
this.statusbar1.Pop(0);
this.statusbar1.Push(0,statustext);
}
namespace OpenGridServices.Manager
{
public partial class MainWindow: Gtk.Window
{
public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Build();
}
public void DrawGrid(RegionBlock[][] regions)
{
for(int x=0; x<=regions.GetUpperBound(0); x++) {
for(int y=0; y<=regions.GetUpperBound(1); y++) {
Gdk.Image themap = new Gdk.Image(Gdk.ImageType.Fastest,Gdk.Visual.System,256,256);
this.drawingarea1.GdkWindow.DrawImage(new Gdk.GC(this.drawingarea1.GdkWindow),themap,0,0,x*256,y*256,256,256);
}
}
}
public void SetGridServerConnected(bool connected)
{
if(connected) {
this.ConnectToGridserver.Visible=false;
this.DisconnectFromGridServer.Visible=true;
} else {
this.ConnectToGridserver.Visible=true;
this.DisconnectFromGridServer.Visible=false;
}
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
MainClass.QuitReq=true;
a.RetVal = true;
}
protected virtual void QuitMenu(object sender, System.EventArgs e)
{
MainClass.QuitReq=true;
Application.Quit();
}
protected virtual void ConnectToGridServerMenu(object sender, System.EventArgs e)
{
ConnectToGridServerDialog griddialog = new ConnectToGridServerDialog ();
griddialog.Show();
}
public void SetStatus(string statustext)
{
this.statusbar1.Pop(0);
this.statusbar1.Push(0, statustext);
}
protected virtual void RestartGridserverMenu(object sender, System.EventArgs e)
{
MainClass.PendingOperations.Enqueue("restart_gridserver");
}
public void DrawGrid(RegionBlock[][] regions)
{
for (int x=0; x<=regions.GetUpperBound(0); x++)
{
for (int y=0; y<=regions.GetUpperBound(1); y++)
{
Gdk.Image themap = new Gdk.Image(Gdk.ImageType.Fastest,Gdk.Visual.System,256,256);
this.drawingarea1.GdkWindow.DrawImage(new Gdk.GC(this.drawingarea1.GdkWindow),themap,0,0,x*256,y*256,256,256);
}
}
}
protected virtual void ShutdownGridserverMenu(object sender, System.EventArgs e)
{
MainClass.PendingOperations.Enqueue("shutdown_gridserver");
}
public void SetGridServerConnected(bool connected)
{
if (connected) {
this.ConnectToGridserver.Visible=false;
this.DisconnectFromGridServer.Visible=true;
} else {
this.ConnectToGridserver.Visible=true;
this.DisconnectFromGridServer.Visible=false;
}
}
protected virtual void DisconnectGridServerMenu(object sender, System.EventArgs e)
{
MainClass.PendingOperations.Enqueue("disconnect_gridserver");
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
MainClass.QuitReq=true;
a.RetVal = true;
}
}
protected virtual void QuitMenu(object sender, System.EventArgs e)
{
MainClass.QuitReq=true;
Application.Quit();
}
protected virtual void ConnectToGridServerMenu(object sender, System.EventArgs e)
{
ConnectToGridServerDialog griddialog = new ConnectToGridServerDialog ();
griddialog.Show();
}
protected virtual void RestartGridserverMenu(object sender, System.EventArgs e)
{
MainClass.PendingOperations.Enqueue("restart_gridserver");
}
protected virtual void ShutdownGridserverMenu(object sender, System.EventArgs e)
{
MainClass.PendingOperations.Enqueue("shutdown_gridserver");
}
protected virtual void DisconnectGridServerMenu(object sender, System.EventArgs e)
{
MainClass.PendingOperations.Enqueue("disconnect_gridserver");
}
}
}

View File

@ -33,33 +33,31 @@ using OpenSim.Framework.Utilities;
namespace OpenGridServices.Manager
{
public class RegionBlock
{
public uint regloc_x;
public uint regloc_y;
public string httpd_url;
public string region_name;
public ulong regionhandle {
get { return Util.UIntsToLong(regloc_x*256,regloc_y*256); }
}
public class RegionBlock
{
public uint regloc_x;
public uint regloc_y;
public Gdk.Pixbuf MiniMap;
public RegionBlock()
{
}
public string httpd_url;
public void LoadFromXmlNode(XmlNode sourcenode)
{
this.regloc_x=Convert.ToUInt32(sourcenode.Attributes.GetNamedItem("loc_x").Value);
this.regloc_y=Convert.ToUInt32(sourcenode.Attributes.GetNamedItem("loc_y").Value);
this.region_name=sourcenode.Attributes.GetNamedItem("region_name").Value;
this.httpd_url=sourcenode.Attributes.GetNamedItem("httpd_url").Value;
}
}
public string region_name;
public ulong regionhandle {
get { return Util.UIntsToLong(regloc_x*256,regloc_y*256); }
}
public Gdk.Pixbuf MiniMap;
public RegionBlock()
{
}
public void LoadFromXmlNode(XmlNode sourcenode)
{
this.regloc_x=Convert.ToUInt32(sourcenode.Attributes.GetNamedItem("loc_x").Value);
this.regloc_y=Convert.ToUInt32(sourcenode.Attributes.GetNamedItem("loc_y").Value);
this.region_name=sourcenode.Attributes.GetNamedItem("region_name").Value;
this.httpd_url=sourcenode.Attributes.GetNamedItem("httpd_url").Value;
}
}
}

View File

@ -41,15 +41,15 @@ namespace OpenUser.Config.UserConfigDb4o
return ( new DbUserConfig());
}
}
public class DbUserConfig : UserConfig
{
private IObjectContainer db;
private IObjectContainer db;
public void LoadDefaults()
{
MainLog.Instance.Notice("DbUserConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
this.DefaultStartupMsg = MainLog.Instance.CmdPrompt("Default startup message", "Welcome to OGS");
this.GridServerURL = MainLog.Instance.CmdPrompt("Grid server URL","http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString() + "/");
@ -88,14 +88,14 @@ namespace OpenUser.Config.UserConfigDb4o
MainLog.Instance.Warn("DbUserConfig.cs:InitConfig() - Exception occured");
MainLog.Instance.Warn(e.ToString());
}
MainLog.Instance.Verbose("DBUSERCONFIG", "User settings loaded:");
MainLog.Instance.Verbose("DBUSERCONFIG", "Default startup message: " + this.DefaultStartupMsg);
MainLog.Instance.Verbose("DBUSERCONFIG", "Grid server URL: " + this.GridServerURL);
MainLog.Instance.Verbose("DBUSERCONFIG", "Key to send to grid: " + this.GridSendKey);
MainLog.Instance.Verbose("DBUSERCONFIG", "Key to expect from grid: " + this.GridRecvKey);
}
public void Shutdown()
{
db.Close();