Merge lp:~develop7/synapse-project/ssh-plugin-proper-wildcards-and-dupes-handling into lp:synapse-project

Proposed by Andrei Dziahel
Status: Merged
Merged at revision: 517
Proposed branch: lp:~develop7/synapse-project/ssh-plugin-proper-wildcards-and-dupes-handling
Merge into: lp:synapse-project
Diff against target: 54 lines (+6/-8)
1 file modified
src/plugins/ssh-plugin.vala (+6/-8)
To merge this branch: bzr merge lp:~develop7/synapse-project/ssh-plugin-proper-wildcards-and-dupes-handling
Reviewer Review Type Date Requested Status
Alberto Aldegheri Approve
Antono Vasiljev Pending
Review via email: mp+138487@code.launchpad.net

Description of the change

This implements skipping of wildcard hosts (i.e. lines like "Host ?ubuntu.*") and dealing with host dupes by replacing ArrayList with HashMap.

To post a comment you must log in.
Revision history for this message
Andrei Dziahel (develop7) wrote :

Any comments/suggestions?

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

 it is ok to me! but me and mhr3 are really busy with our jobs, so for the moment synapse development is suspended.
 I'm really sorry.

 I'll try to merge your patch asap.

review: Approve
Revision history for this message
Andrei Dziahel (develop7) wrote :

> I'm really sorry.
Oh, no need really.
> I'll try to merge your patch asap.
Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugins/ssh-plugin.vala'
2--- src/plugins/ssh-plugin.vala 2011-09-26 11:20:02 +0000
3+++ src/plugins/ssh-plugin.vala 2012-12-06 15:52:28 +0000
4@@ -26,7 +26,7 @@
5 public class SshPlugin: Object, Activatable, ItemProvider
6 {
7 public bool enabled { get; set; default = true; }
8- private ArrayList<SshHost> hosts;
9+ private HashMap<string, SshHost> hosts;
10
11 protected File config_file;
12 protected FileMonitor monitor;
13@@ -38,7 +38,7 @@
14
15 construct
16 {
17- hosts = new ArrayList<SshHost> ();
18+ hosts = new HashMap<string, SshHost> ();
19 }
20
21 public void activate ()
22@@ -102,11 +102,10 @@
23 foreach (var host in line.split (" "))
24 {
25 string host_stripped = host.strip ();
26- if (host_stripped != ""/* && host_stripped.index_of ("*") == -1*/)
27+ if (host_stripped != "" && host_stripped.index_of ("*") == -1 && host_stripped.index_of ("?") == -1)
28 {
29- // TODO: no dupes
30 Utils.Logger.debug (this, "host added: %s\n", host_stripped);
31- hosts.add (new SshHost (host_stripped));
32+ hosts.set (host_stripped, new SshHost (host_stripped));
33 }
34 }
35 }
36@@ -148,7 +147,7 @@
37 var matchers = Query.get_matchers_for_query (q.query_string, 0,
38 RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS);
39
40- foreach (var host in hosts)
41+ foreach (var host in hosts.values) //workaround for missing HashMap.iterator() method
42 {
43 foreach (var matcher in matchers)
44 {
45@@ -198,8 +197,7 @@
46 description: _("Connect with SSH"),
47 has_thumbnail: false,
48 icon_name: "terminal",
49- // FIXME: handle wildcard hosts somehow better than now
50- host_query: host_name.replace ("?", " ").replace ("*", "").strip ()
51+ host_query: host_name
52 );
53
54 }