[tomboy/xdg-migration2: 6/16] When no port is specified for SSH sync, don't force 22 (bug #574517).



commit 976deaa39ee102bab5b76f103f51b505b79fb395
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Sat Aug 22 18:10:19 2009 -0700

    When no port is specified for SSH sync, don't force 22 (bug #574517).
    
    Default preference value to -1, where any value less than 0 indicates
    that the -p option should not even be used. This allows other SSH
    configuration voodoo to be applied when invoking sshfs.

 .../Addins/SshSyncService/SshSyncServiceAddin.cs   |   15 ++++++++-------
 data/tomboy.schemas.in                             |    3 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/Tomboy/Addins/SshSyncService/SshSyncServiceAddin.cs b/Tomboy/Addins/SshSyncService/SshSyncServiceAddin.cs
index c2e2862..f3dba84 100644
--- a/Tomboy/Addins/SshSyncService/SshSyncServiceAddin.cs
+++ b/Tomboy/Addins/SshSyncService/SshSyncServiceAddin.cs
@@ -35,7 +35,7 @@ namespace Tomboy.Sync
 			GetConfigSettings (out server, out folder, out username, out port);
 			if (server == null)
 				server = string.Empty;
-			if (port != 22)
+			if (port > -1 && port != 22)
 				server += ":" + port.ToString ();
 			if (folder == null)
 				folder = string.Empty;
@@ -103,7 +103,7 @@ namespace Tomboy.Sync
 		protected override void ResetConfigurationValues ()
 		{
 			Preferences.Set ("/apps/tomboy/sync_sshfs_server", string.Empty);
-			Preferences.Set ("/apps/tomboy/sync_sshfs_port", 22);
+			Preferences.Set ("/apps/tomboy/sync_sshfs_port", -1);
 			Preferences.Set ("/apps/tomboy/sync_sshfs_folder", string.Empty);
 			Preferences.Set ("/apps/tomboy/sync_sshfs_username", string.Empty);
 		}
@@ -144,15 +144,16 @@ namespace Tomboy.Sync
 
 		protected override string GetFuseMountExeArgs (string mountPath, bool fromStoredValues)
 		{
-			int port = 22;
+			int port = -1;
 			string server, folder, username;
 			if (fromStoredValues)
 				GetConfigSettings (out server, out folder, out username, out port);
 			else
 				GetPrefWidgetSettings (out server, out folder, out username, out port);
+			string portStr = port > -1 ? string.Format ("-p {0}", port) : string.Empty;
 			return string.Format (
-			               "-p {0} {1} {2}:{3} {4}",
-			               port,
+			               "{0} {1} {2}:{3} {4}",
+			               portStr,
 			               username,
 			               server,
 			               folder,
@@ -189,7 +190,7 @@ namespace Tomboy.Sync
 		private bool GetConfigSettings (out string server, out string folder, out string username, out int port)
 		{
 			server = Preferences.Get ("/apps/tomboy/sync_sshfs_server") as String;
-			port = 22;
+			port = -1;
 			try {
 				port = (int)Preferences.Get ("/apps/tomboy/sync_sshfs_port");
 			} catch {}
@@ -205,7 +206,7 @@ namespace Tomboy.Sync
 		/// </summary>
 		private bool GetPrefWidgetSettings (out string server, out string folder, out string username, out int port)
 		{
-			port = 22;
+			port = -1;
 			server = serverEntry.Text.Trim ();
 			int lastColonIndex = server.LastIndexOf(":");
 			if (lastColonIndex > 0) {
diff --git a/data/tomboy.schemas.in b/data/tomboy.schemas.in
index c241042..66d0d95 100644
--- a/data/tomboy.schemas.in
+++ b/data/tomboy.schemas.in
@@ -491,11 +491,12 @@
       <applyto>/apps/tomboy/sync_sshfs_port</applyto>
       <owner>tomboy</owner>
       <type>int</type>
-      <default>22</default>
+      <default>-1</default>
       <locale name="C">
          <short>SSHFS Synchronization Server Port</short>
          <long>
 	   The port to use when connecting to the synchronization server via SSH.
+	   Set to -1 or less if default SSH port settings should be used instead.
          </long>
       </locale>
     </schema>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]