Skip to content

Commit

Permalink
* Settings.settings: New AppSetting listening_port
Browse files Browse the repository at this point in the history
* ConfigForm.cs: Close button now works ;)
* MainForm.cs: Listening port is now configurable

git-svn-id: http://xdebugclient.googlecode.com/svn/trunk@23 8941dcae-ad2d-0410-8676-e30e110ce8a3
  • Loading branch information
[email protected] committed Apr 23, 2009
1 parent 2866124 commit 1695934
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 8 deletions.
29 changes: 27 additions & 2 deletions xdc/Forms/ConfigForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions xdc/Forms/ConfigForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ public ConfigForm()
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
18 changes: 16 additions & 2 deletions xdc/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public partial class MainForm : Form
public MainForm()
{
InitializeComponent();
_client = new xdc.XDebug.Client("localhost", 9000);

_client = new xdc.XDebug.Client("localhost", 9000);
_client.EventCallback += new XDebugEventHandler(XDebugEventCallback);

// Get the forms up.
Expand Down Expand Up @@ -532,6 +532,20 @@ private void startListeningToolStripMenuItem_Click(object sender, EventArgs e)

try
{
int port;

try
{
port = Convert.ToInt32(xdc.Properties.Settings.Default.listening_port);
}
catch
{
MessageBox.Show("An invalid port number has been set in options, using 9000.", "Invalid port number");
port = 9000;
}


_client.setListeningPort(port);
_client.listenForConnection();

startListeningToolStripMenuItem.Enabled = false;
Expand Down
12 changes: 12 additions & 0 deletions xdc/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions xdc/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<Setting Name="auto_restart" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="listening_port" Type="System.String" Scope="User">
<Value Profile="(Default)">9000</Value>
</Setting>
</Settings>
</SettingsFile>
23 changes: 21 additions & 2 deletions xdc/XDebug/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Net;
using System.Net.Sockets;
using System.Xml;
using System.Windows.Forms;

namespace xdc.XDebug
{
Expand Down Expand Up @@ -110,6 +111,8 @@ public string Source(string URI)
{
string remoteURI = "file://";

string s;

if (URI[0] != '/')
remoteURI += "/";

Expand All @@ -123,7 +126,15 @@ public string Source(string URI)
throw new Exception("Parse error");
}

return base64ToASCII(r.XmlMessage.InnerText);
if (r.XmlMessage.InnerText == "can not open file")
{
MessageBox.Show("Could not load source file. Possibly the source file is empty. Continuing with empty file...","Source file");
s = "";
}
else
s = r.XmlMessage.InnerText;

return base64ToASCII(s);
}

/// <summary>
Expand Down Expand Up @@ -406,14 +417,22 @@ public void listenForConnection()
_listener = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

_listener.Bind(new IPEndPoint(IPAddress.Any, 9000));
_listener.Bind(new IPEndPoint(IPAddress.Any, _port));
_listener.Listen(1);

AsyncCallback c = new AsyncCallback(OnConnectRequest);

_listener.BeginAccept(new AsyncCallback(OnConnectRequest), _listener);
}

/// <summary>
/// Set the port that is used next time when listenForConnection() is called
/// </summary>
public void setListeningPort(int port)
{
_port = port;
}

/// <summary>
/// Deal with an incoming request. Also called when listening socket
/// is terminated.
Expand Down
3 changes: 3 additions & 0 deletions xdc/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<setting name="auto_restart" serializeAs="String">
<value>True</value>
</setting>
<setting name="listening_port" serializeAs="String">
<value>9000</value>
</setting>
</xdc.Properties.Settings>
</userSettings>
</configuration>
2 changes: 0 additions & 2 deletions xdc/xdc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@
<Content Include="lgpl.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Resources\ellipsis_normal.gif" />
<None Include="Resources\ellipsis_pressed.gif" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

0 comments on commit 1695934

Please sign in to comment.