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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,33 +33,31 @@ using OpenSim.Framework.Utilities;
namespace OpenGridServices.Manager namespace OpenGridServices.Manager
{ {
public class RegionBlock
{
public uint regloc_x;
public uint regloc_y;
public string httpd_url;
public class RegionBlock public string region_name;
{
public uint regloc_x;
public uint regloc_y;
public string httpd_url; public ulong regionhandle {
get { return Util.UIntsToLong(regloc_x*256,regloc_y*256); }
}
public string region_name; public Gdk.Pixbuf MiniMap;
public ulong regionhandle { public RegionBlock()
get { return Util.UIntsToLong(regloc_x*256,regloc_y*256); } {
} }
public Gdk.Pixbuf MiniMap; public void LoadFromXmlNode(XmlNode sourcenode)
{
public RegionBlock() 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 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;
}
}
} }