diff options
author | Michael Hutchinson <mhutchinson@novell.com> | 2010-02-20 03:27:12 +0300 |
---|---|---|
committer | Michael Hutchinson <mhutchinson@novell.com> | 2010-02-20 03:27:12 +0300 |
commit | c19a00956d6da4b678a9455c6de3a9df145bcd93 (patch) | |
tree | db3d87255e858dc8e4ec7d6c639b663776b2da9c /extras/MonoDevelop.MeeGo/MeeGoExecutionHandler.cs | |
parent | 06a87144b8289411e8a565103eb16e1ae5a154f7 (diff) |
* MeeGoUtility.cs:
* MeeGoProject.cs:
* SshOperation.cs:
* MeeGoDevicePicker.cs:
* MonoDevelop.MeeGo.csproj:
* MeeGoExecutionCommand.cs:
* MeeGoExecutionHandler.cs:
* MeeGoSoftDebuggerEngine.cs:
* MonoDevelop.MeeGo.addin.xml: Add support for launching over ssh.
svn path=/trunk/monodevelop/; revision=152111
Diffstat (limited to 'extras/MonoDevelop.MeeGo/MeeGoExecutionHandler.cs')
-rw-r--r-- | extras/MonoDevelop.MeeGo/MeeGoExecutionHandler.cs | 80 |
1 files changed, 78 insertions, 2 deletions
diff --git a/extras/MonoDevelop.MeeGo/MeeGoExecutionHandler.cs b/extras/MonoDevelop.MeeGo/MeeGoExecutionHandler.cs index ae68ea0b94..d1caa1a6aa 100644 --- a/extras/MonoDevelop.MeeGo/MeeGoExecutionHandler.cs +++ b/extras/MonoDevelop.MeeGo/MeeGoExecutionHandler.cs @@ -25,7 +25,11 @@ // THE SOFTWARE. using System; +using System.Linq; using MonoDevelop.Core.Execution; +using System.Collections.Generic; +using Tamir.SharpSsh; +using System.IO; namespace MonoDevelop.MeeGo { @@ -40,9 +44,81 @@ namespace MonoDevelop.MeeGo public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console) { - //var cmd = (MeeGoExecutionCommand) command; + var cmd = (MeeGoExecutionCommand) command; + var targetDevice = MeeGoDevice.GetChosenDevice (); + if (targetDevice == null) { + return new NullProcessAsyncOperation (false); + } - throw new NotImplementedException (); + MeeGoUtility.Upload (targetDevice, cmd.Config, console.Out, console.Error).WaitForCompleted (); + + Sftp sftp = new Sftp (targetDevice.Address, targetDevice.Username, targetDevice.Password); + sftp.Connect (); + var files = sftp.GetFileList ("/var/run/gdm/auth-for-" + targetDevice.Username + "*"); + sftp.Close (); + if (files.Count != 1) { + console.Error.WriteLine ("Could not obtain single X authority for user '" + targetDevice.Username +"'"); + return new NullProcessAsyncOperation (false); + } + + var ssh = new SshExec (targetDevice.Address, targetDevice.Username, targetDevice.Password); + + string targetPath = cmd.Config.ParentItem.Name + "/" + Path.GetFileName (cmd.Config.CompiledOutputName); + var proc = new SshRemoteProcess (ssh, string.Format ( + "XAUTHLOCALHOSTNAME=localhost " + + "DISPLAY=:0.0 " + + "XAUTHORITY=/var/run/gdm/" + files[0] +"/database " + + "mono '{0}'", targetPath)); + proc.Run (); + + return new NullProcessAsyncOperation (true);// proc; + } + } + + class SshRemoteProcess : SshOperation<SshExec>, IProcessAsyncOperation + { + string command; + + public SshRemoteProcess (SshExec ssh, string command) : base (ssh) + { + this.command = command; + } + + protected override void RunOperations () + { + Console.WriteLine (command); + Console.WriteLine (Ssh.RunCommand (command)); + } + + public int ExitCode { get; private set; } + public int ProcessId { get; private set; } + } + + public class MeeGoExecutionModeSet : IExecutionModeSet + { + MeeGoExecutionMode mode; + + public string Name { get { return "MeeGo"; } } + + public IEnumerable<IExecutionMode> ExecutionModes { + get { + yield return mode ?? (mode = new MeeGoExecutionMode ()); + } + } + } + + class MeeGoExecutionMode : IExecutionMode + { + MeeGoExecutionHandler handler; + + public string Name { get { return "MeeGo Device"; } } + + public string Id { get { return "MeeGoExecutionMode"; } } + + public IExecutionHandler ExecutionHandler { + get { + return handler ?? (handler = new MeeGoExecutionHandler ()); + } } } } |