diff --git a/SparkleLib/SparkleBackend.cs b/SparkleLib/SparkleBackend.cs index d59164b2..e478e9e8 100644 --- a/SparkleLib/SparkleBackend.cs +++ b/SparkleLib/SparkleBackend.cs @@ -22,15 +22,7 @@ namespace SparkleLib { public class SparkleBackend { - public static SparkleBackend DefaultBackend = - new SparkleBackend ("Git", - new string [4] { - "/opt/local/bin/git", - "/usr/bin/git", - "/usr/local/bin/git", - "/usr/local/git/bin/git" - } - ); + public static SparkleBackend DefaultBackend = new SparkleBackendGit (); public string Name; public string Path; @@ -61,4 +53,44 @@ namespace SparkleLib { return (path.Length > 0); } } + + + public class SparkleBackendGit : SparkleBackend { + + private static string name = "Git"; + private static string [] paths = new string [] { + "/opt/local/bin/git", + "/usr/bin/git", + "/usr/local/bin/git", + "/usr/local/git/bin/git" + }; + + public SparkleBackendGit () : base (name, paths) { } + + } + + + public class SparkleBackendHg : SparkleBackend { + + private static string name = "Hg"; + private static string [] paths = new string [] { + "/opt/local/bin/hg", + "/usr/bin/hg" + }; + + public SparkleBackendHg () : base (name, paths) { } + + } + + + public class SparkleBackendScp : SparkleBackend { + + private static string name = "Scp"; + private static string [] paths = new string [] { + "/usr/bin/scp" + }; + + public SparkleBackendScp () : base (name, paths) { } + + } } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index d2f4f839..38f0bbde 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -106,11 +106,10 @@ namespace SparkleShare { if (File.Exists (old_global_config_file_path)) MigrateConfig (); - if (FirstRun) { + if (FirstRun) SparkleConfig.DefaultConfig.SetConfigOption ("notifications", bool.TrueString); - } else { + else AddKey (); - } // Watch the SparkleShare folder FileSystemWatcher watcher = new FileSystemWatcher (SparklePaths.SparklePath) { @@ -401,8 +400,7 @@ namespace SparkleShare { event_log += day_entry.Replace ("", event_entries); } - string html = event_log_html.Replace ("", event_log); - return html; + return event_log_html.Replace ("", event_log); } @@ -468,25 +466,17 @@ namespace SparkleShare { if (backend == null) return; - + SparkleRepoBase repo = null; - if (backend.Equals ("Git")) { - repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend); + if (backend.Equals ("Hg")) + repo = new SparkleRepoHg (folder_path, new SparkleBackendHg ()); - } else if (backend.Equals ("Hg")) { - SparkleBackend hg_backend = new SparkleBackend ("Hg", - new string [] { - "/opt/local/bin/hg", - "/usr/bin/hg" - }); + else if (backend.Equals ("Scp")) + repo = new SparkleRepoScp (folder_path, new SparkleBackendScp ()); - repo = new SparkleRepoHg (folder_path, hg_backend); - - } else if (backend.Equals ("Scp")) { - SparkleBackend scp_backend = new SparkleBackend ("Scp", new string [] {"/usr/bin/scp"}); - repo = new SparkleRepoScp (folder_path, scp_backend); - } + else + repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend); repo.NewChangeSet += delegate (SparkleChangeSet change_set, string repository_path) { @@ -631,6 +621,7 @@ namespace SparkleShare { if (changes_count > 0) { string msg = Catalog.GetPluralString ("and {0} more", "and {0} more", changes_count); message += " " + String.Format (msg, changes_count); + } else if (changes_count < 0) { message += _("did something magical"); }