Merge lp:~qos/do-plugins/ssh-browse-via-sftp into lp:do-plugins

Proposed by Massimo Mund
Status: Needs review
Proposed branch: lp:~qos/do-plugins/ssh-browse-via-sftp
Merge into: lp:do-plugins
Diff against target: 266 lines (+141/-11)
8 files modified
SSH/Makefile.am (+3/-1)
SSH/Resources/SSH.addin.xml.in (+4/-2)
SSH/SSH.mdp (+2/-0)
SSH/src/SFTPAction.cs (+77/-0)
SSH/src/SSHAction.cs (+0/-4)
SSH/src/SSHHostItem.cs (+10/-2)
SSH/src/SSHHostItemSource.cs (+2/-2)
SSH/src/Util.cs (+43/-0)
To merge this branch: bzr merge lp:~qos/do-plugins/ssh-browse-via-sftp
Reviewer Review Type Date Requested Status
Alex Launi Pending
Review via email: mp+15702@code.launchpad.net

This proposal supersedes a proposal from 2009-08-21.

To post a comment you must log in.
Revision history for this message
Massimo Mund (qos) wrote : Posted in a previous version of this proposal

You can now launch your SSH hosts via nautilus and SFTP.
e.g.: Tap the MagicKey, type "SFTP", type "yourhost", ENTER
and nautilus will open the host via "sftp://yourhost".

You can also directly access "yourhost".
e.g.: Tag the MagicKey, type "yourhost", TAB, select OPEN or BROWSE VIA SFTP, ENTER

Revision history for this message
Alex Launi (alexlauni) wrote : Posted in a previous version of this proposal

1) Please return the localizer to the autofoo one. You've hardcoded the path in the Addin.xml.in.
2) SSHActionSFTP is an ugly name, StfpAction.cs.
3) You've got a bunch of Mono guideline violations, make sure that all of your method calls have a space between the method name and the parameters. Method (param);
4) You dont need SupportsItem if you're just returning True, that's what the parent method does.
5) I don't like that you've got the code for finding the file manager in two places. You should make a new static class Util.cs that has a static method FindFileManager () that will search GConf for the file manager, then you're not copying and pasting blocks. Much cleaner.

review: Needs Fixing
Revision history for this message
Massimo Mund (qos) wrote : Posted in a previous version of this proposal

all issues fixed hopefully :)

Unmerged revisions

660. By Massimo Mund

Fixed the issues suggested by Alex Launi.

659. By Mo <mo@ibex>

Fixed missing SSH source file

658. By Mo <mo@ibex>

