diff options
author | James Willcox <snopr@snorp.net> | 2007-05-10 20:06:09 +0000 |
---|---|---|
committer | James Willcox <snopr@snorp.net> | 2007-05-10 20:06:09 +0000 |
commit | ed07152bd1d6f28d05167dd915711098ea241609 (patch) | |
tree | 9edf612a3648e5ca7a54481a4812b7ec848c02b5 /avahi-ui-sharp/bssh.cs | |
parent | eccd65bf97742966c466d99d1fdbbc388d2d8742 (diff) |
s/zssh.exe/bssh.exe/
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1481 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-ui-sharp/bssh.cs')
-rw-r--r-- | avahi-ui-sharp/bssh.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/avahi-ui-sharp/bssh.cs b/avahi-ui-sharp/bssh.cs new file mode 100644 index 0000000..003a3a6 --- /dev/null +++ b/avahi-ui-sharp/bssh.cs @@ -0,0 +1,39 @@ +using System; +using System.Diagnostics; +using Gtk; +using Avahi.UI; + +public class EntryPoint { + public static void Main () { + Application.Init (); + + ServiceDialog dialog = new ServiceDialog ("Choose SSH Server", null, + Stock.Cancel, ResponseType.Cancel, + Stock.Connect, ResponseType.Accept); + dialog.BrowseServiceTypes = new string[] { "_ssh._tcp" }; + dialog.ResolveServiceEnabled = true; + + if (dialog.Run () == (int) ResponseType.Accept) { + Console.WriteLine ("Connecting to {0}:{1}", dialog.Address, dialog.Port); + + string user = Environment.UserName; + + foreach (byte[] txtBytes in dialog.TxtData) { + string txt = System.Text.Encoding.UTF8.GetString (txtBytes); + string[] splitTxt = txt.Split(new char[] { '=' }, 2); + + if (splitTxt.Length != 2) + continue; + + if (splitTxt[0] == "u") { + user = splitTxt[1]; + } + + string args = String.Format ("gnome-terminal -t {0} -x ssh -p {1} -l {2} {3}", + dialog.HostName, dialog.Port, user, dialog.Address.ToString ()); + Console.WriteLine ("Launching: " + args); + Process.Start (args); + } + } + } +} |