~ubuntu-branches/ubuntu/hardy/do-plugins/hardy

« back to all changes in this revision

Viewing changes to SSH/SSHAction.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-03-15 13:06:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080315130635-jg1g6fbllv1sfjsx
Tags: 0.4.0-0ubuntu1
* New upstream release
* debian/watch:
  + Update for new Launchpad address
* debian/rules:
  + Don't build the Banshee plugin - it interferes with the normal running
    of Banshee
* debian/gnome-do-plugins.install:
  + Update for new plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* SSHAction.cs
 
2
 *
 
3
 * GNOME Do is the legal property of its developers. Please refer to the
 
4
 * COPYRIGHT file distributed with this
 
5
 * source distribution.
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation, either version 3 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
using System;
 
22
using Do.Universe;
 
23
using System.Diagnostics;
 
24
 
 
25
using GConf;
 
26
 
 
27
namespace GnomeDoSSH {
 
28
        public class SSHAction : AbstractAction {
 
29
                
 
30
                public override string Name {
 
31
                        get {
 
32
                                return "Connect with SSH";
 
33
                        }
 
34
                }
 
35
                
 
36
                public override string Description {
 
37
                        get {
 
38
                                return "Connect with SSH";
 
39
                        }
 
40
                }
 
41
                
 
42
                public override string Icon {
 
43
                        get {
 
44
                                return "network-server";
 
45
                        }
 
46
                }
 
47
                
 
48
                public override Type[] SupportedItemTypes {
 
49
            get {
 
50
                return new Type[] {
 
51
                    typeof(ITextItem),
 
52
                    typeof(HostItem),
 
53
                };
 
54
            }
 
55
                }
 
56
                
 
57
                public override bool SupportsItem (IItem item) {
 
58
                        return true;
 
59
                }
 
60
                
 
61
                public override IItem[] Perform (IItem[] items, IItem[] modItems) {
 
62
                        GConf.Client client = new GConf.Client ();
 
63
 
 
64
                        string exec;
 
65
                        try {
 
66
                                exec = client.Get ("/desktop/gnome/applications/terminal/exec") as string;
 
67
                        } 
 
68
                        catch {
 
69
                                exec = "gnome-terminal";
 
70
                        }
 
71
                        
 
72
            string hostname;
 
73
 
 
74
            if (items [0] is ITextItem) {
 
75
                ITextItem textitem = items [0] as ITextItem;
 
76
                hostname = textitem.Text;
 
77
            }
 
78
            else {
 
79
                HostItem hostitem = items [0] as HostItem;
 
80
                hostname = hostitem.Text;
 
81
            }
 
82
 
 
83
                        Process term = new Process ();
 
84
                        term.StartInfo.FileName = exec;
 
85
                        term.StartInfo.Arguments = "-e 'ssh " + hostname + "'";
 
86
                        term.Start ();
 
87
                        return null;
 
88
                }
 
89
        }
 
90
}