Allows you to launch SSH profiles via SFTP and nautilus

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'SSH/Makefile.am'
--- SSH/Makefile.am 2009-06-22 04:05:16 +0000
+++ SSH/Makefile.am 2009-12-06 00:40:28 +0000
@@ -4,8 +4,10 @@
44
5FILES = \5FILES = \
6 src/SSHAction.cs \6 src/SSHAction.cs \
7 src/SFTPAction.cs \
7 src/SSHHostItem.cs \8 src/SSHHostItem.cs \
8 src/SSHHostItemSource.cs9 src/SSHHostItemSource.cs \
10 src/Util.cs
911
10RESOURCES = \12RESOURCES = \
11 Resources/SSH.addin.xml 13 Resources/SSH.addin.xml
1214
=== modified file 'SSH/Resources/SSH.addin.xml.in'
--- SSH/Resources/SSH.addin.xml.in 2009-06-26 15:28:06 +0000
+++ SSH/Resources/SSH.addin.xml.in 2009-12-06 00:40:28 +0000
@@ -1,9 +1,9 @@
1<Addin1<Addin
2 id="SSH"2 id="SSH"
3 namespace="Do"3 namespace="Do"
4 version="1.1"4 version="1.2"
5 name="SSH"5 name="SSH"
6 description="Search and connect to SSH hosts."6 description="Search, Browse and connect to SSH hosts."
7 author="Peter Stuifzand"7 author="Peter Stuifzand"
8 category="Community"8 category="Community"
9 defaultEnabled="false"9 defaultEnabled="false"
@@ -19,11 +19,13 @@
19 <Dependencies>19 <Dependencies>
20 <Addin id="Universe" version="1.0" />20 <Addin id="Universe" version="1.0" />
21 </Dependencies>21 </Dependencies>
22
2223
23 <Extension path = "/Do/ItemSource">24 <Extension path = "/Do/ItemSource">
24 <ItemSource type="SSH.SSHHostItemSource" />25 <ItemSource type="SSH.SSHHostItemSource" />
25 </Extension>26 </Extension>
26 <Extension path = "/Do/Action">27 <Extension path = "/Do/Action">
27 <Action type="SSH.SSHAction" />28 <Action type="SSH.SSHAction" />
29 <Action type="SSH.SFTPAction" />
28 </Extension>30 </Extension>
29</Addin>31</Addin>
3032
=== modified file 'SSH/SSH.mdp'
--- SSH/SSH.mdp 2009-06-29 08:47:41 +0000
+++ SSH/SSH.mdp 2009-12-06 00:40:28 +0000
@@ -16,7 +16,9 @@
16 <Contents>16 <Contents>
17 <File name="src" subtype="Directory" buildaction="Compile" />17 <File name="src" subtype="Directory" buildaction="Compile" />
18 <File name="src/SSHAction.cs" subtype="Code" buildaction="Compile" />18 <File name="src/SSHAction.cs" subtype="Code" buildaction="Compile" />
19 <File name="src/SFTPAction.cs" subtype="Code" buildaction="Compile" />
19 <File name="src/SSHHostItem.cs" subtype="Code" buildaction="Compile" />20 <File name="src/SSHHostItem.cs" subtype="Code" buildaction="Compile" />
21 <File name="src/Util.cs" subtype="Code" buildaction="Compile" />
20 <File name="Resources/SSH.addin.xml" subtype="Code" buildaction="EmbedAsResource" />22 <File name="Resources/SSH.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
21 <File name="src/SSHHostItemSource.cs" subtype="Code" buildaction="Compile" />23 <File name="src/SSHHostItemSource.cs" subtype="Code" buildaction="Compile" />
22 </Contents>24 </Contents>
2325
=== added file 'SSH/src/SFTPAction.cs'
--- SSH/src/SFTPAction.cs 1970-01-01 00:00:00 +0000
+++ SSH/src/SFTPAction.cs 2009-12-06 00:40:28 +0000
@@ -0,0 +1,77 @@
1/* SFTPAction.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
21using System;
22using System.Collections.Generic;
23using System.Linq;
24using Do.Universe;
25using Do.Platform;
26using System.Diagnostics;
27
28using Mono.Addins;
29
30namespace SSH {
31
32 public class SFTPAction : Act {
33
34 public override string Name {
35 get {
36 return AddinManager.CurrentLocalizer.GetString ("Browse via SFTP");
37 }
38 }
39
40 public override string Description {
41 get {
42 return AddinManager.CurrentLocalizer.GetString ("Browse via SFTP");
43 }
44 }
45
46 public override string Icon {
47 get {
48 return "network-server";
49 }
50 }
51
52 public override IEnumerable<Type> SupportedItemTypes {
53 get {
54 yield return typeof (ITextItem);
55 yield return typeof (SSHHostItem);
56 }
57 }
58
59 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) {
60
61 string hostname;
62 string exec = Util.FindFileManager ();
63
64 if (items.First () is ITextItem) {
65 ITextItem textitem = items.First () as ITextItem;
66 hostname = textitem.Text;
67 }
68 else {
69 SSHHostItem hostitem = items.First () as SSHHostItem;
70 hostname = hostitem.Host;
71 }
72
73 Process.Start (exec, "sftp://"+hostname);
74 yield break;
75 }
76 }
77}
0\ No newline at end of file78\ No newline at end of file
179
=== modified file 'SSH/src/SSHAction.cs'
--- SSH/src/SSHAction.cs 2009-06-22 04:05:16 +0000
+++ SSH/src/SSHAction.cs 2009-12-06 00:40:28 +0000
@@ -57,10 +57,6 @@
57 }57 }
58 }58 }
59 59
60 public override bool SupportsItem (Item item) {
61 return true;
62 }
63
64 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) {60 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) {
65 61
66 GConf.Client client = new GConf.Client ();62 GConf.Client client = new GConf.Client ();
6763
=== modified file 'SSH/src/SSHHostItem.cs'
--- SSH/src/SSHHostItem.cs 2009-06-22 04:05:16 +0000
+++ SSH/src/SSHHostItem.cs 2009-12-06 00:40:28 +0000
@@ -21,6 +21,7 @@
21using System;21using System;
22using System.IO;22using System.IO;
23using System.Collections.Generic;23using System.Collections.Generic;
24using System.Diagnostics;
2425
25using Do.Universe;26using Do.Universe;
2627
@@ -28,7 +29,7 @@
2829
29namespace SSH {30namespace SSH {
3031
31 public class SSHHostItem : Item {32 public class SSHHostItem : Item, IOpenableItem {
32 33
33 public SSHHostItem (string host)34 public SSHHostItem (string host)
34 {35 {
@@ -37,9 +38,16 @@
3738
38 public override string Name { get { return this.Host; } }39 public override string Name { get { return this.Host; } }
39 public override string Description { get { return AddinManager.CurrentLocalizer.GetString ("SSH Host"); } }40 public override string Description { get { return AddinManager.CurrentLocalizer.GetString ("SSH Host"); } }
40 public override string Icon { get { return "gnome-globe"; } }41 public override string Icon { get { return "network-server"; } }
4142
42 public string Host { get; private set; }43 public string Host { get; private set; }
44
45 public void Open () {
46
47 string exec = Util.FindFileManager ();
48 Process.Start (exec, "sftp://"+this.Host);
49
50 }
43 }51 }
44}52}
4553
4654
=== modified file 'SSH/src/SSHHostItemSource.cs'
--- SSH/src/SSHHostItemSource.cs 2009-07-02 18:44:25 +0000
+++ SSH/src/SSHHostItemSource.cs 2009-12-06 00:40:28 +0000
@@ -64,7 +64,7 @@
64 items.Clear ();64 items.Clear ();
65 try {65 try {
66 string home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);66 string home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
67 string hostsFile = Path.Combine(home, ".ssh/config");67 string hostsFile = Path.Combine (home, ".ssh/config");
68 68
69 using (FileStream fs = new FileStream (hostsFile, FileMode.Open, FileAccess.Read)) {69 using (FileStream fs = new FileStream (hostsFile, FileMode.Open, FileAccess.Read)) {
70 Regex NameRegex = new Regex ("^\\s*Host\\s+(.+)\\s*$");70 Regex NameRegex = new Regex ("^\\s*Host\\s+(.+)\\s*$");
@@ -76,7 +76,7 @@
76 Match NameMatch = NameRegex.Match (s);76 Match NameMatch = NameRegex.Match (s);
77 if (NameMatch.Groups.Count != 2) continue;77 if (NameMatch.Groups.Count != 2) continue;
78 78
79 string line = NameMatch.Groups[1].ToString();79 string line = NameMatch.Groups[1].ToString ();
80 string[] hosts = line.Split(new string[] { " " }, StringSplitOptions.None);80 string[] hosts = line.Split(new string[] { " " }, StringSplitOptions.None);
81 foreach (string host in hosts)81 foreach (string host in hosts)
82 items.Add (new SSHHostItem (host));82 items.Add (new SSHHostItem (host));
8383
=== added file 'SSH/src/Util.cs'
--- SSH/src/Util.cs 1970-01-01 00:00:00 +0000
+++ SSH/src/Util.cs 2009-12-06 00:40:28 +0000
@@ -0,0 +1,43 @@
1/* Util.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
21using GConf;
22
23namespace SSH {
24
25 public static class Util {
26
27 public static string FindFileManager () {
28
29 GConf.Client client = new GConf.Client ();
30 string exec = (string) client.Get ("/desktop/gnome/applications/component_viewer/exec");
31
32 if (exec.Equals ("") == true) {
33 exec = "nautilus";
34 } else {
35 exec = exec.Replace ("%s", "");
36 }
37 return exec;
38
39 }
40
41 }
42
43}

Subscribers

People subscribed via source and target branches