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
1=== modified file 'SSH/Makefile.am'
2--- SSH/Makefile.am 2009-06-22 04:05:16 +0000
3+++ SSH/Makefile.am 2009-12-06 00:40:28 +0000
4@@ -4,8 +4,10 @@
5
6 FILES = \
7 src/SSHAction.cs \
8+ src/SFTPAction.cs \
9 src/SSHHostItem.cs \
10- src/SSHHostItemSource.cs
11+ src/SSHHostItemSource.cs \
12+ src/Util.cs
13
14 RESOURCES = \
15 Resources/SSH.addin.xml
16
17=== modified file 'SSH/Resources/SSH.addin.xml.in'
18--- SSH/Resources/SSH.addin.xml.in 2009-06-26 15:28:06 +0000
19+++ SSH/Resources/SSH.addin.xml.in 2009-12-06 00:40:28 +0000
20@@ -1,9 +1,9 @@
21 <Addin
22 id="SSH"
23 namespace="Do"
24- version="1.1"
25+ version="1.2"
26 name="SSH"
27- description="Search and connect to SSH hosts."
28+ description="Search, Browse and connect to SSH hosts."
29 author="Peter Stuifzand"
30 category="Community"
31 defaultEnabled="false"
32@@ -19,11 +19,13 @@
33 <Dependencies>
34 <Addin id="Universe" version="1.0" />
35 </Dependencies>
36+
37
38 <Extension path = "/Do/ItemSource">
39 <ItemSource type="SSH.SSHHostItemSource" />
40 </Extension>
41 <Extension path = "/Do/Action">
42 <Action type="SSH.SSHAction" />
43+ <Action type="SSH.SFTPAction" />
44 </Extension>
45 </Addin>
46
47=== modified file 'SSH/SSH.mdp'
48--- SSH/SSH.mdp 2009-06-29 08:47:41 +0000
49+++ SSH/SSH.mdp 2009-12-06 00:40:28 +0000
50@@ -16,7 +16,9 @@
51 <Contents>
52 <File name="src" subtype="Directory" buildaction="Compile" />
53 <File name="src/SSHAction.cs" subtype="Code" buildaction="Compile" />
54+ <File name="src/SFTPAction.cs" subtype="Code" buildaction="Compile" />
55 <File name="src/SSHHostItem.cs" subtype="Code" buildaction="Compile" />
56+ <File name="src/Util.cs" subtype="Code" buildaction="Compile" />
57 <File name="Resources/SSH.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
58 <File name="src/SSHHostItemSource.cs" subtype="Code" buildaction="Compile" />
59 </Contents>
60
61=== added file 'SSH/src/SFTPAction.cs'
62--- SSH/src/SFTPAction.cs 1970-01-01 00:00:00 +0000
63+++ SSH/src/SFTPAction.cs 2009-12-06 00:40:28 +0000
64@@ -0,0 +1,77 @@
65+/* SFTPAction.cs
66+ *
67+ * GNOME Do is the legal property of its developers. Please refer to the
68+ * COPYRIGHT file distributed with this
69+ * source distribution.
70+ *
71+ * This program is free software: you can redistribute it and/or modify
72+ * it under the terms of the GNU General Public License as published by
73+ * the Free Software Foundation, either version 3 of the License, or
74+ * (at your option) any later version.
75+ *
76+ * This program is distributed in the hope that it will be useful,
77+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
78+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79+ * GNU General Public License for more details.
80+ *
81+ * You should have received a copy of the GNU General Public License
82+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
83+ */
84+
85+using System;
86+using System.Collections.Generic;
87+using System.Linq;
88+using Do.Universe;
89+using Do.Platform;
90+using System.Diagnostics;
91+
92+using Mono.Addins;
93+
94+namespace SSH {
95+
96+ public class SFTPAction : Act {
97+
98+ public override string Name {
99+ get {
100+ return AddinManager.CurrentLocalizer.GetString ("Browse via SFTP");
101+ }
102+ }
103+
104+ public override string Description {
105+ get {
106+ return AddinManager.CurrentLocalizer.GetString ("Browse via SFTP");
107+ }
108+ }
109+
110+ public override string Icon {
111+ get {
112+ return "network-server";
113+ }
114+ }
115+
116+ public override IEnumerable<Type> SupportedItemTypes {
117+ get {
118+ yield return typeof (ITextItem);
119+ yield return typeof (SSHHostItem);
120+ }
121+ }
122+
123+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) {
124+
125+ string hostname;
126+ string exec = Util.FindFileManager ();
127+
128+ if (items.First () is ITextItem) {
129+ ITextItem textitem = items.First () as ITextItem;
130+ hostname = textitem.Text;
131+ }
132+ else {
133+ SSHHostItem hostitem = items.First () as SSHHostItem;
134+ hostname = hostitem.Host;
135+ }
136+
137+ Process.Start (exec, "sftp://"+hostname);
138+ yield break;
139+ }
140+ }
141+}
142\ No newline at end of file
143
144=== modified file 'SSH/src/SSHAction.cs'
145--- SSH/src/SSHAction.cs 2009-06-22 04:05:16 +0000
146+++ SSH/src/SSHAction.cs 2009-12-06 00:40:28 +0000
147@@ -57,10 +57,6 @@
148 }
149 }
150
151- public override bool SupportsItem (Item item) {
152- return true;
153- }
154-
155 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) {
156
157 GConf.Client client = new GConf.Client ();
158
159=== modified file 'SSH/src/SSHHostItem.cs'
160--- SSH/src/SSHHostItem.cs 2009-06-22 04:05:16 +0000
161+++ SSH/src/SSHHostItem.cs 2009-12-06 00:40:28 +0000
162@@ -21,6 +21,7 @@
163 using System;
164 using System.IO;
165 using System.Collections.Generic;
166+using System.Diagnostics;
167
168 using Do.Universe;
169
170@@ -28,7 +29,7 @@
171
172 namespace SSH {
173
174- public class SSHHostItem : Item {
175+ public class SSHHostItem : Item, IOpenableItem {
176
177 public SSHHostItem (string host)
178 {
179@@ -37,9 +38,16 @@
180
181 public override string Name { get { return this.Host; } }
182 public override string Description { get { return AddinManager.CurrentLocalizer.GetString ("SSH Host"); } }
183- public override string Icon { get { return "gnome-globe"; } }
184+ public override string Icon { get { return "network-server"; } }
185
186 public string Host { get; private set; }
187+
188+ public void Open () {
189+
190+ string exec = Util.FindFileManager ();
191+ Process.Start (exec, "sftp://"+this.Host);
192+
193+ }
194 }
195 }
196
197
198=== modified file 'SSH/src/SSHHostItemSource.cs'
199--- SSH/src/SSHHostItemSource.cs 2009-07-02 18:44:25 +0000
200+++ SSH/src/SSHHostItemSource.cs 2009-12-06 00:40:28 +0000
201@@ -64,7 +64,7 @@
202 items.Clear ();
203 try {
204 string home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
205- string hostsFile = Path.Combine(home, ".ssh/config");
206+ string hostsFile = Path.Combine (home, ".ssh/config");
207
208 using (FileStream fs = new FileStream (hostsFile, FileMode.Open, FileAccess.Read)) {
209 Regex NameRegex = new Regex ("^\\s*Host\\s+(.+)\\s*$");
210@@ -76,7 +76,7 @@
211 Match NameMatch = NameRegex.Match (s);
212 if (NameMatch.Groups.Count != 2) continue;
213
214- string line = NameMatch.Groups[1].ToString();
215+ string line = NameMatch.Groups[1].ToString ();
216 string[] hosts = line.Split(new string[] { " " }, StringSplitOptions.None);
217 foreach (string host in hosts)
218 items.Add (new SSHHostItem (host));
219
220=== added file 'SSH/src/Util.cs'
221--- SSH/src/Util.cs 1970-01-01 00:00:00 +0000
222+++ SSH/src/Util.cs 2009-12-06 00:40:28 +0000
223@@ -0,0 +1,43 @@
224+/* Util.cs
225+ *
226+ * GNOME Do is the legal property of its developers. Please refer to the
227+ * COPYRIGHT file distributed with this
228+ * source distribution.
229+ *
230+ * This program is free software: you can redistribute it and/or modify
231+ * it under the terms of the GNU General Public License as published by
232+ * the Free Software Foundation, either version 3 of the License, or
233+ * (at your option) any later version.
234+ *
235+ * This program is distributed in the hope that it will be useful,
236+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
237+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
238+ * GNU General Public License for more details.
239+ *
240+ * You should have received a copy of the GNU General Public License
241+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
242+ */
243+
244+using GConf;
245+
246+namespace SSH {
247+
248+ public static class Util {
249+
250+ public static string FindFileManager () {
251+
252+ GConf.Client client = new GConf.Client ();
253+ string exec = (string) client.Get ("/desktop/gnome/applications/component_viewer/exec");
254+
255+ if (exec.Equals ("") == true) {
256+ exec = "nautilus";
257+ } else {
258+ exec = exec.Replace ("%s", "");
259+ }
260+ return exec;
261+
262+ }
263+
264+ }
265+
266+}

Subscribers

People subscribed via source and target branches