summaryrefslogtreecommitdiffstats
path: root/avahi-ui-sharp/zssh.cs
diff options
context:
space:
mode:
authorJames Willcox <snopr@snorp.net>2007-04-19 21:01:45 +0000
committerJames Willcox <snopr@snorp.net>2007-04-19 21:01:45 +0000
commit3025a26988fe2de9d14867056c945e20f490ec1e (patch)
tree3bcd3e15bce426c8dc1163b980dd34d5661d4e9d /avahi-ui-sharp/zssh.cs
parent6d19f5e1d1800396007e0f26bac8232539a2094c (diff)
add avahi-ui-sharp
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1444 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-ui-sharp/zssh.cs')
-rw-r--r--avahi-ui-sharp/zssh.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/avahi-ui-sharp/zssh.cs b/avahi-ui-sharp/zssh.cs
new file mode 100644
index 0000000..ad45ca9
--- /dev/null
+++ b/avahi-ui-sharp/zssh.cs
@@ -0,0 +1,37 @@
+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.Close, ResponseType.Cancel);
+ 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);
+ }
+ }
+ }
+}