diff --git a/SparkleLib/AuthenticationInfo.cs b/SparkleLib/AuthenticationInfo/AuthenticationInfo.cs similarity index 100% rename from SparkleLib/AuthenticationInfo.cs rename to SparkleLib/AuthenticationInfo/AuthenticationInfo.cs diff --git a/SparkleLib/SSHAuthenticationInfo.cs b/SparkleLib/AuthenticationInfo/SSHAuthenticationInfo.cs similarity index 91% rename from SparkleLib/SSHAuthenticationInfo.cs rename to SparkleLib/AuthenticationInfo/SSHAuthenticationInfo.cs index e5c257b0..abe84d0b 100644 --- a/SparkleLib/SSHAuthenticationInfo.cs +++ b/SparkleLib/AuthenticationInfo/SSHAuthenticationInfo.cs @@ -40,7 +40,7 @@ namespace SparkleLib { public SSHAuthenticationInfo () { - Path = IO.Path.Combine (IO.Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "ssh"); + Path = IO.Path.Combine (IO.Path.GetDirectoryName (Configuration.DefaultConfig.FullPath), "ssh"); KnownHostsFilePath = IO.Path.Combine (Path, "known_hosts"); KnownHostsFilePath = MakeWindowsDomainAccountSafe (KnownHostsFilePath); @@ -98,19 +98,19 @@ namespace SparkleLib { "-C \"" + computer_name + " (SparkleShare)\" " + // Key comment "-f \"" + key_file_name + "\""; - var process = new SparkleProcess ("ssh-keygen", arguments); + var process = new Command ("ssh-keygen", arguments); process.StartInfo.WorkingDirectory = Path; process.Start (); process.WaitForExit (); if (process.ExitCode == 0) { - SparkleLogger.LogInfo ("Auth", "Created key pair: " + key_file_name); + Logger.LogInfo ("Auth", "Created key pair: " + key_file_name); ImportKeys (); return true; } - SparkleLogger.LogInfo ("Auth", "Could not create key pair"); + Logger.LogInfo ("Auth", "Could not create key pair"); return false; } diff --git a/SparkleLib/SparkleBackend.cs b/SparkleLib/Backend.cs similarity index 95% rename from SparkleLib/SparkleBackend.cs rename to SparkleLib/Backend.cs index 2c221228..c6297c5b 100755 --- a/SparkleLib/SparkleBackend.cs +++ b/SparkleLib/Backend.cs @@ -21,7 +21,7 @@ using System.Runtime.InteropServices; namespace SparkleLib { - public static class SparkleBackend { + public static class Backend { public static string Version { get { @@ -55,6 +55,6 @@ namespace SparkleLib { [DllImport ("libc")] - private static extern int uname (IntPtr buf); + static extern int uname (IntPtr buf); } } diff --git a/SparkleLib/SparkleProcess.cs b/SparkleLib/Command.cs similarity index 88% rename from SparkleLib/SparkleProcess.cs rename to SparkleLib/Command.cs index cfced2fb..832c7459 100644 --- a/SparkleLib/SparkleProcess.cs +++ b/SparkleLib/Command.cs @@ -21,17 +21,17 @@ using System.IO; namespace SparkleLib { - public class SparkleProcess : Process { + public class Command : Process { bool write_output; - public SparkleProcess (string path, string args) : this (path, args, false) + public Command (string path, string args) : this (path, args, false) { } - public SparkleProcess (string path, string args, bool write_output) + public Command (string path, string args, bool write_output) { this.write_output = write_output; @@ -53,13 +53,13 @@ namespace SparkleLib { folder = Path.GetFileName (StartInfo.WorkingDirectory) + " | "; if (this.write_output) - SparkleLogger.LogInfo ("Cmd", folder + Path.GetFileName (StartInfo.FileName) + " " + StartInfo.Arguments); + Logger.LogInfo ("Cmd", folder + Path.GetFileName (StartInfo.FileName) + " " + StartInfo.Arguments); try { base.Start (); } catch (Exception e) { - SparkleLogger.LogInfo ("Cmd", "Couldn't execute command: " + e.Message); + Logger.LogInfo ("Cmd", "Couldn't execute command: " + e.Message); Environment.Exit (-1); } } diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/Configuration.cs similarity index 93% rename from SparkleLib/SparkleConfig.cs rename to SparkleLib/Configuration.cs index 47f9abf2..f5cc18b8 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/Configuration.cs @@ -22,9 +22,9 @@ using System.Xml; namespace SparkleLib { - public class SparkleConfig : XmlDocument { + public class Configuration : XmlDocument { - public static SparkleConfig DefaultConfig; + public static Configuration DefaultConfig; public static bool DebugMode = true; public string FullPath; @@ -34,7 +34,7 @@ namespace SparkleLib { public string HomePath { get { - if (SparkleBackend.Platform == PlatformID.Win32NT) + if (Backend.Platform == PlatformID.Win32NT) return Environment.GetFolderPath (Environment.SpecialFolder.UserProfile); else return Environment.GetFolderPath (Environment.SpecialFolder.Personal); @@ -52,7 +52,7 @@ namespace SparkleLib { } - public SparkleConfig (string config_path, string config_file_name) + public Configuration (string config_path, string config_file_name) { FullPath = Path.Combine (config_path, config_file_name); string logs_path = Path.Combine (config_path, "logs"); @@ -110,8 +110,8 @@ namespace SparkleLib { { string user_name = "Unknown"; - if (SparkleBackend.Platform == PlatformID.Unix || - SparkleBackend.Platform == PlatformID.MacOSX) { + if (Backend.Platform == PlatformID.Unix || + Backend.Platform == PlatformID.MacOSX) { user_name = Environment.UserName; if (string.IsNullOrEmpty (user_name)) @@ -137,7 +137,7 @@ namespace SparkleLib { } - public SparkleUser User { + public User User { get { XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()"); XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()"); @@ -145,11 +145,11 @@ namespace SparkleLib { string name = name_node.Value; string email = email_node.Value; - return new SparkleUser (name, email); + return new User (name, email); } set { - SparkleUser user = (SparkleUser) value; + User user = (User) value; XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()"); XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()"); @@ -322,7 +322,7 @@ namespace SparkleLib { } Save (); - SparkleLogger.LogInfo ("Config", "Updated option " + name + ":" + content); + Logger.LogInfo ("Config", "Updated option " + name + ":" + content); } @@ -349,7 +349,7 @@ namespace SparkleLib { throw new FileNotFoundException (FullPath + " does not exist"); Save (FullPath); - SparkleLogger.LogInfo ("Config", "Wrote to '" + FullPath + "'"); + Logger.LogInfo ("Config", "Wrote to '" + FullPath + "'"); } } } diff --git a/SparkleLib/SparkleExtensions.cs b/SparkleLib/Extensions.cs similarity index 100% rename from SparkleLib/SparkleExtensions.cs rename to SparkleLib/Extensions.cs diff --git a/SparkleLib/SparkleFetcherBase.cs b/SparkleLib/Fetcher/BaseFetcher.cs similarity index 95% rename from SparkleLib/SparkleFetcherBase.cs rename to SparkleLib/Fetcher/BaseFetcher.cs index 105d9111..2297ab57 100755 --- a/SparkleLib/SparkleFetcherBase.cs +++ b/SparkleLib/Fetcher/BaseFetcher.cs @@ -35,7 +35,7 @@ namespace SparkleLib { } - public abstract class SparkleFetcherBase { + public abstract class BaseFetcher { public event Action Started = delegate { }; public event Action Failed = delegate { }; @@ -109,7 +109,7 @@ namespace SparkleLib { private Thread thread; - public SparkleFetcherBase (SparkleFetcherInfo info) + public BaseFetcher (SparkleFetcherInfo info) { OriginalFetcherInfo = info; RequiredFingerprint = info.Fingerprint; @@ -138,7 +138,7 @@ namespace SparkleLib { IsActive = true; Started (); - SparkleLogger.LogInfo ("Fetcher", TargetFolder + " | Fetching folder: " + RemoteUrl); + Logger.LogInfo ("Fetcher", TargetFolder + " | Fetching folder: " + RemoteUrl); try { if (Directory.Exists (TargetFolder)) @@ -153,7 +153,7 @@ namespace SparkleLib { this.thread = new Thread (() => { if (Fetch ()) { Thread.Sleep (500); - SparkleLogger.LogInfo ("Fetcher", "Finished"); + Logger.LogInfo ("Fetcher", "Finished"); IsActive = false; @@ -166,11 +166,11 @@ namespace SparkleLib { Thread.Sleep (500); if (IsActive) { - SparkleLogger.LogInfo ("Fetcher", "Failed"); + Logger.LogInfo ("Fetcher", "Failed"); Failed (); } else { - SparkleLogger.LogInfo ("Fetcher", "Failed: cancelled by user"); + Logger.LogInfo ("Fetcher", "Failed: cancelled by user"); } IsActive = false; diff --git a/SparkleLib/SparkleFetcherSSH.cs b/SparkleLib/Fetcher/SSHFetcher.cs similarity index 83% rename from SparkleLib/SparkleFetcherSSH.cs rename to SparkleLib/Fetcher/SSHFetcher.cs index a0264c42..9bb9e46b 100644 --- a/SparkleLib/SparkleFetcherSSH.cs +++ b/SparkleLib/Fetcher/SSHFetcher.cs @@ -22,9 +22,9 @@ using System.Security.Cryptography; namespace SparkleLib { - public abstract class SparkleFetcherSSH : SparkleFetcherBase { + public abstract class SSHFetcher : BaseFetcher { - public SparkleFetcherSSH (SparkleFetcherInfo info) : base (info) + public SSHFetcher (SparkleFetcherInfo info) : base (info) { } @@ -35,7 +35,7 @@ namespace SparkleLib { // resolved by using a proxy via tor. While the rest of the openssh suite // fully supports proxying, ssh-keyscan does not, so we can't use it for .onion if (RemoteUrl.Host.EndsWith (".onion")) { - SparkleLogger.LogInfo ("Auth", "using tor .onion address skipping ssh-keyscan"); + Logger.LogInfo ("Auth", "using tor .onion address skipping ssh-keyscan"); return true; } @@ -45,7 +45,7 @@ namespace SparkleLib { string host_key = FetchHostKey (); if (string.IsNullOrEmpty (RemoteUrl.Host) || host_key == null) { - SparkleLogger.LogInfo ("Auth", "Could not fetch host key"); + Logger.LogInfo ("Auth", "Could not fetch host key"); this.errors.Add ("error: Could not fetch host key"); return false; @@ -62,24 +62,24 @@ namespace SparkleLib { } catch (InvalidOperationException e) { // "Unapproved cryptographic algorithms" won't work when FIPS is enabled on Windows. // Software like Cisco AnyConnect can demand this feature is on, so we show an error - SparkleLogger.LogInfo ("Auth", "Unable to derive fingerprint: ", e); + Logger.LogInfo ("Auth", "Unable to derive fingerprint: ", e); this.errors.Add ("error: Can't check fingerprint due to FIPS being enabled"); return false; } if (host_fingerprint == null || !RequiredFingerprint.Equals (host_fingerprint)) { - SparkleLogger.LogInfo ("Auth", "Fingerprint doesn't match"); + Logger.LogInfo ("Auth", "Fingerprint doesn't match"); this.errors.Add ("error: Host fingerprint doesn't match"); return false; } warn = false; - SparkleLogger.LogInfo ("Auth", "Fingerprint matches"); + Logger.LogInfo ("Auth", "Fingerprint matches"); } else { - SparkleLogger.LogInfo ("Auth", "Skipping fingerprint check"); + Logger.LogInfo ("Auth", "Skipping fingerprint check"); } AcceptHostKey (host_key, warn); @@ -90,11 +90,11 @@ namespace SparkleLib { private string FetchHostKey () { - SparkleLogger.LogInfo ("Auth", "Fetching host key for " + RemoteUrl.Host); + Logger.LogInfo ("Auth", "Fetching host key for " + RemoteUrl.Host); Process process = new Process (); process.StartInfo.FileName = "ssh-keyscan"; - process.StartInfo.WorkingDirectory = SparkleConfig.DefaultConfig.TmpPath; + process.StartInfo.WorkingDirectory = Configuration.DefaultConfig.TmpPath; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.CreateNoWindow = true; @@ -108,7 +108,7 @@ namespace SparkleLib { else process.StartInfo.Arguments = "-t " + key_type + " -p " + RemoteUrl.Port + " " + RemoteUrl.Host; - SparkleLogger.LogInfo ("Cmd", process.StartInfo.FileName + " " + process.StartInfo.Arguments); + Logger.LogInfo ("Cmd", process.StartInfo.FileName + " " + process.StartInfo.Arguments); process.Start (); string host_key = process.StandardOutput.ReadToEnd ().Trim (); @@ -134,7 +134,7 @@ namespace SparkleLib { return fingerprint.ToLower ().Replace ("-", ":"); } catch (Exception e) { - SparkleLogger.LogInfo ("Fetcher", "Failed creating fingerprint: " + e.Message + " " + e.StackTrace); + Logger.LogInfo ("Fetcher", "Failed creating fingerprint: " + e.Message + " " + e.StackTrace); return null; } } @@ -143,7 +143,7 @@ namespace SparkleLib { private void AcceptHostKey (string host_key, bool warn) { // TODO: Make a proper member for this - string config_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath); + string config_path = Path.GetDirectoryName (Configuration.DefaultConfig.FullPath); string ssh_config_path = Path.Combine (config_path, "ssh"); string known_hosts_file_path = Path.Combine (ssh_config_path, "known_hosts"); @@ -169,7 +169,7 @@ namespace SparkleLib { else File.AppendAllText (known_hosts_file_path, "\n" + host_key + "\n"); - SparkleLogger.LogInfo ("Auth", "Accepted host key for " + host); + Logger.LogInfo ("Auth", "Accepted host key for " + host); if (warn) this.warnings.Add ("The following host key has been accepted:\n" + DeriveFingerprint (host_key)); diff --git a/SparkleLib/Git/SparkleGit.cs b/SparkleLib/Git/GitCommand.cs similarity index 91% rename from SparkleLib/Git/SparkleGit.cs rename to SparkleLib/Git/GitCommand.cs index 16bf5566..4b85a5a6 100644 --- a/SparkleLib/Git/SparkleGit.cs +++ b/SparkleLib/Git/GitCommand.cs @@ -17,7 +17,7 @@ namespace SparkleLib.Git { - public class SparkleGit : SparkleProcess { + public class GitCommand : Command { public static string SSHPath; public static string GitPath; @@ -26,13 +26,13 @@ namespace SparkleLib.Git { public static string GitVersion { get { - string git_version = new SparkleProcess (GitPath, "--version").StartAndReadStandardOutput (); + string git_version = new Command (GitPath, "--version").StartAndReadStandardOutput (); return git_version.Replace ("git version ", ""); } } - public SparkleGit (string path, string args) : base (path, args) + public GitCommand (string path, string args) : base (path, args) { if (GitPath == null) GitPath = LocateCommand ("git"); diff --git a/SparkleLib/Git/SparkleFetcherGit.cs b/SparkleLib/Git/GitFetcher.cs similarity index 90% rename from SparkleLib/Git/SparkleFetcherGit.cs rename to SparkleLib/Git/GitFetcher.cs index 1f522797..5b3f49fa 100755 --- a/SparkleLib/Git/SparkleFetcherGit.cs +++ b/SparkleLib/Git/GitFetcher.cs @@ -23,9 +23,9 @@ using System.Threading; namespace SparkleLib.Git { - public class SparkleFetcher : SparkleFetcherSSH { + public class GitFetcher : SSHFetcher { - SparkleGit git; + GitCommand git; Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled); Regex speed_regex = new Regex (@"([0-9\.]+) ([KM])iB/s", RegexOptions.Compiled); @@ -35,7 +35,7 @@ namespace SparkleLib.Git { public override bool IsFetchedRepoEmpty { get { - SparkleGit git = new SparkleGit (TargetFolder, "rev-parse HEAD"); + GitCommand git = new GitCommand (TargetFolder, "rev-parse HEAD"); git.StartAndWaitForExit (); return (git.ExitCode != 0); @@ -43,7 +43,7 @@ namespace SparkleLib.Git { } - public SparkleFetcher (SparkleFetcherInfo info) : base (info) + public GitFetcher (SparkleFetcherInfo info) : base (info) { if (RemoteUrl.ToString ().StartsWith ("ssh+")) RemoteUrl = new Uri ("ssh" + RemoteUrl.ToString ().Substring (RemoteUrl.ToString ().IndexOf ("://"))); @@ -91,11 +91,11 @@ namespace SparkleLib.Git { return false; if (FetchPriorHistory) { - this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath, + this.git = new GitCommand (Configuration.DefaultConfig.TmpPath, "clone --progress --no-checkout \"" + RemoteUrl + "\" \"" + TargetFolder + "\""); } else { - this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath, + this.git = new GitCommand (Configuration.DefaultConfig.TmpPath, "clone --progress --no-checkout --depth=1 \"" + RemoteUrl + "\" \"" + TargetFolder + "\""); } @@ -119,7 +119,7 @@ namespace SparkleLib.Git { number = double.Parse (match.Groups [1].Value, new CultureInfo ("en-US")); } catch (FormatException) { - SparkleLogger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\""); + Logger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\""); } // The pushing progress consists of two stages: the "Compressing @@ -139,7 +139,7 @@ namespace SparkleLib.Git { speed = double.Parse (speed_match.Groups [1].Value, new CultureInfo ("en-US")) * 1024; } catch (FormatException) { - SparkleLogger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\""); + Logger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\""); } if (speed_match.Groups [2].Value.Equals ("M")) @@ -148,7 +148,7 @@ namespace SparkleLib.Git { } } else { - SparkleLogger.LogInfo ("Fetcher", line); + Logger.LogInfo ("Fetcher", line); line = line.Trim (new char [] {' ', '@'}); if (line.StartsWith ("fatal:", StringComparison.InvariantCultureIgnoreCase) || @@ -215,16 +215,16 @@ namespace SparkleLib.Git { } } catch (Exception e) { - SparkleLogger.LogInfo ("Fetcher", "Failed to dispose properly", e); + Logger.LogInfo ("Fetcher", "Failed to dispose properly", e); } if (Directory.Exists (TargetFolder)) { try { Directory.Delete (TargetFolder, true /* Recursive */ ); - SparkleLogger.LogInfo ("Fetcher", "Deleted '" + TargetFolder + "'"); + Logger.LogInfo ("Fetcher", "Deleted '" + TargetFolder + "'"); } catch (Exception e) { - SparkleLogger.LogInfo ("Fetcher", "Failed to delete '" + TargetFolder + "'", e); + Logger.LogInfo ("Fetcher", "Failed to delete '" + TargetFolder + "'", e); } } } @@ -233,7 +233,7 @@ namespace SparkleLib.Git { public override void Complete () { if (!IsFetchedRepoEmpty) { - SparkleGit git = new SparkleGit (TargetFolder, "checkout --quiet HEAD"); + GitCommand git = new GitCommand (TargetFolder, "checkout --quiet HEAD"); git.StartAndWaitForExit (); } @@ -259,11 +259,11 @@ namespace SparkleLib.Git { "push.default matching" }; - if (SparkleBackend.Platform == PlatformID.Win32NT) + if (Backend.Platform == PlatformID.Win32NT) settings [0] = "core.autocrlf true"; foreach (string setting in settings) { - SparkleGit git_config = new SparkleGit (TargetFolder, "config " + setting); + GitCommand git_config = new GitCommand (TargetFolder, "config " + setting); git_config.StartAndWaitForExit (); } } @@ -312,12 +312,12 @@ namespace SparkleLib.Git { public override void EnableFetchedRepoCrypto (string password) { // Set up the encryption filter - SparkleGit git_config_smudge = new SparkleGit (TargetFolder, + GitCommand git_config_smudge = new GitCommand (TargetFolder, "config filter.encryption.smudge \"openssl enc -d -aes-256-cbc -base64" + " " + "-S " + password.SHA256 (this.password_salt).Substring (0, 16) + " " + "-pass file:.git/info/encryption_password\""); - SparkleGit git_config_clean = new SparkleGit (TargetFolder, + GitCommand git_config_clean = new GitCommand (TargetFolder, "config filter.encryption.clean \"openssl enc -e -aes-256-cbc -base64" + " " + "-S " + password.SHA256 (this.password_salt).Substring (0, 16) + " " + "-pass file:.git/info/encryption_password\""); @@ -340,7 +340,7 @@ namespace SparkleLib.Git { string password_check_file_path = Path.Combine (TargetFolder, ".sparkleshare"); if (!File.Exists (password_check_file_path)) { - SparkleGit git = new SparkleGit (TargetFolder, "show HEAD:.sparkleshare"); + GitCommand git = new GitCommand (TargetFolder, "show HEAD:.sparkleshare"); string output = git.StartAndReadStandardOutput (); if (git.ExitCode == 0) @@ -352,7 +352,7 @@ namespace SparkleLib.Git { string args = "enc -d -aes-256-cbc -base64 -salt -pass pass:" + password.SHA256 (this.password_salt) + " " + "-in \"" + password_check_file_path + "\""; - var process = new SparkleProcess ("openssl", args); + var process = new Command ("openssl", args); process.StartInfo.WorkingDirectory = TargetFolder; process.StartAndWaitForExit (); diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/GitRepository.cs similarity index 86% rename from SparkleLib/Git/SparkleRepoGit.cs rename to SparkleLib/Git/GitRepository.cs index fa813e35..ef099559 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/GitRepository.cs @@ -25,7 +25,7 @@ using System.Threading; namespace SparkleLib.Git { - public class SparkleRepo : SparkleRepoBase { + public class GitRepository : BaseRepository { private bool user_is_set; private bool is_encrypted; @@ -53,7 +53,7 @@ namespace SparkleLib.Git { if (!string.IsNullOrEmpty (this.cached_branch)) return this.cached_branch; - SparkleGit git = new SparkleGit (LocalPath, "config core.ignorecase true"); + GitCommand git = new GitCommand (LocalPath, "config core.ignorecase true"); git.StartAndWaitForExit (); while (this.in_merge && HasLocalChanges) { @@ -61,14 +61,14 @@ namespace SparkleLib.Git { ResolveConflict (); } catch (IOException e) { - SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); + Logger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); } } - git = new SparkleGit (LocalPath, "config core.ignorecase false"); + git = new GitCommand (LocalPath, "config core.ignorecase false"); git.StartAndWaitForExit (); - git = new SparkleGit (LocalPath, "rev-parse --abbrev-ref HEAD"); + git = new GitCommand (LocalPath, "rev-parse --abbrev-ref HEAD"); this.cached_branch = git.StartAndReadStandardOutput (); return this.cached_branch; @@ -84,12 +84,12 @@ namespace SparkleLib.Git { } - public SparkleRepo (string path, SparkleConfig config) : base (path, config) + public GitRepository (string path, Configuration config) : base (path, config) { - SparkleGit git = new SparkleGit (LocalPath, "config core.ignorecase false"); + GitCommand git = new GitCommand (LocalPath, "config core.ignorecase false"); git.StartAndWaitForExit (); - git = new SparkleGit (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\""); + git = new GitCommand (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\""); git.StartAndWaitForExit (); string password_file_path = Path.Combine (LocalPath, ".git", "password"); @@ -154,7 +154,7 @@ namespace SparkleLib.Git { public override string CurrentRevision { get { - SparkleGit git = new SparkleGit (LocalPath, "rev-parse HEAD"); + GitCommand git = new GitCommand (LocalPath, "rev-parse HEAD"); string output = git.StartAndReadStandardOutput (); if (git.ExitCode == 0) @@ -167,10 +167,10 @@ namespace SparkleLib.Git { public override bool HasRemoteChanges { get { - SparkleLogger.LogInfo ("Git", Name + " | Checking for remote changes..."); + Logger.LogInfo ("Git", Name + " | Checking for remote changes..."); string current_revision = CurrentRevision; - SparkleGit git = new SparkleGit (LocalPath, "ls-remote --heads --exit-code \"" + RemoteUrl + "\" " + this.branch); + GitCommand git = new GitCommand (LocalPath, "ls-remote --heads --exit-code \"" + RemoteUrl + "\" " + this.branch); string output = git.StartAndReadStandardOutput (); if (git.ExitCode != 0) @@ -179,23 +179,23 @@ namespace SparkleLib.Git { string remote_revision = "" + output.Substring (0, 40); if (!remote_revision.Equals (current_revision)) { - git = new SparkleGit (LocalPath, "merge-base " + remote_revision + " master"); + git = new GitCommand (LocalPath, "merge-base " + remote_revision + " master"); git.StartAndWaitForExit (); if (git.ExitCode != 0) { - SparkleLogger.LogInfo ("Git", Name + " | Remote changes found, local: " + + Logger.LogInfo ("Git", Name + " | Remote changes found, local: " + current_revision + ", remote: " + remote_revision); Error = ErrorStatus.None; return true; } else { - SparkleLogger.LogInfo ("Git", Name + " | Remote " + remote_revision + " is already in our history"); + Logger.LogInfo ("Git", Name + " | Remote " + remote_revision + " is already in our history"); return false; } } - SparkleLogger.LogInfo ("Git", Name + " | No remote changes, local+remote: " + current_revision); + Logger.LogInfo ("Git", Name + " | No remote changes, local+remote: " + current_revision); return false; } } @@ -216,7 +216,7 @@ namespace SparkleLib.Git { if (message != null) Commit (message); - SparkleGit git = new SparkleGit (LocalPath, "push --progress \"" + RemoteUrl + "\" " + this.branch); + GitCommand git = new GitCommand (LocalPath, "push --progress \"" + RemoteUrl + "\" " + this.branch); git.StartInfo.RedirectStandardError = true; git.Start (); @@ -233,7 +233,7 @@ namespace SparkleLib.Git { number = double.Parse (match.Groups [1].Value, new CultureInfo ("en-US")); } catch (FormatException) { - SparkleLogger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\""); + Logger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\""); } // The pushing progress consists of two stages: the "Compressing @@ -253,7 +253,7 @@ namespace SparkleLib.Git { speed = double.Parse (speed_match.Groups [1].Value, new CultureInfo ("en-US")) * 1024; } catch (FormatException) { - SparkleLogger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\""); + Logger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\""); } if (speed_match.Groups [2].Value.Equals ("M")) @@ -262,7 +262,7 @@ namespace SparkleLib.Git { } } else { - SparkleLogger.LogInfo ("Git", Name + " | " + line); + Logger.LogInfo ("Git", Name + " | " + line); if (FindError (line)) return false; @@ -287,7 +287,7 @@ namespace SparkleLib.Git { public override bool SyncDown () { - SparkleGit git = new SparkleGit (LocalPath, "fetch --progress \"" + RemoteUrl + "\" " + this.branch); + GitCommand git = new GitCommand (LocalPath, "fetch --progress \"" + RemoteUrl + "\" " + this.branch); git.StartInfo.RedirectStandardError = true; git.Start (); @@ -305,7 +305,7 @@ namespace SparkleLib.Git { number = double.Parse (match.Groups [1].Value, new CultureInfo ("en-US")); } catch (FormatException) { - SparkleLogger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\""); + Logger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\""); } // The fetching progress consists of two stages: the "Compressing @@ -325,7 +325,7 @@ namespace SparkleLib.Git { speed = double.Parse (speed_match.Groups [1].Value, new CultureInfo ("en-US")) * 1024; } catch (FormatException) { - SparkleLogger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\""); + Logger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\""); } if (speed_match.Groups [2].Value.Equals ("M")) @@ -334,7 +334,7 @@ namespace SparkleLib.Git { } } else { - SparkleLogger.LogInfo ("Git", Name + " | " + line); + Logger.LogInfo ("Git", Name + " | " + line); if (FindError (line)) return false; @@ -367,7 +367,7 @@ namespace SparkleLib.Git { get { PrepareDirectories (LocalPath); - SparkleGit git = new SparkleGit (LocalPath, "status --porcelain"); + GitCommand git = new GitCommand (LocalPath, "status --porcelain"); string output = git.StartAndReadStandardOutput (); return !string.IsNullOrEmpty (output); @@ -395,7 +395,7 @@ namespace SparkleLib.Git { // Stages the made changes private bool Add () { - SparkleGit git = new SparkleGit (LocalPath, "add --all"); + GitCommand git = new GitCommand (LocalPath, "add --all"); git.StartAndWaitForExit (); return (git.ExitCode == 0); @@ -405,19 +405,19 @@ namespace SparkleLib.Git { // Commits the made changes private void Commit (string message) { - SparkleGit git; + GitCommand git; if (!this.user_is_set) { - git = new SparkleGit (LocalPath, "config user.name \"" + base.local_config.User.Name + "\""); + git = new GitCommand (LocalPath, "config user.name \"" + base.local_config.User.Name + "\""); git.StartAndWaitForExit (); - git = new SparkleGit (LocalPath, "config user.email \"" + base.local_config.User.Email + "\""); + git = new GitCommand (LocalPath, "config user.email \"" + base.local_config.User.Email + "\""); git.StartAndWaitForExit (); this.user_is_set = true; } - git = new SparkleGit (LocalPath, "commit --all --message=\"" + message + "\" " + + git = new GitCommand (LocalPath, "commit --all --message=\"" + message + "\" " + "--author=\"" + base.local_config.User.Name + " <" + base.local_config.User.Email + ">\""); git.StartAndReadStandardOutput (); @@ -434,11 +434,11 @@ namespace SparkleLib.Git { Commit (message); } - SparkleGit git; + GitCommand git; // Stop if we're already in a merge because something went wrong if (this.in_merge) { - git = new SparkleGit (LocalPath, "merge --abort"); + git = new GitCommand (LocalPath, "merge --abort"); git.StartAndWaitForExit (); return false; @@ -446,10 +446,10 @@ namespace SparkleLib.Git { // Temporarily change the ignorecase setting to true to avoid // conflicts in file names due to letter case changes - git = new SparkleGit (LocalPath, "config core.ignorecase true"); + git = new GitCommand (LocalPath, "config core.ignorecase true"); git.StartAndWaitForExit (); - git = new SparkleGit (LocalPath, "merge FETCH_HEAD"); + git = new GitCommand (LocalPath, "merge FETCH_HEAD"); git.StartInfo.RedirectStandardOutput = false; string error_output = git.StartAndReadStandardError (); @@ -459,34 +459,34 @@ namespace SparkleLib.Git { // error: cannot stat 'filename': Permission denied if (error_output.Contains ("error: cannot stat")) { Error = ErrorStatus.UnreadableFiles; - SparkleLogger.LogInfo ("Git", Name + " | Error status changed to " + Error); + Logger.LogInfo ("Git", Name + " | Error status changed to " + Error); - git = new SparkleGit (LocalPath, "merge --abort"); + git = new GitCommand (LocalPath, "merge --abort"); git.StartAndWaitForExit (); - git = new SparkleGit (LocalPath, "config core.ignorecase false"); + git = new GitCommand (LocalPath, "config core.ignorecase false"); git.StartAndWaitForExit (); return false; } else { - SparkleLogger.LogInfo ("Git", error_output); - SparkleLogger.LogInfo ("Git", Name + " | Conflict detected, trying to get out..."); + Logger.LogInfo ("Git", error_output); + Logger.LogInfo ("Git", Name + " | Conflict detected, trying to get out..."); while (this.in_merge && HasLocalChanges) { try { ResolveConflict (); } catch (Exception e) { - SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); + Logger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); } } - SparkleLogger.LogInfo ("Git", Name + " | Conflict resolved"); + Logger.LogInfo ("Git", Name + " | Conflict resolved"); } } - git = new SparkleGit (LocalPath, "config core.ignorecase false"); + git = new GitCommand (LocalPath, "config core.ignorecase false"); git.StartAndWaitForExit (); return true; @@ -507,7 +507,7 @@ namespace SparkleLib.Git { // UU unmerged, both modified -> Use server's, save ours as a timestamped copy // ?? unmerged, new files -> Stage the new files - SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain"); + GitCommand git_status = new GitCommand (LocalPath, "status --porcelain"); string output = git_status.StartAndReadStandardOutput (); string [] lines = output.Split ("\n".ToCharArray ()); @@ -527,14 +527,14 @@ namespace SparkleLib.Git { } } - SparkleLogger.LogInfo ("Git", Name + " | Conflict type: " + line); + Logger.LogInfo ("Git", Name + " | Conflict type: " + line); // Ignore conflicts in hidden files and use the local versions if (conflicting_path.EndsWith (".sparkleshare") || conflicting_path.EndsWith (".empty")) { - SparkleLogger.LogInfo ("Git", Name + " | Ignoring conflict in special file: " + conflicting_path); + Logger.LogInfo ("Git", Name + " | Ignoring conflict in special file: " + conflicting_path); // Recover local version - SparkleGit git_ours = new SparkleGit (LocalPath, "checkout --ours \"" + conflicting_path + "\""); + GitCommand git_ours = new GitCommand (LocalPath, "checkout --ours \"" + conflicting_path + "\""); git_ours.StartAndWaitForExit (); string abs_conflicting_path = Path.Combine (LocalPath, conflicting_path); @@ -545,14 +545,14 @@ namespace SparkleLib.Git { continue; } - SparkleLogger.LogInfo ("Git", Name + " | Resolving: " + conflicting_path); + Logger.LogInfo ("Git", Name + " | Resolving: " + conflicting_path); // Both the local and server version have been modified if (line.StartsWith ("UU") || line.StartsWith ("AA") || line.StartsWith ("AU") || line.StartsWith ("UA")) { // Recover local version - SparkleGit git_ours = new SparkleGit (LocalPath, "checkout --ours \"" + conflicting_path + "\""); + GitCommand git_ours = new GitCommand (LocalPath, "checkout --ours \"" + conflicting_path + "\""); git_ours.StartAndWaitForExit (); // Append a timestamp to local version. @@ -569,7 +569,7 @@ namespace SparkleLib.Git { File.Move (abs_conflicting_path, abs_our_path); // Recover server version - SparkleGit git_theirs = new SparkleGit (LocalPath, "checkout --theirs \"" + conflicting_path + "\""); + GitCommand git_theirs = new GitCommand (LocalPath, "checkout --theirs \"" + conflicting_path + "\""); git_theirs.StartAndWaitForExit (); trigger_conflict_event = true; @@ -580,7 +580,7 @@ namespace SparkleLib.Git { // The modified local version is already in the checkout, so it just needs to be added. // We need to specifically mention the file, so we can't reuse the Add () method - SparkleGit git_add = new SparkleGit (LocalPath, "add \"" + conflicting_path + "\""); + GitCommand git_add = new GitCommand (LocalPath, "add \"" + conflicting_path + "\""); git_add.StartAndWaitForExit (); @@ -588,26 +588,26 @@ namespace SparkleLib.Git { } else if (line.StartsWith ("UD")) { // Recover server version - SparkleGit git_theirs = new SparkleGit (LocalPath, "checkout --theirs \"" + conflicting_path + "\""); + GitCommand git_theirs = new GitCommand (LocalPath, "checkout --theirs \"" + conflicting_path + "\""); git_theirs.StartAndWaitForExit (); // Server and local versions were removed } else if (line.StartsWith ("DD")) { - SparkleLogger.LogInfo ("Git", Name + " | No need to resolve: " + line); + Logger.LogInfo ("Git", Name + " | No need to resolve: " + line); // New local files } else if (line.StartsWith ("??")) { - SparkleLogger.LogInfo ("Git", Name + " | Found new file, no need to resolve: " + line); + Logger.LogInfo ("Git", Name + " | Found new file, no need to resolve: " + line); } else { - SparkleLogger.LogInfo ("Git", Name + " | Don't know what to do with: " + line); + Logger.LogInfo ("Git", Name + " | Don't know what to do with: " + line); } } Add (); - SparkleGit git = new SparkleGit (LocalPath, "commit --message \"Conflict resolution by SparkleShare\""); + GitCommand git = new GitCommand (LocalPath, "commit --message \"Conflict resolution by SparkleShare\""); git.StartInfo.RedirectStandardOutput = false; git.StartAndWaitForExit (); @@ -624,13 +624,13 @@ namespace SparkleLib.Git { if (revision == null) throw new ArgumentNullException ("revision"); - SparkleLogger.LogInfo ("Git", Name + " | Restoring \"" + path + "\" (revision " + revision + ")"); + Logger.LogInfo ("Git", Name + " | Restoring \"" + path + "\" (revision " + revision + ")"); // git-show doesn't decrypt objects, so we can't use it to retrieve // files from the index. This is a suboptimal workaround but it does the job if (this.is_encrypted) { // Restore the older file... - SparkleGit git = new SparkleGit (LocalPath, "checkout " + revision + " \"" + path + "\""); + GitCommand git = new GitCommand (LocalPath, "checkout " + revision + " \"" + path + "\""); git.StartAndWaitForExit (); string local_file_path = Path.Combine (LocalPath, path); @@ -640,19 +640,19 @@ namespace SparkleLib.Git { File.Move (local_file_path, target_file_path); } catch { - SparkleLogger.LogInfo ("Git", + Logger.LogInfo ("Git", Name + " | Could not move \"" + local_file_path + "\" to \"" + target_file_path + "\""); } // ...and restore the most recent revision - git = new SparkleGit (LocalPath, "checkout " + CurrentRevision + " \"" + path + "\""); + git = new GitCommand (LocalPath, "checkout " + CurrentRevision + " \"" + path + "\""); git.StartAndWaitForExit (); // The correct way } else { path = path.Replace ("\"", "\\\""); - SparkleGit git = new SparkleGit (LocalPath, "show " + revision + ":\"" + path + "\""); + GitCommand git = new GitCommand (LocalPath, "show " + revision + ":\"" + path + "\""); git.Start (); FileStream stream = File.OpenWrite (target_file_path); @@ -696,7 +696,7 @@ namespace SparkleLib.Git { } if (Error != ErrorStatus.None) { - SparkleLogger.LogInfo ("Git", Name + " | Error status changed to " + Error); + Logger.LogInfo ("Git", Name + " | Error status changed to " + Error); return true; } else { @@ -712,36 +712,36 @@ namespace SparkleLib.Git { } - public override List GetChangeSets () + public override List GetChangeSets () { return GetChangeSetsInternal (null); } - public override List GetChangeSets (string path) + public override List GetChangeSets (string path) { return GetChangeSetsInternal (path); } - private List GetChangeSetsInternal (string path) + private List GetChangeSetsInternal (string path) { - List change_sets = new List (); - SparkleGit git; + List change_sets = new List (); + GitCommand git; if (path == null) { - git = new SparkleGit (LocalPath, "log --since=1.month --raw --find-renames --date=iso " + + git = new GitCommand (LocalPath, "log --since=1.month --raw --find-renames --date=iso " + "--format=medium --no-color --no-merges"); } else { path = path.Replace ("\\", "/"); - git = new SparkleGit (LocalPath, "log --raw --find-renames --date=iso " + + git = new GitCommand (LocalPath, "log --raw --find-renames --date=iso " + "--format=medium --no-color --no-merges -- \"" + path + "\""); } string output = git.StartAndReadStandardOutput (); if (path == null && string.IsNullOrWhiteSpace (output)) { - git = new SparkleGit (LocalPath, "log -n 75 --raw --find-renames --date=iso " + + git = new GitCommand (LocalPath, "log -n 75 --raw --find-renames --date=iso " + "--format=medium --no-color --no-merges"); output = git.StartAndReadStandardOutput (); @@ -786,11 +786,11 @@ namespace SparkleLib.Git { continue; } - SparkleChangeSet change_set = new SparkleChangeSet (); + ChangeSet change_set = new ChangeSet (); change_set.Folder = new SparkleFolder (Name); change_set.Revision = match.Groups [1].Value; - change_set.User = new SparkleUser (match.Groups [2].Value, match.Groups [3].Value); + change_set.User = new User (match.Groups [2].Value, match.Groups [3].Value); change_set.RemoteUrl = RemoteUrl; change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value), @@ -829,7 +829,7 @@ namespace SparkleLib.Git { file_path = EnsureSpecialCharacters (file_path); } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error parsing file name '" + file_path + "'", e); + Logger.LogInfo ("Local", "Error parsing file name '" + file_path + "'", e); continue; } @@ -851,7 +851,7 @@ namespace SparkleLib.Git { file_path = EnsureSpecialCharacters (file_path); } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error parsing file name '" + file_path + "'", e); + Logger.LogInfo ("Local", "Error parsing file name '" + file_path + "'", e); continue; } @@ -859,7 +859,7 @@ namespace SparkleLib.Git { to_file_path = EnsureSpecialCharacters (to_file_path); } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error parsing file name '" + to_file_path + "'", e); + Logger.LogInfo ("Local", "Error parsing file name '" + to_file_path + "'", e); continue; } @@ -892,7 +892,7 @@ namespace SparkleLib.Git { // Group commits per user, per day if (change_sets.Count > 0 && path == null) { - SparkleChangeSet last_change_set = change_sets [change_sets.Count - 1]; + ChangeSet last_change_set = change_sets [change_sets.Count - 1]; if (change_set.Timestamp.Year == last_change_set.Timestamp.Year && change_set.Timestamp.Month == last_change_set.Timestamp.Month && @@ -997,7 +997,7 @@ namespace SparkleLib.Git { if (File.Exists (HEAD_file_path)) { File.Move (HEAD_file_path, HEAD_file_path + ".backup"); - SparkleLogger.LogInfo ("Git", Name + " | Renamed " + HEAD_file_path); + Logger.LogInfo ("Git", Name + " | Renamed " + HEAD_file_path); } continue; @@ -1016,13 +1016,13 @@ namespace SparkleLib.Git { File.SetAttributes (Path.Combine (path, ".empty"), FileAttributes.Hidden); } catch { - SparkleLogger.LogInfo ("Git", Name + " | Failed adding empty folder " + path); + Logger.LogInfo ("Git", Name + " | Failed adding empty folder " + path); } } } } catch (IOException e) { - SparkleLogger.LogInfo ("Git", "Failed preparing directory", e); + Logger.LogInfo ("Git", "Failed preparing directory", e); } } @@ -1032,7 +1032,7 @@ namespace SparkleLib.Git { { List changes = new List (); - SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain"); + GitCommand git_status = new GitCommand (LocalPath, "status --porcelain"); git_status.Start (); while (!git_status.StandardOutput.EndOfStream) { @@ -1127,7 +1127,7 @@ namespace SparkleLib.Git { } } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error calculating directory size", e); + Logger.LogInfo ("Local", "Error calculating directory size", e); } try { @@ -1142,7 +1142,7 @@ namespace SparkleLib.Git { } } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error calculating file size", e); + Logger.LogInfo ("Local", "Error calculating file size", e); } return size; diff --git a/SparkleLib/Git/SparkleLib.Git.csproj b/SparkleLib/Git/SparkleLib.Git.csproj index ddfed9db..8023d098 100644 --- a/SparkleLib/Git/SparkleLib.Git.csproj +++ b/SparkleLib/Git/SparkleLib.Git.csproj @@ -52,8 +52,8 @@ - - - + + + diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/Listener/BaseListener.cs similarity index 84% rename from SparkleLib/SparkleListenerBase.cs rename to SparkleLib/Listener/BaseListener.cs index 152b6254..d996f8de 100755 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/Listener/BaseListener.cs @@ -30,7 +30,7 @@ namespace SparkleLib { // A persistent connection to the server that // listens for change notifications - public abstract class SparkleListenerBase { + public abstract class BaseListener { public event Action Connected = delegate { }; @@ -66,7 +66,7 @@ namespace SparkleLib { }; - public SparkleListenerBase (Uri server, string folder_identifier) + public BaseListener (Uri server, string folder_identifier) { Server = server; this.channels.Add (folder_identifier); @@ -85,19 +85,19 @@ namespace SparkleLib { { if (!IsRecentAnnouncement (announcement)) { if (IsConnected) { - SparkleLogger.LogInfo ("Listener", "Announcing message " + announcement.Message + + Logger.LogInfo ("Listener", "Announcing message " + announcement.Message + " to " + announcement.FolderIdentifier + " on " + Server); AnnounceInternal (announcement); AddRecentAnnouncement (announcement); } else { - SparkleLogger.LogInfo ("Listener", "Can't send message to " + Server + ". Queuing message"); + Logger.LogInfo ("Listener", "Can't send message to " + Server + ". Queuing message"); this.queue_up [announcement.FolderIdentifier] = announcement; } } else { - SparkleLogger.LogInfo ("Listener", "Already processed message " + announcement.Message + + Logger.LogInfo ("Listener", "Already processed message " + announcement.Message + " to " + announcement.FolderIdentifier + " from " + Server); } } @@ -109,7 +109,7 @@ namespace SparkleLib { this.channels.Add (channel); if (IsConnected) { - SparkleLogger.LogInfo ("Listener", "Subscribing to channel " + channel + " on " + Server); + Logger.LogInfo ("Listener", "Subscribing to channel " + channel + " on " + Server); AlsoListenToInternal (channel); } } @@ -117,7 +117,7 @@ namespace SparkleLib { public void Reconnect () { - SparkleLogger.LogInfo ("Listener", "Trying to reconnect to " + Server); + Logger.LogInfo ("Listener", "Trying to reconnect to " + Server); Connect (); } @@ -125,15 +125,15 @@ namespace SparkleLib { public void OnConnected () { foreach (string channel in this.channels.GetRange (0, this.channels.Count)) { - SparkleLogger.LogInfo ("Listener", "Subscribing to channel " + channel + " on " + Server); + Logger.LogInfo ("Listener", "Subscribing to channel " + channel + " on " + Server); AlsoListenToInternal (channel); } - SparkleLogger.LogInfo ("Listener", "Listening for announcements on " + Server); + Logger.LogInfo ("Listener", "Listening for announcements on " + Server); Connected (); if (this.queue_up.Count > 0) { - SparkleLogger.LogInfo ("Listener", "Delivering " + this.queue_up.Count + " queued messages..."); + Logger.LogInfo ("Listener", "Delivering " + this.queue_up.Count + " queued messages..."); foreach (KeyValuePair item in this.queue_up) { SparkleAnnouncement announcement = item.Value; @@ -145,14 +145,14 @@ namespace SparkleLib { public void OnDisconnected (DisconnectReason reason, string message) { - SparkleLogger.LogInfo ("Listener", "Disconnected from " + Server + ": " + message); + Logger.LogInfo ("Listener", "Disconnected from " + Server + ": " + message); Disconnected (reason); } public void OnAnnouncement (SparkleAnnouncement announcement) { - SparkleLogger.LogInfo ("Listener", "Got message " + announcement.Message + " from " + + Logger.LogInfo ("Listener", "Got message " + announcement.Message + " from " + announcement.FolderIdentifier + " on " + Server); if (IsRecentAnnouncement (announcement)) diff --git a/SparkleLib/SparkleListenerFactory.cs b/SparkleLib/Listener/ListenerFactory.cs similarity index 70% rename from SparkleLib/SparkleListenerFactory.cs rename to SparkleLib/Listener/ListenerFactory.cs index a42f4805..1ca2b7d4 100644 --- a/SparkleLib/SparkleListenerFactory.cs +++ b/SparkleLib/Listener/ListenerFactory.cs @@ -20,19 +20,19 @@ using System.Collections.Generic; namespace SparkleLib { - public static class SparkleListenerFactory { + public static class ListenerFactory { - private static List listeners = new List (); + private static List listeners = new List (); - public static SparkleListenerBase CreateListener (string folder_name, string folder_identifier) + public static BaseListener CreateListener (string folder_name, string folder_identifier) { // Check if the user wants to use a global custom notification service - string uri = SparkleConfig.DefaultConfig.GetConfigOption ("announcements_url"); + string uri = Configuration.DefaultConfig.GetConfigOption ("announcements_url"); // Check if the user wants a use a custom notification service for this folder if (string.IsNullOrEmpty (uri)) - uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute (folder_name, "announcements_url"); + uri = Configuration.DefaultConfig.GetFolderOptionalAttribute (folder_name, "announcements_url"); // This is SparkleShare's centralized notification service. // It communicates "It's time to sync!" signals between clients. @@ -46,21 +46,21 @@ namespace SparkleLib { // Use only one listener per notification service to keep // the number of connections as low as possible - foreach (SparkleListenerBase listener in listeners) { + foreach (BaseListener listener in listeners) { if (listener.Server.Equals (announce_uri)) { - SparkleLogger.LogInfo ("ListenerFactory", "Refered to existing listener for " + announce_uri); + Logger.LogInfo ("ListenerFactory", "Refered to existing listener for " + announce_uri); // We already seem to have a listener for this server, // refer to the existing one instead listener.AlsoListenTo (folder_identifier); - return (SparkleListenerBase) listener; + return (BaseListener) listener; } } - listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier)); - SparkleLogger.LogInfo ("ListenerFactory", "Issued new listener for " + announce_uri); + listeners.Add (new TcpListener (announce_uri, folder_identifier)); + Logger.LogInfo ("ListenerFactory", "Issued new listener for " + announce_uri); - return (SparkleListenerBase) listeners [listeners.Count - 1]; + return (BaseListener) listeners [listeners.Count - 1]; } } } diff --git a/SparkleLib/SparkleListenerTcp.cs b/SparkleLib/Listener/TcpListener.cs old mode 100755 new mode 100644 similarity index 94% rename from SparkleLib/SparkleListenerTcp.cs rename to SparkleLib/Listener/TcpListener.cs index f022cbbe..544cd9db --- a/SparkleLib/SparkleListenerTcp.cs +++ b/SparkleLib/Listener/TcpListener.cs @@ -22,7 +22,7 @@ using System.Threading; namespace SparkleLib { - public class SparkleListenerTcp : SparkleListenerBase { + public class TcpListener : BaseListener { private Socket socket; private Thread thread; @@ -31,7 +31,7 @@ namespace SparkleLib { private DateTime last_ping = DateTime.Now; - public SparkleListenerTcp (Uri server, string folder_identifier) : base (server, folder_identifier) + public TcpListener (Uri server, string folder_identifier) : base (server, folder_identifier) { } @@ -104,7 +104,7 @@ namespace SparkleLib { // We've timed out, let's ping the server to // see if the connection is still up if (i == timeout) { - SparkleLogger.LogInfo ("ListenerTcp", "Pinging " + Server); + Logger.LogInfo ("ListenerTcp", "Pinging " + Server); byte [] ping_bytes = Encoding.UTF8.GetBytes ("ping\n"); byte [] pong_bytes = new byte [4096]; @@ -115,7 +115,7 @@ namespace SparkleLib { // 10057 means "Socket is not connected" throw new SocketException (10057); - SparkleLogger.LogInfo ("ListenerTcp", "Received pong from " + Server); + Logger.LogInfo ("ListenerTcp", "Received pong from " + Server); i = 0; this.last_ping = DateTime.Now; @@ -132,7 +132,7 @@ namespace SparkleLib { ); if (sleepiness <= 0) { - SparkleLogger.LogInfo ("ListenerTcp", "System woke up from sleep"); + Logger.LogInfo ("ListenerTcp", "System woke up from sleep"); reason = DisconnectReason.SystemSleep; // 10057 means "Socket is not connected" diff --git a/SparkleLib/SparkleLogger.cs b/SparkleLib/Logger.cs old mode 100755 new mode 100644 similarity index 84% rename from SparkleLib/SparkleLogger.cs rename to SparkleLib/Logger.cs index 9f43a0dd..df93e57e --- a/SparkleLib/SparkleLogger.cs +++ b/SparkleLib/Logger.cs @@ -20,7 +20,7 @@ using System.IO; namespace SparkleLib { - public static class SparkleLogger { + public static class Logger { static object debug_lock = new object (); static int log_size; @@ -45,16 +45,16 @@ namespace SparkleLib { if (exception != null) line += ": " + exception.Message + " " + exception.StackTrace; - if (SparkleConfig.DebugMode) + if (Configuration.DebugMode) Console.WriteLine (line); lock (debug_lock) { if (log_size >= 1000) { - File.WriteAllText (SparkleConfig.DefaultConfig.LogFilePath, line + Environment.NewLine); + File.WriteAllText (Configuration.DefaultConfig.LogFilePath, line + Environment.NewLine); log_size = 0; } else { - File.AppendAllText (SparkleConfig.DefaultConfig.LogFilePath, line + Environment.NewLine); + File.AppendAllText (Configuration.DefaultConfig.LogFilePath, line + Environment.NewLine); log_size++; } } @@ -65,7 +65,7 @@ namespace SparkleLib { { string home_path = Environment.GetFolderPath (Environment.SpecialFolder.Personal); - if (SparkleBackend.Platform == PlatformID.Win32NT) + if (Backend.Platform == PlatformID.Win32NT) home_path = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile); string crash_report_file_path = new string [] { home_path, "SparkleShare", "crash_report.txt" }.Combine (); @@ -76,16 +76,16 @@ namespace SparkleLib { "https://github.com/hbons/SparkleShare/issues and include the lines below." + n + n + "Remove any sensitive information like file names, IP addresses, domain names, etc. if needed." + n + n + "------" + n + n + - "SparkleShare version: " + SparkleBackend.Version + n + - "Operating system: " + SparkleBackend.Platform + " (" + Environment.OSVersion + ")" + n; + "SparkleShare version: " + Backend.Version + n + + "Operating system: " + Backend.Platform + " (" + Environment.OSVersion + ")" + n; crash_report += e.GetType () + ": " + e.Message + n + e.StackTrace + n; if (e.InnerException != null) crash_report += n + e.InnerException.Message + n + e.InnerException.StackTrace + n; - if (SparkleConfig.DefaultConfig != null && File.Exists (SparkleConfig.DefaultConfig.LogFilePath)) { - string debug_log = File.ReadAllText (SparkleConfig.DefaultConfig.LogFilePath); + if (Configuration.DefaultConfig != null && File.Exists (Configuration.DefaultConfig.LogFilePath)) { + string debug_log = File.ReadAllText (Configuration.DefaultConfig.LogFilePath); string [] debug_lines = debug_log.Split (Environment.NewLine.ToCharArray ()); int line_count = 50; diff --git a/SparkleLib/Makefile.am b/SparkleLib/Makefile.am index 01261e5b..c7d34e6f 100755 --- a/SparkleLib/Makefile.am +++ b/SparkleLib/Makefile.am @@ -5,22 +5,21 @@ ASSEMBLY_INFO_SOURCE = Defines.cs SOURCES = \ AuthenticationInfo.cs \ + Backend.cs \ + BaseFetcher.cs \ + BaseListener.cs \ + BaseRepository.cs \ + Command.cs \ + Config.cs \ + Extensions.cs \ + ListenerFactory.cs \ + Logger.cs \ SSHAuthenticationInfo.cs \ - SparkleBackend.cs \ - SparkleConfig.cs \ - SparkleExtensions.cs \ - SparkleFetcherBase.cs \ - SparkleFetcherSSH.cs \ - SparkleListenerBase.cs \ - SparkleListenerFactory.cs \ - SparkleListenerTcp.cs \ - SparkleLogger.cs \ - SparkleProcess.cs \ - SparkleRepoBase.cs \ - SparkleUser.cs \ - SparkleWatcher.cs \ - SparkleWrappers.cs - + SSHFetcher.cs \ + TcpListener.cs \ + User.cs \ + Watcher.cs \ + Wrappers.cs install-data-hook: for ASM in $(EXTRA_BUNDLE); do \ diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/Repository/BaseRepository.cs old mode 100755 new mode 100644 similarity index 90% rename from SparkleLib/SparkleRepoBase.cs rename to SparkleLib/Repository/BaseRepository.cs index 33f90dd1..057af0c2 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/Repository/BaseRepository.cs @@ -45,7 +45,7 @@ namespace SparkleLib { } - public abstract class SparkleRepoBase { + public abstract class BaseRepository { public abstract bool SyncUp (); public abstract bool SyncDown (); @@ -60,8 +60,8 @@ namespace SparkleLib { public abstract List ExcludePaths { get; } public abstract List UnsyncedChanges { get; } - public abstract List GetChangeSets (); - public abstract List GetChangeSets (string path); + public abstract List GetChangeSets (); + public abstract List GetChangeSets (string path); public static bool UseCustomWatcher = false; @@ -73,7 +73,7 @@ namespace SparkleLib { public delegate void ProgressChangedEventHandler (); public event NewChangeSetEventHandler NewChangeSet = delegate { }; - public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set); + public delegate void NewChangeSetEventHandler (ChangeSet change_set); public event Action ConflictResolved = delegate { }; public event Action ChangesDetected = delegate { }; @@ -82,7 +82,7 @@ namespace SparkleLib { public readonly string LocalPath; public readonly string Name; public readonly Uri RemoteUrl; - public List ChangeSets { get; private set; } + public List ChangeSets { get; private set; } public SyncStatus Status { get; private set; } public ErrorStatus Error { get; protected set; } public bool IsBuffering { get; private set; } @@ -117,12 +117,12 @@ namespace SparkleLib { if (!string.IsNullOrEmpty (config_identifier)) this.identifier = config_identifier; else - this.identifier = SparkleFetcherBase.CreateIdentifier (); + this.identifier = BaseFetcher.CreateIdentifier (); File.WriteAllText (id_path, this.identifier); File.SetAttributes (id_path, FileAttributes.Hidden); - SparkleLogger.LogInfo ("Local", Name + " | Assigned identifier: " + this.identifier); + Logger.LogInfo ("Local", Name + " | Assigned identifier: " + this.identifier); return this.identifier; } @@ -130,12 +130,12 @@ namespace SparkleLib { } - protected SparkleConfig local_config; + protected Configuration local_config; private string identifier; - private SparkleListenerBase listener; - private SparkleWatcher watcher; + private BaseListener listener; + private Watcher watcher; private TimeSpan poll_interval = PollInterval.Short; private DateTime last_poll = DateTime.Now; private DateTime progress_last_change = DateTime.Now; @@ -152,9 +152,9 @@ namespace SparkleLib { } - public SparkleRepoBase (string path, SparkleConfig config) + public BaseRepository (string path, Configuration config) { - SparkleLogger.LogInfo (path, "Initializing..."); + Logger.LogInfo (path, "Initializing..."); Status = SyncStatus.Idle; Error = ErrorStatus.None; @@ -174,7 +174,7 @@ namespace SparkleLib { File.SetAttributes (identifier_file_path, FileAttributes.Hidden); if (!UseCustomWatcher) - this.watcher = new SparkleWatcher (LocalPath); + this.watcher = new Watcher (LocalPath); new Thread (() => CreateListener ()).Start (); @@ -270,7 +270,7 @@ namespace SparkleLib { if (!UseCustomWatcher) this.watcher.Disable (); - SparkleLogger.LogInfo ("Local", Name + " | Activity detected, waiting for it to settle..."); + Logger.LogInfo ("Local", Name + " | Activity detected, waiting for it to settle..."); List size_buffer = new List (); DirectoryInfo info = new DirectoryInfo (LocalPath); @@ -286,7 +286,7 @@ namespace SparkleLib { size_buffer [1].Equals (size_buffer [2]) && size_buffer [2].Equals (size_buffer [3])) { - SparkleLogger.LogInfo ("Local", Name + " | Activity has settled"); + Logger.LogInfo ("Local", Name + " | Activity has settled"); IsBuffering = false; bool first_sync = true; @@ -294,7 +294,7 @@ namespace SparkleLib { if (HasLocalChanges && Status == SyncStatus.Idle) { do { if (!first_sync) - SparkleLogger.LogInfo ("Local", Name + " | More changes found"); + Logger.LogInfo ("Local", Name + " | More changes found"); SyncUpBase (); @@ -360,14 +360,14 @@ namespace SparkleLib { if (!UseCustomWatcher) this.watcher.Disable (); - SparkleLogger.LogInfo ("SyncUp", Name + " | Initiated"); + Logger.LogInfo ("SyncUp", Name + " | Initiated"); HasUnsyncedChanges = true; Status = SyncStatus.SyncUp; SyncStatusChanged (Status); if (SyncUp ()) { - SparkleLogger.LogInfo ("SyncUp", Name + " | Done"); + Logger.LogInfo ("SyncUp", Name + " | Done"); ChangeSets = GetChangeSets (); HasUnsyncedChanges = false; @@ -379,7 +379,7 @@ namespace SparkleLib { SyncStatusChanged (Status); } else { - SparkleLogger.LogInfo ("SyncUp", Name + " | Error"); + Logger.LogInfo ("SyncUp", Name + " | Error"); SyncDownBase (); if (!UseCustomWatcher) @@ -416,7 +416,7 @@ namespace SparkleLib { if (!UseCustomWatcher) this.watcher.Disable (); - SparkleLogger.LogInfo ("SyncDown", Name + " | Initiated"); + Logger.LogInfo ("SyncDown", Name + " | Initiated"); Status = SyncStatus.SyncDown; SyncStatusChanged (Status); @@ -448,7 +448,7 @@ namespace SparkleLib { NewChangeSet (ChangeSets [0]); } - SparkleLogger.LogInfo ("SyncDown", Name + " | Done"); + Logger.LogInfo ("SyncDown", Name + " | Done"); // There could be changes from a resolved // conflict. Tries only once, then lets @@ -465,7 +465,7 @@ namespace SparkleLib { SyncStatusChanged (Status); } else { - SparkleLogger.LogInfo ("SyncDown", Name + " | Error"); + Logger.LogInfo ("SyncDown", Name + " | Error"); ChangeSets = GetChangeSets (); @@ -486,7 +486,7 @@ namespace SparkleLib { private void CreateListener () { - this.listener = SparkleListenerFactory.CreateListener (Name, Identifier); + this.listener = ListenerFactory.CreateListener (Name, Identifier); if (this.listener.IsConnected) this.poll_interval = PollInterval.Long; @@ -515,7 +515,7 @@ namespace SparkleLib { private void ListenerDisconnectedDelegate (DisconnectReason reason) { - SparkleLogger.LogInfo (Name, "Falling back to regular polling"); + Logger.LogInfo (Name, "Falling back to regular polling"); this.poll_interval = PollInterval.Short; this.last_disconnect_reason = reason; @@ -526,7 +526,7 @@ namespace SparkleLib { int backoff_time = 2; do { - SparkleLogger.LogInfo (Name, "Next reconnect attempt in " + backoff_time + " seconds"); + Logger.LogInfo (Name, "Next reconnect attempt in " + backoff_time + " seconds"); Thread.Sleep (backoff_time * 1000); this.listener.Connect (); backoff_time *= 2; @@ -549,10 +549,10 @@ namespace SparkleLib { while (this.is_syncing) Thread.Sleep (100); - SparkleLogger.LogInfo (Name, "Syncing due to announcement"); + Logger.LogInfo (Name, "Syncing due to announcement"); if (Status == SyncStatus.Paused) - SparkleLogger.LogInfo (Name, "We're paused, skipping sync"); + Logger.LogInfo (Name, "We're paused, skipping sync"); else SyncDownBase (); } @@ -575,7 +575,7 @@ namespace SparkleLib { size += file.Length; } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error calculating directory size", e); + Logger.LogInfo ("Local", "Error calculating directory size", e); } return size; diff --git a/SparkleLib/SparkleWrappers.cs b/SparkleLib/Repository/ChangeSet.cs similarity index 92% rename from SparkleLib/SparkleWrappers.cs rename to SparkleLib/Repository/ChangeSet.cs index 9af9df23..764d6b36 100644 --- a/SparkleLib/SparkleWrappers.cs +++ b/SparkleLib/Repository/ChangeSet.cs @@ -29,9 +29,9 @@ namespace SparkleLib { } - public class SparkleChangeSet { + public class ChangeSet { - public SparkleUser User = new SparkleUser ("Unknown", "Unknown"); + public User User = new User ("Unknown", "Unknown"); public SparkleFolder Folder; public string Revision; @@ -77,12 +77,12 @@ namespace SparkleLib { public string FullPath { get { - string custom_path = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute (Name, "path"); + string custom_path = Configuration.DefaultConfig.GetFolderOptionalAttribute (Name, "path"); if (custom_path != null) return Path.Combine (custom_path, Name); else - return Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, Name); + return Path.Combine (Configuration.DefaultConfig.FoldersPath, Name); } } diff --git a/SparkleLib/SparkleUser.cs b/SparkleLib/Repository/User.cs similarity index 92% rename from SparkleLib/SparkleUser.cs rename to SparkleLib/Repository/User.cs index 6cf7ab3d..4f4c4652 100644 --- a/SparkleLib/SparkleUser.cs +++ b/SparkleLib/Repository/User.cs @@ -17,7 +17,7 @@ namespace SparkleLib { - public class SparkleUser { + public class User { public readonly string Name; public readonly string Email; @@ -25,7 +25,7 @@ namespace SparkleLib { public string AvatarFilePath; - public SparkleUser (string name, string email) + public User (string name, string email) { Name = name; Email = email; diff --git a/SparkleLib/SparkleWatcher.cs b/SparkleLib/Repository/Watcher.cs similarity index 93% rename from SparkleLib/SparkleWatcher.cs rename to SparkleLib/Repository/Watcher.cs index 72681cc7..bb99b553 100755 --- a/SparkleLib/SparkleWatcher.cs +++ b/SparkleLib/Repository/Watcher.cs @@ -20,7 +20,7 @@ using System.IO; namespace SparkleLib { - public class SparkleWatcher : FileSystemWatcher { + public class Watcher : FileSystemWatcher { public event ChangeEventEventHandler ChangeEvent = delegate { }; public delegate void ChangeEventEventHandler (FileSystemEventArgs args); @@ -28,7 +28,7 @@ namespace SparkleLib { private object thread_lock = new object (); - public SparkleWatcher (string path) : base (path) + public Watcher (string path) : base (path) { IncludeSubdirectories = true; EnableRaisingEvents = true; diff --git a/SparkleLib/SparkleLib.csproj b/SparkleLib/SparkleLib.csproj index 6aaafa74..0a9b37de 100644 --- a/SparkleLib/SparkleLib.csproj +++ b/SparkleLib/SparkleLib.csproj @@ -32,23 +32,29 @@ - - - - - - - - - - - - + + + + - - - - + + + + + + + + + + + + + + + + + + diff --git a/SparkleShare/SparkleAboutController.cs b/SparkleShare/Common/AboutController.cs old mode 100755 new mode 100644 similarity index 91% rename from SparkleShare/SparkleAboutController.cs rename to SparkleShare/Common/AboutController.cs index 58a4c8da..bc553b4c --- a/SparkleShare/SparkleAboutController.cs +++ b/SparkleShare/Common/AboutController.cs @@ -32,16 +32,16 @@ namespace SparkleShare { public readonly string WebsiteLinkAddress = "http://www.sparkleshare.org/"; public readonly string CreditsLinkAddress = "http://github.com/hbons/SparkleShare/blob/master/legal/Authors.txt"; public readonly string ReportProblemLinkAddress = "http://www.github.com/hbons/SparkleShare/issues"; - public readonly string DebugLogLinkAddress = "file://" + Program.Controller.Config.LogFilePath; + public readonly string DebugLogLinkAddress = "file://" + SparkleShare.Controller.Config.LogFilePath; public string RunningVersion; public SparkleAboutController () { - RunningVersion = SparkleLib.SparkleBackend.Version; + RunningVersion = SparkleLib.Backend.Version; - Program.Controller.ShowAboutWindowEvent += delegate { + SparkleShare.Controller.ShowAboutWindowEvent += delegate { ShowWindowEvent (); new Thread (() => CheckForNewVersion ()).Start (); }; diff --git a/SparkleShare/SparkleAvatars.cs b/SparkleShare/Common/Avatars.cs similarity index 88% rename from SparkleShare/SparkleAvatars.cs rename to SparkleShare/Common/Avatars.cs index 2b403a35..c0cb0e65 100644 --- a/SparkleShare/SparkleAvatars.cs +++ b/SparkleShare/Common/Avatars.cs @@ -27,9 +27,9 @@ using SparkleLib; namespace SparkleShare { - public static class SparkleAvatars + public static class Avatars { - private static List skipped_avatars = new List (); + static List skipped_avatars = new List (); public static string GetAvatar (string email, int size, string target_path) @@ -64,7 +64,7 @@ namespace SparkleShare avatar_file_path = Path.Combine (avatars_path, email.MD5 ()); } catch (InvalidOperationException e) { - SparkleLogger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); + Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); return null; } @@ -87,11 +87,11 @@ namespace SparkleShare if (buffer.Length > 255) { if (!Directory.Exists (avatars_path)) { Directory.CreateDirectory (avatars_path); - SparkleLogger.LogInfo ("Avatars", "Created '" + avatars_path + "'"); + Logger.LogInfo ("Avatars", "Created '" + avatars_path + "'"); } File.WriteAllBytes (avatar_file_path, buffer); - SparkleLogger.LogInfo ("Avatars", "Fetched " + size + "x" + size + " avatar for " + email); + Logger.LogInfo ("Avatars", "Fetched " + size + "x" + size + " avatar for " + email); return avatar_file_path; @@ -100,7 +100,7 @@ namespace SparkleShare } } catch (Exception e) { - SparkleLogger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); + Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); skipped_avatars.Add (email); return null; @@ -121,7 +121,7 @@ namespace SparkleShare string gravatar_cert_fingerprint = "1264B3F00814C6077D3853238771EE67FB6321C9"; if (!certificate2.Thumbprint.Equals (gravatar_cert_fingerprint)) { - SparkleLogger.LogInfo ("Avatars", "Invalid certificate for https://www.gravatar.com/"); + Logger.LogInfo ("Avatars", "Invalid certificate for https://www.gravatar.com/"); return false; } diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/Common/BaseController.cs similarity index 90% rename from SparkleShare/SparkleControllerBase.cs rename to SparkleShare/Common/BaseController.cs index d31bb85e..d2dac560 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/Common/BaseController.cs @@ -26,9 +26,9 @@ using SparkleLib.Git; namespace SparkleShare { - public abstract class SparkleControllerBase { + public abstract class BaseController { - public SparkleRepoBase [] Repositories { + public BaseRepository [] Repositories { get { lock (this.repo_lock) return this.repositories.GetRange (0, this.repositories.Count).ToArray (); @@ -36,7 +36,7 @@ namespace SparkleShare { } - private void AddRepository (SparkleRepoBase repo) + private void AddRepository (BaseRepository repo) { lock (this.repo_lock) { this.repositories.Add (repo); @@ -45,17 +45,17 @@ namespace SparkleShare { } - private void RemoveRepository (SparkleRepoBase repo) + private void RemoveRepository (BaseRepository repo) { lock (this.repo_lock) this.repositories.Remove (repo); } - public SparkleRepoBase GetRepoByName (string name) + public BaseRepository GetRepoByName (string name) { lock (this.repo_lock) { - foreach (SparkleRepoBase repo in this.repositories) + foreach (BaseRepository repo in this.repositories) if (repo.Name.Equals (name)) return repo; } @@ -64,7 +64,7 @@ namespace SparkleShare { } - public SparkleConfig Config { get; private set; } + public Configuration Config { get; private set; } public bool RepositoriesLoaded { get; private set; } public string FoldersPath { get; private set; } @@ -102,7 +102,7 @@ namespace SparkleShare { public delegate void InviteReceivedHandler (SparkleInvite invite); public event NotificationRaisedEventHandler NotificationRaised = delegate { }; - public delegate void NotificationRaisedEventHandler (SparkleChangeSet change_set); + public delegate void NotificationRaisedEventHandler (ChangeSet change_set); public event AlertNotificationRaisedEventHandler AlertNotificationRaised = delegate { }; public delegate void AlertNotificationRaisedEventHandler (string title, string message); @@ -120,7 +120,7 @@ namespace SparkleShare { } - public SparkleUser CurrentUser { + public User CurrentUser { get { return Config.User; } set { Config.User = value; } } @@ -186,22 +186,22 @@ namespace SparkleShare { public abstract string EventEntryHTML { get; } - private SparkleFetcherBase fetcher; + private BaseFetcher fetcher; private FileSystemWatcher watcher; private Object repo_lock = new Object (); private Object check_repos_lock = new Object (); - private List repositories = new List (); + private List repositories = new List (); private bool lost_folders_path = false; - public SparkleControllerBase () + public BaseController () { string app_data_path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); string config_path = Path.Combine (app_data_path, "sparkleshare"); - Config = new SparkleConfig (config_path, "config.xml"); - SparkleConfig.DefaultConfig = Config; + Config = new Configuration (config_path, "config.xml"); + Configuration.DefaultConfig = Config; UserAuthenticationInfo = new SSHAuthenticationInfo (); SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo; @@ -212,11 +212,11 @@ namespace SparkleShare { public virtual void Initialize () { - SparkleLogger.LogInfo ("Environment", "SparkleShare " + SparkleBackend.Version); - SparkleLogger.LogInfo ("Environment", "Git " + SparkleGit.GitVersion); - SparkleLogger.LogInfo ("Environment", SparkleBackend.Platform + " (" + Environment.OSVersion + ")"); + Logger.LogInfo ("Environment", "SparkleShare " + Backend.Version); + Logger.LogInfo ("Environment", "Git " + GitCommand.GitVersion); + Logger.LogInfo ("Environment", Backend.Platform + " (" + Environment.OSVersion + ")"); - SparklePlugin.PluginsPath = PluginsPath; + Plugin.PluginsPath = PluginsPath; InstallProtocolHandler (); try { @@ -260,7 +260,7 @@ namespace SparkleShare { public void UIHasLoaded () { if (this.lost_folders_path) { - Program.UI.Bubbles.Controller.ShowBubble ("Where's your SparkleShare folder?", + SparkleShare.UI.Bubbles.Controller.ShowBubble ("Where's your SparkleShare folder?", "Did you put it on a detached drive?", null); Environment.Exit (-1); @@ -351,7 +351,7 @@ namespace SparkleShare { string new_folder_path = Path.Combine (path, folder_name); AddRepository (new_folder_path); - SparkleLogger.LogInfo ("Controller", + Logger.LogInfo ("Controller", "Renamed folder with identifier " + identifier + " to '" + folder_name + "'"); } } @@ -365,7 +365,7 @@ namespace SparkleShare { Config.RemoveFolder (folder_name); RemoveRepository (GetRepoByName (folder_name)); - SparkleLogger.LogInfo ("Controller", "Removed folder '" + folder_name + "' from config"); + Logger.LogInfo ("Controller", "Removed folder '" + folder_name + "' from config"); } else { AddRepository (folder_path); @@ -388,17 +388,17 @@ namespace SparkleShare { void AddRepository (string folder_path) { - SparkleRepoBase repo = null; + BaseRepository repo = null; string folder_name = Path.GetFileName (folder_path); string backend = Config.GetBackendForFolder (folder_name); try { - repo = (SparkleRepoBase) Activator.CreateInstance ( - Type.GetType ("SparkleLib." + backend + ".SparkleRepo, SparkleLib." + backend), + repo = (BaseRepository) Activator.CreateInstance ( + Type.GetType ("SparkleLib." + backend + "." + backend + "Repository, SparkleLib." + backend), new object [] { folder_path, Config }); } catch (Exception e) { - SparkleLogger.LogInfo ("Controller", "Failed to load backend '" + backend + "' for '" + folder_name + "': ", e); + Logger.LogInfo ("Controller", "Failed to load backend '" + backend + "' for '" + folder_name + "': ", e); return; } @@ -424,7 +424,7 @@ namespace SparkleShare { double percentage = 0.0; int repo_count = 0; - foreach (SparkleRepoBase rep in Repositories) { + foreach (BaseRepository rep in Repositories) { if (rep.ProgressPercentage > 0) { percentage += rep.ProgressPercentage; repo_count++; @@ -443,9 +443,9 @@ namespace SparkleShare { UpdateState (); }; - repo.NewChangeSet += delegate (SparkleChangeSet change_set) { + repo.NewChangeSet += delegate (ChangeSet change_set) { if (AvatarsEnabled) - change_set.User.AvatarFilePath = SparkleAvatars.GetAvatar (change_set.User.Email, 48, Config.FullPath); + change_set.User.AvatarFilePath = Avatars.GetAvatar (change_set.User.Email, 48, Config.FullPath); NotificationRaised (change_set); }; @@ -523,7 +523,7 @@ namespace SparkleShare { bool has_unsynced_repos = false; bool has_syncing_repos = false; - foreach (SparkleRepoBase repo in Repositories) { + foreach (BaseRepository repo in Repositories) { if (repo.Status == SyncStatus.SyncDown || repo.Status == SyncStatus.SyncUp || repo.IsBuffering) { has_syncing_repos = true; break; @@ -555,16 +555,16 @@ namespace SparkleShare { string backend = info.Backend; if (string.IsNullOrEmpty (backend)) - backend = SparkleFetcherBase.GetBackend (info.Address); + backend = BaseFetcher.GetBackend (info.Address); info.TargetDirectory = Path.Combine (tmp_path, canonical_name); try { - this.fetcher = (SparkleFetcherBase) Activator.CreateInstance ( + this.fetcher = (BaseFetcher) Activator.CreateInstance ( Type.GetType ("SparkleLib." + backend + ".SparkleFetcher, SparkleLib." + backend), info); } catch (Exception e) { - SparkleLogger.LogInfo ("Controller", + Logger.LogInfo ("Controller", "Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message); FolderFetchError (Path.Combine (info.Address, info.RemotePath).Replace (@"\", "/"), @@ -658,14 +658,14 @@ namespace SparkleShare { Directory.Move (this.fetcher.TargetFolder, target_folder_path); } catch (Exception e) { - SparkleLogger.LogInfo ("Controller", "Error moving directory, trying again...", e); + Logger.LogInfo ("Controller", "Error moving directory, trying again...", e); try { ClearDirectoryAttributes (this.fetcher.TargetFolder); Directory.Move (this.fetcher.TargetFolder, target_folder_path); } catch (Exception x) { - SparkleLogger.LogInfo ("Controller", "Error moving directory", x); + Logger.LogInfo ("Controller", "Error moving directory", x); this.fetcher.Dispose (); this.fetcher = null; @@ -674,7 +674,7 @@ namespace SparkleShare { } } - string backend = SparkleFetcherBase.GetBackend (this.fetcher.RemoteUrl.ToString ()); + string backend = BaseFetcher.GetBackend (this.fetcher.RemoteUrl.ToString ()); Config.AddFolder (target_folder_name, this.fetcher.Identifier, this.fetcher.RemoteUrl.ToString (), backend); @@ -699,7 +699,7 @@ namespace SparkleShare { public virtual void Quit () { - foreach (SparkleRepoBase repo in Repositories) + foreach (BaseRepository repo in Repositories) repo.Dispose (); Environment.Exit (0); diff --git a/SparkleShare/SparkleBubblesController.cs b/SparkleShare/Common/BubblesController.cs old mode 100755 new mode 100644 similarity index 87% rename from SparkleShare/SparkleBubblesController.cs rename to SparkleShare/Common/BubblesController.cs index b3eca179..b0665a85 --- a/SparkleShare/SparkleBubblesController.cs +++ b/SparkleShare/Common/BubblesController.cs @@ -30,11 +30,11 @@ namespace SparkleShare { public SparkleBubblesController () { - Program.Controller.AlertNotificationRaised += delegate (string title, string message) { + SparkleShare.Controller.AlertNotificationRaised += delegate (string title, string message) { ShowBubble (title, message, null); }; - Program.Controller.NotificationRaised += delegate (SparkleChangeSet change_set) { + SparkleShare.Controller.NotificationRaised += delegate (ChangeSet change_set) { ShowBubble (change_set.User.Name, change_set.ToMessage (), change_set.User.AvatarFilePath); }; } @@ -53,7 +53,7 @@ namespace SparkleShare { public void BubbleClicked () { - Program.Controller.ShowEventLogWindow (); + SparkleShare.Controller.ShowEventLogWindow (); } } } diff --git a/SparkleShare/SparkleEventLogController.cs b/SparkleShare/Common/EventLogController.cs old mode 100755 new mode 100644 similarity index 89% rename from SparkleShare/SparkleEventLogController.cs rename to SparkleShare/Common/EventLogController.cs index fea2e65a..82886e0f --- a/SparkleShare/SparkleEventLogController.cs +++ b/SparkleShare/Common/EventLogController.cs @@ -84,7 +84,7 @@ namespace SparkleShare { public string HTML { get { - List change_sets = GetLog (this.selected_folder); + List change_sets = GetLog (this.selected_folder); string html = GetHTMLLog (change_sets); return html; @@ -93,7 +93,7 @@ namespace SparkleShare { public string [] Folders { get { - return Program.Controller.Folders.ToArray (); + return SparkleShare.Controller.Folders.ToArray (); } } @@ -101,7 +101,7 @@ namespace SparkleShare { get { double size = 0; - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) { if (this.selected_folder == null) { size += repo.Size; @@ -124,7 +124,7 @@ namespace SparkleShare { get { double size = 0; - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) { if (this.selected_folder == null) { size += repo.HistorySize; @@ -146,7 +146,7 @@ namespace SparkleShare { public SparkleEventLogController () { - Program.Controller.ShowEventLogWindowEvent += delegate { + SparkleShare.Controller.ShowEventLogWindowEvent += delegate { if (!WindowIsOpen) { ContentLoadingEvent (); UpdateSizeInfoEvent ("…", "…"); @@ -173,7 +173,7 @@ namespace SparkleShare { ShowWindowEvent (); }; - Program.Controller.OnIdle += delegate { + SparkleShare.Controller.OnIdle += delegate { if (this.history_view_active) return; @@ -190,8 +190,8 @@ namespace SparkleShare { UpdateSizeInfoEvent (Size, HistorySize); }; - Program.Controller.FolderListChanged += delegate { - if (this.selected_folder != null && !Program.Controller.Folders.Contains (this.selected_folder)) + SparkleShare.Controller.FolderListChanged += delegate { + if (this.selected_folder != null && !SparkleShare.Controller.Folders.Contains (this.selected_folder)) this.selected_folder = null; UpdateChooserEvent (Folders); @@ -216,7 +216,7 @@ namespace SparkleShare { url = url.Replace ("%20", " "); if (url.StartsWith ("http")) { - Program.Controller.OpenWebsite (url); + SparkleShare.Controller.OpenWebsite (url); } else if (url.StartsWith ("restore://") && this.restore_revision_info == null) { Regex regex = new Regex ("restore://(.+)/([a-f0-9]+)/(.+)/(.{3} [0-9]+ [0-9]+h[0-9]+)/(.+)"); @@ -262,13 +262,13 @@ namespace SparkleShare { file_path = Uri.UnescapeDataString (file_path); - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) { if (!repo.Name.Equals (folder)) continue; new Thread (() => { SparkleDelay delay = new SparkleDelay (); - List change_sets = repo.GetChangeSets (file_path); + List change_sets = repo.GetChangeSets (file_path); string html = GetHistoryHTMLLog (change_sets, file_path); delay.Stop (); @@ -281,14 +281,14 @@ namespace SparkleShare { } } else { - Program.Controller.OpenFile (url); + SparkleShare.Controller.OpenFile (url); } } public void SaveDialogCompleted (string target_file_path) { - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) { if (repo.Name.Equals (this.restore_revision_info.Folder.Name)) { repo.RestoreFile (this.restore_revision_info.FilePath, this.restore_revision_info.Revision, target_file_path); @@ -298,7 +298,7 @@ namespace SparkleShare { } this.restore_revision_info = null; - Program.Controller.OpenFolder (Path.GetDirectoryName (target_file_path)); + SparkleShare.Controller.OpenFolder (Path.GetDirectoryName (target_file_path)); } @@ -308,17 +308,17 @@ namespace SparkleShare { } - private List GetLog () + private List GetLog () { - List list = new List (); + List list = new List (); - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { - List change_sets = repo.ChangeSets; + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) { + List change_sets = repo.ChangeSets; if (change_sets != null) list.AddRange (change_sets); else - SparkleLogger.LogInfo ("Log", "Could not create log for " + repo.Name); + Logger.LogInfo ("Log", "Could not create log for " + repo.Name); } list.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp))); @@ -331,14 +331,14 @@ namespace SparkleShare { } - private List GetLog (string name) + private List GetLog (string name) { if (name == null) return GetLog (); - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) { if (repo.Name.Equals (name)) { - List change_sets = repo.ChangeSets; + List change_sets = repo.ChangeSets; if (change_sets != null) return change_sets; @@ -347,11 +347,11 @@ namespace SparkleShare { } } - return new List (); + return new List (); } - public string GetHistoryHTMLLog (List change_sets, string file_path) + public string GetHistoryHTMLLog (List change_sets, string file_path) { string html = "
" + "« Back  |  "; @@ -367,7 +367,7 @@ namespace SparkleShare { if (change_sets.Count > 0) change_sets.RemoveAt (0); - foreach (SparkleChangeSet change_set in change_sets) { + foreach (ChangeSet change_set in change_sets) { html += "" + "" + "" + change_set.User.Name + "" + @@ -385,16 +385,16 @@ namespace SparkleShare { } html += "
"; - html = Program.Controller.EventLogHTML.Replace ("", html); + html = SparkleShare.Controller.EventLogHTML.Replace ("", html); return html.Replace ("", "100000000"); } - public string GetHTMLLog (List change_sets) + public string GetHTMLLog (List change_sets) { if (change_sets == null || change_sets.Count == 0) - return Program.Controller.EventLogHTML.Replace ("", + return SparkleShare.Controller.EventLogHTML.Replace ("", "
This project does not keep a history.
"); List activity_days = new List (); @@ -402,7 +402,7 @@ namespace SparkleShare { change_sets.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp))); change_sets.Reverse (); - foreach (SparkleChangeSet change_set in change_sets) { + foreach (ChangeSet change_set in change_sets) { bool change_set_inserted = false; foreach (ActivityDay stored_activity_day in activity_days) { @@ -424,15 +424,15 @@ namespace SparkleShare { } } - string event_log_html = Program.Controller.EventLogHTML; - string day_entry_html = Program.Controller.DayEntryHTML; - string event_entry_html = Program.Controller.EventEntryHTML; + string event_log_html = SparkleShare.Controller.EventLogHTML; + string day_entry_html = SparkleShare.Controller.DayEntryHTML; + string event_entry_html = SparkleShare.Controller.EventEntryHTML; string event_log = ""; foreach (ActivityDay activity_day in activity_days) { string event_entries = ""; - foreach (SparkleChangeSet change_set in activity_day) { + foreach (ChangeSet change_set in activity_day) { string event_entry = "
"; foreach (SparkleChange change in change_set.Changes) { @@ -590,12 +590,12 @@ namespace SparkleShare { } - private string GetAvatarFilePath (SparkleUser user) + private string GetAvatarFilePath (User user) { - if (!Program.Controller.AvatarsEnabled) + if (!SparkleShare.Controller.AvatarsEnabled) return "/user-icon-default.png"; - string fetched_avatar = SparkleAvatars.GetAvatar (user.Email, 48, Program.Controller.Config.FullPath); + string fetched_avatar = Avatars.GetAvatar (user.Email, 48, SparkleShare.Controller.Config.FullPath); if (!string.IsNullOrEmpty (fetched_avatar)) return "file://" + fetched_avatar.Replace ("\\", "/"); @@ -605,7 +605,7 @@ namespace SparkleShare { // All change sets that happened on a day - private class ActivityDay : List + private class ActivityDay : List { public DateTime Date; diff --git a/SparkleShare/SparkleInvite.cs b/SparkleShare/Common/Invite.cs similarity index 84% rename from SparkleShare/SparkleInvite.cs rename to SparkleShare/Common/Invite.cs index 7ce67eb9..7a8098bc 100644 --- a/SparkleShare/SparkleInvite.cs +++ b/SparkleShare/Common/Invite.cs @@ -40,13 +40,13 @@ namespace SparkleShare { } - public SparkleInvite (string xml_file_path) : base () + public SparkleInvite (string xml_file_path) { try { Load (xml_file_path); } catch (XmlException e) { - SparkleLogger.LogInfo ("Invite", "Error parsing XML", e); + Logger.LogInfo ("Invite", "Error parsing XML", e); return; } @@ -88,12 +88,12 @@ namespace SparkleShare { response.Close (); } catch (WebException e) { - SparkleLogger.LogInfo ("Invite", "Failed uploading public key to " + AcceptUrl + "", e); + Logger.LogInfo ("Invite", "Failed uploading public key to " + AcceptUrl + "", e); return false; } if (response != null && response.StatusCode == HttpStatusCode.OK) { - SparkleLogger.LogInfo ("Invite", "Uploaded public key to " + AcceptUrl); + Logger.LogInfo ("Invite", "Uploaded public key to " + AcceptUrl); return true; } @@ -101,20 +101,20 @@ namespace SparkleShare { } - private string ReadField (string name) + string ReadField (string name) { try { XmlNode node = SelectSingleNode ("/sparkleshare/invite/" + name + "/text()"); - + if (node != null) - return node.Value; - else - return ""; - + return node.Value; + + return ""; + } catch (XmlException e) { - SparkleLogger.LogInfo ("Invite", "Error reading field '" + name + "'", e); + Logger.LogInfo ("Invite", "Error reading field '" + name + "'", e); return ""; } } } -} \ No newline at end of file +} diff --git a/SparkleShare/SparkleNoteController.cs b/SparkleShare/Common/NoteController.cs old mode 100755 new mode 100644 similarity index 79% rename from SparkleShare/SparkleNoteController.cs rename to SparkleShare/Common/NoteController.cs index 3ea76a52..edd09fde --- a/SparkleShare/SparkleNoteController.cs +++ b/SparkleShare/Common/NoteController.cs @@ -36,11 +36,11 @@ namespace SparkleShare { public SparkleNoteController () { - Program.Controller.ShowNoteWindowEvent += OnNoteWindowEvent; + SparkleShare.Controller.ShowNoteWindowEvent += OnNoteWindowEvent; - if (Program.Controller.AvatarsEnabled && !Program.Controller.FirstRun) - AvatarFilePath = SparkleAvatars.GetAvatar (Program.Controller.CurrentUser.Email, - 48, Program.Controller.Config.FullPath); + if (SparkleShare.Controller.AvatarsEnabled && !SparkleShare.Controller.FirstRun) + AvatarFilePath = Avatars.GetAvatar (SparkleShare.Controller.CurrentUser.Email, + 48, SparkleShare.Controller.Config.FullPath); } @@ -74,7 +74,7 @@ namespace SparkleShare { void ResumeWithNote (string note) { - SparkleRepoBase repo = Program.Controller.GetRepoByName (CurrentProject); + BaseRepository repo = SparkleShare.Controller.GetRepoByName (CurrentProject); repo.Resume (note); } } diff --git a/SparkleShare/SparklePlugin.cs b/SparkleShare/Common/Plugin.cs similarity index 94% rename from SparkleShare/SparklePlugin.cs rename to SparkleShare/Common/Plugin.cs index c80d2d8a..264affd0 100644 --- a/SparkleShare/SparklePlugin.cs +++ b/SparkleShare/Common/Plugin.cs @@ -22,7 +22,7 @@ using IO = System.IO; namespace SparkleShare { - public class SparklePlugin : XmlDocument { + public class Plugin : XmlDocument { public static string PluginsPath = ""; @@ -65,14 +65,14 @@ namespace SparkleShare { private string plugin_directory; - public SparklePlugin (string plugin_path) + public Plugin (string plugin_path) { this.plugin_directory = System.IO.Path.GetDirectoryName (plugin_path); Load (plugin_path); } - public static SparklePlugin Create (string name, string description, string address_value, + public static Plugin Create (string name, string description, string address_value, string address_example, string path_value, string path_example) { string plugin_path = System.IO.Path.Combine (LocalPluginsPath, name + ".xml"); @@ -106,7 +106,7 @@ namespace SparkleShare { IO.Directory.CreateDirectory (LocalPluginsPath); IO.File.WriteAllText (plugin_path, plugin_xml); - return new SparklePlugin (plugin_path); + return new Plugin (plugin_path); } diff --git a/SparkleShare/SparkleSetupController.cs b/SparkleShare/Common/SetupController.cs old mode 100755 new mode 100644 similarity index 83% rename from SparkleShare/SparkleSetupController.cs rename to SparkleShare/Common/SetupController.cs index 605f1c59..54c7252b --- a/SparkleShare/SparkleSetupController.cs +++ b/SparkleShare/Common/SetupController.cs @@ -73,8 +73,8 @@ namespace SparkleShare { public event ChangePathFieldEventHandler ChangePathFieldEvent = delegate { }; public delegate void ChangePathFieldEventHandler (string text, string example_text, FieldState state); - public readonly List Plugins = new List (); - public SparklePlugin SelectedPlugin; + public readonly List Plugins = new List (); + public Plugin SelectedPlugin; public bool WindowIsOpen { get; private set; } public SparkleInvite PendingInvite { get; private set; } @@ -117,44 +117,44 @@ namespace SparkleShare { PreviousUrl = ""; SyncingFolder = ""; - string local_plugins_path = SparklePlugin.LocalPluginsPath; + string local_plugins_path = Plugin.LocalPluginsPath; int local_plugins_count = 0; // Import all of the plugins if (Directory.Exists (local_plugins_path)) // Local plugins go first... foreach (string xml_file_path in Directory.GetFiles (local_plugins_path, "*.xml")) { - Plugins.Add (new SparklePlugin (xml_file_path)); + Plugins.Add (new Plugin (xml_file_path)); local_plugins_count++; } // ...system plugins after that... - if (Directory.Exists (Program.Controller.PluginsPath)) { - foreach (string xml_file_path in Directory.GetFiles (Program.Controller.PluginsPath, "*.xml")) { + if (Directory.Exists (SparkleShare.Controller.PluginsPath)) { + foreach (string xml_file_path in Directory.GetFiles (SparkleShare.Controller.PluginsPath, "*.xml")) { // ...and "Own server" at the very top if (xml_file_path.EndsWith ("own-server.xml")) { - Plugins.Insert (0, new SparklePlugin (xml_file_path)); + Plugins.Insert (0, new Plugin (xml_file_path)); } else if (xml_file_path.EndsWith ("ssnet.xml")) { // Plugins.Insert ((local_plugins_count + 1), new SparklePlugin (xml_file_path)); // TODO: Skip this plugin for now } else { - Plugins.Add (new SparklePlugin (xml_file_path)); + Plugins.Add (new Plugin (xml_file_path)); } } } SelectedPlugin = Plugins [0]; - Program.Controller.InviteReceived += delegate (SparkleInvite invite) { + SparkleShare.Controller.InviteReceived += delegate (SparkleInvite invite) { PendingInvite = invite; ChangePageEvent (PageType.Invite, null); ShowWindowEvent (); }; - Program.Controller.ShowSetupWindowEvent += delegate (PageType page_type) { + SparkleShare.Controller.ShowSetupWindowEvent += delegate (PageType page_type) { if (page_type == PageType.CryptoSetup || page_type == PageType.CryptoPassword) { ChangePageEvent (page_type, null); return; @@ -184,7 +184,7 @@ namespace SparkleShare { ChangePageEvent (PageType.Add, null); } - } else if (!Program.Controller.FirstRun && TutorialPageNumber == 0) { + } else if (!SparkleShare.Controller.FirstRun && TutorialPageNumber == 0) { WindowIsOpen = true; ChangePageEvent (PageType.Add, null); } @@ -230,13 +230,13 @@ namespace SparkleShare { public void SetupPageCancelled () { - Program.Controller.Quit (); + SparkleShare.Controller.Quit (); } public void SetupPageCompleted (string full_name, string email) { - Program.Controller.CurrentUser = new SparkleUser (full_name, email); + SparkleShare.Controller.CurrentUser = new User (full_name, email); TutorialPageNumber = 1; ChangePageEvent (PageType.Tutorial, null); @@ -267,7 +267,7 @@ namespace SparkleShare { HideWindowEvent (); if (this.create_startup_item) - new Thread (() => Program.Controller.CreateStartupItem ()).Start (); + new Thread (() => SparkleShare.Controller.CreateStartupItem ()).Start (); } else { ChangePageEvent (PageType.Tutorial, null); @@ -347,9 +347,9 @@ namespace SparkleShare { PreviousAddress = address; PreviousPath = remote_path; - Program.Controller.FolderFetched += AddPageFetchedDelegate; - Program.Controller.FolderFetchError += AddPageFetchErrorDelegate; - Program.Controller.FolderFetching += SyncingPageFetchingDelegate; + SparkleShare.Controller.FolderFetched += AddPageFetchedDelegate; + SparkleShare.Controller.FolderFetchError += AddPageFetchErrorDelegate; + SparkleShare.Controller.FolderFetching += SyncingPageFetchingDelegate; SparkleFetcherInfo info = new SparkleFetcherInfo { Address = address, @@ -360,7 +360,7 @@ namespace SparkleShare { Backend = SelectedPlugin.Backend }; - new Thread (() => { Program.Controller.StartFetcher (info); }).Start (); + new Thread (() => { SparkleShare.Controller.StartFetcher (info); }).Start (); } // The following private methods are @@ -373,28 +373,28 @@ namespace SparkleShare { // Create a local plugin for succesfully added projects, so // so the user can easily use the same host again if (SelectedPluginIndex == 0) { - SparklePlugin new_plugin; + Plugin new_plugin; Uri uri = new Uri (remote_url); try { string address = remote_url.Replace (uri.AbsolutePath, ""); - new_plugin = SparklePlugin.Create (uri.Host, address, address, "", "", "/path/to/project"); + new_plugin = Plugin.Create (uri.Host, address, address, "", "", "/path/to/project"); if (new_plugin != null) { Plugins.Insert (1, new_plugin); - SparkleLogger.LogInfo ("Controller", "Added plugin for " + uri.Host); + Logger.LogInfo ("Controller", "Added plugin for " + uri.Host); } } catch { - SparkleLogger.LogInfo ("Controller", "Failed adding plugin for " + uri.Host); + Logger.LogInfo ("Controller", "Failed adding plugin for " + uri.Host); } } ChangePageEvent (PageType.Finished, warnings); - Program.Controller.FolderFetched -= AddPageFetchedDelegate; - Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate; - Program.Controller.FolderFetching -= SyncingPageFetchingDelegate; + SparkleShare.Controller.FolderFetched -= AddPageFetchedDelegate; + SparkleShare.Controller.FolderFetchError -= AddPageFetchErrorDelegate; + SparkleShare.Controller.FolderFetching -= SyncingPageFetchingDelegate; } private void AddPageFetchErrorDelegate (string remote_url, string [] errors) @@ -404,9 +404,9 @@ namespace SparkleShare { ChangePageEvent (PageType.Error, errors); - Program.Controller.FolderFetched -= AddPageFetchedDelegate; - Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate; - Program.Controller.FolderFetching -= SyncingPageFetchingDelegate; + SparkleShare.Controller.FolderFetched -= AddPageFetchedDelegate; + SparkleShare.Controller.FolderFetchError -= AddPageFetchErrorDelegate; + SparkleShare.Controller.FolderFetching -= SyncingPageFetchingDelegate; } private void SyncingPageFetchingDelegate (double percentage, double speed) @@ -435,15 +435,15 @@ namespace SparkleShare { ChangePageEvent (PageType.Syncing, null); new Thread (() => { - if (!PendingInvite.Accept (Program.Controller.UserAuthenticationInfo.PublicKey)) { + if (!PendingInvite.Accept (SparkleShare.Controller.UserAuthenticationInfo.PublicKey)) { PreviousUrl = PendingInvite.Address + PendingInvite.RemotePath.TrimStart ("/".ToCharArray ()); ChangePageEvent (PageType.Error, new string [] { "error: Failed to upload the public key" }); return; } - Program.Controller.FolderFetched += InvitePageFetchedDelegate; - Program.Controller.FolderFetchError += InvitePageFetchErrorDelegate; - Program.Controller.FolderFetching += SyncingPageFetchingDelegate; + SparkleShare.Controller.FolderFetched += InvitePageFetchedDelegate; + SparkleShare.Controller.FolderFetchError += InvitePageFetchErrorDelegate; + SparkleShare.Controller.FolderFetching += SyncingPageFetchingDelegate; SparkleFetcherInfo info = new SparkleFetcherInfo { Address = PendingInvite.Address, @@ -453,7 +453,7 @@ namespace SparkleShare { AnnouncementsUrl = PendingInvite.AnnouncementsUrl }; - Program.Controller.StartFetcher (info); + SparkleShare.Controller.StartFetcher (info); }).Start (); } @@ -468,9 +468,9 @@ namespace SparkleShare { ChangePageEvent (PageType.Finished, warnings); - Program.Controller.FolderFetched -= AddPageFetchedDelegate; - Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate; - Program.Controller.FolderFetching -= SyncingPageFetchingDelegate; + SparkleShare.Controller.FolderFetched -= AddPageFetchedDelegate; + SparkleShare.Controller.FolderFetchError -= AddPageFetchErrorDelegate; + SparkleShare.Controller.FolderFetching -= SyncingPageFetchingDelegate; } private void InvitePageFetchErrorDelegate (string remote_url, string [] errors) @@ -480,15 +480,15 @@ namespace SparkleShare { ChangePageEvent (PageType.Error, errors); - Program.Controller.FolderFetched -= AddPageFetchedDelegate; - Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate; - Program.Controller.FolderFetching -= SyncingPageFetchingDelegate; + SparkleShare.Controller.FolderFetched -= AddPageFetchedDelegate; + SparkleShare.Controller.FolderFetchError -= AddPageFetchErrorDelegate; + SparkleShare.Controller.FolderFetching -= SyncingPageFetchingDelegate; } public void SyncingCancelled () { - Program.Controller.StopFetcher (); + SparkleShare.Controller.StopFetcher (); if (PendingInvite != null) ChangePageEvent (PageType.Invite, null); @@ -517,7 +517,7 @@ namespace SparkleShare { public void CheckCryptoPasswordPage (string password) { - bool is_password_correct = Program.Controller.CheckPassword (password); + bool is_password_correct = SparkleShare.Controller.CheckPassword (password); UpdateCryptoPasswordContinueButtonEvent (is_password_correct); } @@ -541,7 +541,7 @@ namespace SparkleShare { new Thread (() => { Thread.Sleep (1000); - Program.Controller.FinishFetcher (password); + SparkleShare.Controller.FinishFetcher (password); }).Start (); } @@ -549,7 +549,7 @@ namespace SparkleShare { public void CopyToClipboardClicked () { - Program.Controller.CopyToClipboard (Program.Controller.UserAuthenticationInfo.PublicKey); + SparkleShare.Controller.CopyToClipboard (SparkleShare.Controller.UserAuthenticationInfo.PublicKey); } @@ -564,7 +564,7 @@ namespace SparkleShare { if (PreviousPath.EndsWith ("-crypto.git")) folder_name = folder_name.Replace ("-crypto.git", ""); - Program.Controller.OpenSparkleShareFolder (folder_name); + SparkleShare.Controller.OpenSparkleShareFolder (folder_name); FinishPageCompleted (); } diff --git a/SparkleShare/Program.cs b/SparkleShare/Common/SparkleShare.cs similarity index 86% rename from SparkleShare/Program.cs rename to SparkleShare/Common/SparkleShare.cs index 1dfe811c..8cd4330a 100644 --- a/SparkleShare/Program.cs +++ b/SparkleShare/Common/SparkleShare.cs @@ -23,10 +23,10 @@ using SparkleLib; namespace SparkleShare { // This is SparkleShare! - public class Program { + public class SparkleShare { - public static SparkleController Controller; - public static SparkleUI UI; + public static Controller Controller; + public static UserInterface UI; public static string [] Arguments; private static Mutex program_mutex = new Mutex (false, "SparkleShare"); @@ -40,15 +40,15 @@ namespace SparkleShare { Arguments = args; if (args.Length != 0 && !args [0].Equals ("help") && - SparkleBackend.Platform != PlatformID.MacOSX && - SparkleBackend.Platform != PlatformID.Win32NT) { + Backend.Platform != PlatformID.MacOSX && + Backend.Platform != PlatformID.Win32NT) { string n = Environment.NewLine; Console.WriteLine (n + "Share and collaborate by syncing with any Git repository instantly." + n + n + - "Version: " + SparkleLib.SparkleBackend.Version + n + + "Version: " + SparkleLib.Backend.Version + n + "Copyright (C) 2010 Hylke Bons and others" + n + "This program comes with ABSOLUTELY NO WARRANTY." + n + n + @@ -68,10 +68,10 @@ namespace SparkleShare { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; - Controller = new SparkleController (); + Controller = new Controller (); Controller.Initialize (); - UI = new SparkleUI (); + UI = new UserInterface (); UI.Run (); #if !__MonoCS__ @@ -85,7 +85,7 @@ namespace SparkleShare { { try { Exception e = (Exception) exception_args.ExceptionObject; - SparkleLogger.WriteCrashReport (e); + Logger.WriteCrashReport (e); } finally { Environment.Exit (-1); diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/Common/StatusIconController.cs old mode 100755 new mode 100644 similarity index 82% rename from SparkleShare/SparkleStatusIconController.cs rename to SparkleShare/Common/StatusIconController.cs index aed8d823..f9610192 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/Common/StatusIconController.cs @@ -35,7 +35,7 @@ namespace SparkleShare { public class ProjectInfo { - private SparkleRepoBase repo; + private BaseRepository repo; public string Name { get { return this.repo.Name; }} public string Path { get { return this.repo.LocalPath; }} @@ -111,7 +111,7 @@ namespace SparkleShare { } - public ProjectInfo (SparkleRepoBase repo) + public ProjectInfo (BaseRepository repo) { this.repo = repo; } @@ -140,7 +140,7 @@ namespace SparkleShare { public int ProgressPercentage { get { - return (int) Program.Controller.ProgressPercentage; + return (int) SparkleShare.Controller.ProgressPercentage; } } @@ -148,17 +148,17 @@ namespace SparkleShare { get { string progress_speed = ""; - if (Program.Controller.ProgressSpeedDown == 0 && Program.Controller.ProgressSpeedUp > 0) { - progress_speed = Program.Controller.ProgressSpeedUp.ToSize () + "/s "; + if (SparkleShare.Controller.ProgressSpeedDown == 0 && SparkleShare.Controller.ProgressSpeedUp > 0) { + progress_speed = SparkleShare.Controller.ProgressSpeedUp.ToSize () + "/s "; - } else if (Program.Controller.ProgressSpeedUp == 0 && Program.Controller.ProgressSpeedDown > 0) { - progress_speed = Program.Controller.ProgressSpeedDown.ToSize () + "/s "; + } else if (SparkleShare.Controller.ProgressSpeedUp == 0 && SparkleShare.Controller.ProgressSpeedDown > 0) { + progress_speed = SparkleShare.Controller.ProgressSpeedDown.ToSize () + "/s "; - } else if (Program.Controller.ProgressSpeedUp > 0 && - Program.Controller.ProgressSpeedDown > 0) { + } else if (SparkleShare.Controller.ProgressSpeedUp > 0 && + SparkleShare.Controller.ProgressSpeedDown > 0) { - progress_speed = "Up: " + Program.Controller.ProgressSpeedUp.ToSize () + "/s " + - "Down: " + Program.Controller.ProgressSpeedDown.ToSize () + "/s"; + progress_speed = "Up: " + SparkleShare.Controller.ProgressSpeedUp.ToSize () + "/s " + + "Down: " + SparkleShare.Controller.ProgressSpeedDown.ToSize () + "/s"; } return progress_speed; @@ -167,13 +167,13 @@ namespace SparkleShare { public bool RecentEventsItemEnabled { get { - return (Program.Controller.Repositories.Length > 0); + return (SparkleShare.Controller.Repositories.Length > 0); } } public bool LinkCodeItemEnabled { get { - return !string.IsNullOrEmpty (Program.Controller.UserAuthenticationInfo.PublicKey); + return !string.IsNullOrEmpty (SparkleShare.Controller.UserAuthenticationInfo.PublicKey); } } @@ -188,7 +188,7 @@ namespace SparkleShare { { UpdateFolders (); - Program.Controller.FolderListChanged += delegate { + SparkleShare.Controller.FolderListChanged += delegate { if (CurrentState != IconState.Error) { CurrentState = IconState.Idle; @@ -201,7 +201,7 @@ namespace SparkleShare { UpdateMenuEvent (CurrentState); }; - Program.Controller.OnIdle += delegate { + SparkleShare.Controller.OnIdle += delegate { if (CurrentState != IconState.Error) { CurrentState = IconState.Idle; @@ -216,11 +216,11 @@ namespace SparkleShare { UpdateMenuEvent (CurrentState); }; - Program.Controller.OnSyncing += delegate { + SparkleShare.Controller.OnSyncing += delegate { int repos_syncing_up = 0; int repos_syncing_down = 0; - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) { if (repo.Status == SyncStatus.SyncUp) repos_syncing_up++; @@ -251,7 +251,7 @@ namespace SparkleShare { UpdateQuitItemEvent (QuitItemEnabled); }; - Program.Controller.OnError += delegate { + SparkleShare.Controller.OnError += delegate { CurrentState = IconState.Error; StateText = "Some changes weren’t synced"; @@ -305,56 +305,56 @@ namespace SparkleShare { public void RecentEventsClicked () { new Thread (() => { - while (!Program.Controller.RepositoriesLoaded) + while (!SparkleShare.Controller.RepositoriesLoaded) Thread.Sleep (100); - Program.Controller.ShowEventLogWindow (); + SparkleShare.Controller.ShowEventLogWindow (); }).Start (); } public void AddHostedProjectClicked () { - new Thread (() => Program.Controller.ShowSetupWindow (PageType.Add)).Start (); + new Thread (() => SparkleShare.Controller.ShowSetupWindow (PageType.Add)).Start (); } public void CopyToClipboardClicked () { - Program.Controller.CopyToClipboard (Program.Controller.UserAuthenticationInfo.PublicKey); + SparkleShare.Controller.CopyToClipboard (SparkleShare.Controller.UserAuthenticationInfo.PublicKey); } public void AboutClicked () { - Program.Controller.ShowAboutWindow (); + SparkleShare.Controller.ShowAboutWindow (); } public void QuitClicked () { - Program.Controller.Quit (); + SparkleShare.Controller.Quit (); } // Project items public void ProjectClicked (string project) { - Program.Controller.OpenSparkleShareFolder (project); + SparkleShare.Controller.OpenSparkleShareFolder (project); } public void PauseClicked (string project) { - Program.Controller.GetRepoByName (project).Pause (); + SparkleShare.Controller.GetRepoByName (project).Pause (); UpdateStateText (); UpdateMenuEvent (CurrentState); } public void ResumeClicked (string project) { - if (Program.Controller.GetRepoByName (project).UnsyncedChanges.Count > 0) { - Program.Controller.ShowNoteWindow (project); + if (SparkleShare.Controller.GetRepoByName (project).UnsyncedChanges.Count > 0) { + SparkleShare.Controller.ShowNoteWindow (project); } else { new Thread (() => { - Program.Controller.GetRepoByName (project).Resume (""); + SparkleShare.Controller.GetRepoByName (project).Resume (""); UpdateStateText (); UpdateMenuEvent (CurrentState); @@ -365,7 +365,7 @@ namespace SparkleShare { public void TryAgainClicked (string project) { - new Thread (() => Program.Controller.GetRepoByName (project).ForceRetry ()).Start (); + new Thread (() => SparkleShare.Controller.GetRepoByName (project).ForceRetry ()).Start (); } @@ -398,7 +398,7 @@ namespace SparkleShare { lock (this.projects_lock) { List projects = new List (); - foreach (SparkleRepoBase repo in Program.Controller.Repositories) + foreach (BaseRepository repo in SparkleShare.Controller.Repositories) projects.Add (new ProjectInfo (repo)); Projects = projects.ToArray (); diff --git a/SparkleShare/Linux/SparkleAbout.cs b/SparkleShare/Linux/About.cs similarity index 100% rename from SparkleShare/Linux/SparkleAbout.cs rename to SparkleShare/Linux/About.cs diff --git a/SparkleShare/Linux/SparkleBubbles.cs b/SparkleShare/Linux/Bubbles.cs similarity index 100% rename from SparkleShare/Linux/SparkleBubbles.cs rename to SparkleShare/Linux/Bubbles.cs diff --git a/SparkleShare/Linux/SparkleController.cs b/SparkleShare/Linux/Controller.cs similarity index 100% rename from SparkleShare/Linux/SparkleController.cs rename to SparkleShare/Linux/Controller.cs diff --git a/SparkleShare/Linux/SparkleEventLog.cs b/SparkleShare/Linux/EventLog.cs similarity index 100% rename from SparkleShare/Linux/SparkleEventLog.cs rename to SparkleShare/Linux/EventLog.cs diff --git a/SparkleShare/Linux/Makefile.am b/SparkleShare/Linux/Makefile.am index e8548aa7..24c6b982 100644 --- a/SparkleShare/Linux/Makefile.am +++ b/SparkleShare/Linux/Makefile.am @@ -10,28 +10,27 @@ BUILD_DEFINES = "-define:HAVE_APP_INDICATOR" endif SOURCES = \ - ../Program.cs \ - ../SparkleAboutController.cs \ - ../SparkleAvatars.cs \ - ../SparkleBubblesController.cs \ - ../SparkleControllerBase.cs \ - ../SparkleEventLogController.cs \ - ../SparkleExtensions.cs \ - ../SparkleInvite.cs \ - ../SparkleNoteController.cs \ - ../SparklePlugin.cs \ - ../SparkleSetupController.cs \ - ../SparkleStatusIconController.cs \ - SparkleAbout.cs \ - SparkleBubbles.cs \ - SparkleController.cs \ - SparkleEventLog.cs \ - SparkleNote.cs \ - SparkleSetup.cs \ - SparkleSetupWindow.cs \ - SparkleStatusIcon.cs \ - SparkleUI.cs \ - SparkleUIHelpers.cs + ../Common/Program.cs \ + ../Common/AboutController.cs \ + ../Common/Avatars.cs \ + ../Common/BubblesController.cs \ + ../Common/BaseController.cs \ + ../Common/EventLogController.cs \ + ../Common/Invite.cs \ + ../Common/NoteController.cs \ + ../Common/Plugin.cs \ + ../Common/SetupController.cs \ + ../Common/StatusIconController.cs \ + About.cs \ + Bubbles.cs \ + Controller.cs \ + EventLog.cs \ + Note.cs \ + Setup.cs \ + SetupWindow.cs \ + StatusIcon.cs \ + UserInterface.cs \ + UserInterfaceHelpers.cs include $(top_srcdir)/build/build.mk diff --git a/SparkleShare/Linux/SparkleNote.cs b/SparkleShare/Linux/Note.cs similarity index 100% rename from SparkleShare/Linux/SparkleNote.cs rename to SparkleShare/Linux/Note.cs diff --git a/SparkleShare/Linux/SparkleSetup.cs b/SparkleShare/Linux/Setup.cs similarity index 100% rename from SparkleShare/Linux/SparkleSetup.cs rename to SparkleShare/Linux/Setup.cs diff --git a/SparkleShare/Linux/SparkleSetupWindow.cs b/SparkleShare/Linux/SetupWindow.cs similarity index 100% rename from SparkleShare/Linux/SparkleSetupWindow.cs rename to SparkleShare/Linux/SetupWindow.cs diff --git a/SparkleShare/Linux/SparkleStatusIcon.cs b/SparkleShare/Linux/StatusIcon.cs similarity index 100% rename from SparkleShare/Linux/SparkleStatusIcon.cs rename to SparkleShare/Linux/StatusIcon.cs diff --git a/SparkleShare/Linux/SparkleUI.cs b/SparkleShare/Linux/UserInterface.cs similarity index 100% rename from SparkleShare/Linux/SparkleUI.cs rename to SparkleShare/Linux/UserInterface.cs diff --git a/SparkleShare/Linux/SparkleUIHelpers.cs b/SparkleShare/Linux/UserInterfaceHelpers.cs similarity index 100% rename from SparkleShare/Linux/SparkleUIHelpers.cs rename to SparkleShare/Linux/UserInterfaceHelpers.cs diff --git a/SparkleShare/Mac/AppDelegate.cs b/SparkleShare/Mac/AppDelegate.cs index 9e246c1c..467b8cb5 100755 --- a/SparkleShare/Mac/AppDelegate.cs +++ b/SparkleShare/Mac/AppDelegate.cs @@ -15,17 +15,11 @@ // along with this program. If not, see . -using System; -using System.Drawing; - -using MonoMac.Foundation; using MonoMac.AppKit; -using MonoMac.ObjCRuntime; namespace SparkleShare { public partial class AppDelegate : NSApplicationDelegate { - } } diff --git a/SparkleShare/Mac/SparkleController.cs b/SparkleShare/Mac/Controller.cs old mode 100755 new mode 100644 similarity index 86% rename from SparkleShare/Mac/SparkleController.cs rename to SparkleShare/Mac/Controller.cs index 66ef47dd..f04817cd --- a/SparkleShare/Mac/SparkleController.cs +++ b/SparkleShare/Mac/Controller.cs @@ -29,7 +29,7 @@ using SparkleLib.Git; namespace SparkleShare { - public class SparkleController : SparkleControllerBase { + public class Controller : BaseController { public override string PluginsPath { get { @@ -38,12 +38,12 @@ namespace SparkleShare { } - public SparkleController () + public Controller () { NSApplication.Init (); - SparkleGit.GitPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core", "git"); - SparkleGit.ExecPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core"); + GitCommand.GitPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core", "git"); + GitCommand.ExecPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core"); } @@ -51,9 +51,9 @@ namespace SparkleShare { { base.Initialize (); - SparkleRepoBase.UseCustomWatcher = true; + BaseRepository.UseCustomWatcher = true; - this.watcher = new SparkleMacWatcher (Program.Controller.FoldersPath); + this.watcher = new SparkleMacWatcher (SparkleShare.Controller.FoldersPath); this.watcher.Changed += OnFilesChanged; } @@ -64,7 +64,7 @@ namespace SparkleShare { delegate void FileActivityTask (); - FileActivityTask MacActivityTask (SparkleRepoBase repo, FileSystemEventArgs fse_args) + FileActivityTask MacActivityTask (BaseRepository repo, FileSystemEventArgs fse_args) { return delegate { new Thread (() => { repo.OnFileActivity (fse_args); }).Start (); }; } @@ -83,7 +83,7 @@ namespace SparkleShare { repo_name = file; repo_name = Path.GetFileNameWithoutExtension (repo_name); - SparkleRepoBase repo = GetRepoByName (repo_name); + BaseRepository repo = GetRepoByName (repo_name); if (repo == null) continue; @@ -110,10 +110,10 @@ namespace SparkleShare { "make login item at end with properties " + "{path:\"" + NSBundle.MainBundle.BundlePath + "\", hidden:false}'"; - var process = new SparkleProcess ("osascript", args); + var process = new Command ("osascript", args); process.StartAndWaitForExit (); - SparkleLogger.LogInfo ("Controller", "Added " + NSBundle.MainBundle.BundlePath + " to login items"); + Logger.LogInfo ("Controller", "Added " + NSBundle.MainBundle.BundlePath + " to login items"); } @@ -125,9 +125,9 @@ namespace SparkleShare { public override bool CreateSparkleShareFolder () { - if (!Directory.Exists (Program.Controller.FoldersPath)) { - Directory.CreateDirectory (Program.Controller.FoldersPath); - Syscall.chmod (Program.Controller.FoldersPath, (FilePermissions) 448); // 448 -> 700 + if (!Directory.Exists (SparkleShare.Controller.FoldersPath)) { + Directory.CreateDirectory (SparkleShare.Controller.FoldersPath); + Syscall.chmod (SparkleShare.Controller.FoldersPath, (FilePermissions) 448); // 448 -> 700 return true; } @@ -141,12 +141,12 @@ namespace SparkleShare { if (Environment.OSVersion.Version.Major >= 14) { NSWorkspace.SharedWorkspace.SetIconforFile ( NSImage.ImageNamed ("sparkleshare-folder-yosemite.icns"), - Program.Controller.FoldersPath, 0); + SparkleShare.Controller.FoldersPath, 0); } else { NSWorkspace.SharedWorkspace.SetIconforFile ( NSImage.ImageNamed ("sparkleshare-folder.icns"), - Program.Controller.FoldersPath, 0); + SparkleShare.Controller.FoldersPath, 0); } } diff --git a/SparkleShare/Mac/SparkleMacWatcher.cs b/SparkleShare/Mac/MacWatcher.cs similarity index 98% rename from SparkleShare/Mac/SparkleMacWatcher.cs rename to SparkleShare/Mac/MacWatcher.cs index 0046cb30..ff2d12af 100755 --- a/SparkleShare/Mac/SparkleMacWatcher.cs +++ b/SparkleShare/Mac/MacWatcher.cs @@ -27,13 +27,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Runtime.InteropServices; using System.IO; -using System.Threading; -using System.Timers; -using MonoMac.AppKit; using MonoMac.Foundation; namespace SparkleShare { diff --git a/SparkleShare/Mac/SparkleShare.csproj b/SparkleShare/Mac/SparkleShare.Mac.csproj similarity index 87% rename from SparkleShare/Mac/SparkleShare.csproj rename to SparkleShare/Mac/SparkleShare.Mac.csproj index b8ed5f69..8b7521b1 100644 --- a/SparkleShare/Mac/SparkleShare.csproj +++ b/SparkleShare/Mac/SparkleShare.Mac.csproj @@ -91,47 +91,47 @@ MainMenu.xib - - SparkleControllerBase.cs + + BaseController.cs - - - - Program.cs + + + SparkleShare.cs - - - - - - - SparkleBubblesController.cs + + + + Plugin.cs - - SparkleEventLogController.cs + + Invite.cs - - SparkleSetupController.cs + + + Controllers\AboutController.cs - - SparkleStatusIconController.cs + + Controllers\BubblesController.cs - - SparkleAboutController.cs + + Controllers\EventLogController.cs - - - SparklePlugin.cs + + Controllers\NoteController.cs - - - SparkleInvite.cs + + Controllers\SetupController.cs - - - SparkleNoteController.cs + + Controllers\StatusIconController.cs - + + + + + + + @@ -168,6 +168,8 @@ + + diff --git a/SparkleShare/Mac/SparkleShare.sln b/SparkleShare/Mac/SparkleShare.sln index 382e0017..06828817 100644 --- a/SparkleShare/Mac/SparkleShare.sln +++ b/SparkleShare/Mac/SparkleShare.sln @@ -1,7 +1,7 @@ - + Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleShare", "SparkleShare.csproj", "{CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleShare.Mac", "SparkleShare.Mac.csproj", "{CF5BC8DB-A633-4FCC-8A3E-E3AC9B59FABC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib", "..\..\SparkleLib\SparkleLib.csproj", "{2C914413-B31C-4362-93C7-1AE34F09112A}" EndProject @@ -39,8 +39,10 @@ Global $1.DirectoryNamespaceAssociation = None $1.ResourceNamePolicy = FileFormatDefault $0.TextStylePolicy = $2 - $2.inheritsSet = null - $2.scope = text/x-csharp + $2.inheritsSet = VisualStudio + $2.scope = text/plain + $2.FileWidth = 120 + $2.inheritsScope = text/plain $0.CSharpFormattingPolicy = $3 $3.inheritsSet = Mono $3.inheritsScope = text/x-csharp diff --git a/SparkleShare/Mac/SparkleUI.cs b/SparkleShare/Mac/UserInterface.cs similarity index 70% rename from SparkleShare/Mac/SparkleUI.cs rename to SparkleShare/Mac/UserInterface.cs index 2eebb3e3..71d937d6 100755 --- a/SparkleShare/Mac/SparkleUI.cs +++ b/SparkleShare/Mac/UserInterface.cs @@ -22,52 +22,53 @@ using MonoMac.Foundation; namespace SparkleShare { - public class SparkleUI : AppDelegate { + public class UserInterface : AppDelegate { - public SparkleStatusIcon StatusIcon; - public SparkleEventLog EventLog; - public SparkleSetup Setup; - public SparkleBubbles Bubbles; - public SparkleAbout About; - public SparkleNote Note; + public StatusIcon StatusIcon; + public EventLog EventLog; + public Setup Setup; + public Bubbles Bubbles; + public About About; + public Note Note; public static string FontName = "Helvetica Neue"; - public SparkleUI () + public UserInterface () { + // TODO: SF Font if (Environment.OSVersion.Version.Major < 14) FontName = "Lucida Grande"; - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { if (Environment.OSVersion.Version.Major >= 14) { NSWorkspace.SharedWorkspace.SetIconforFile ( NSImage.ImageNamed ("sparkleshare-folder-yosemite.icns"), - Program.Controller.FoldersPath, 0); + SparkleShare.Controller.FoldersPath, 0); } else { NSWorkspace.SharedWorkspace.SetIconforFile ( NSImage.ImageNamed ("sparkleshare-folder.icns"), - Program.Controller.FoldersPath, 0); + SparkleShare.Controller.FoldersPath, 0); } NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("sparkleshare-app.icns"); - Setup = new SparkleSetup (); - EventLog = new SparkleEventLog (); - About = new SparkleAbout (); - Note = new SparkleNote (); - Bubbles = new SparkleBubbles (); - StatusIcon = new SparkleStatusIcon (); + Setup = new Setup (); + EventLog = new EventLog (); + About = new About (); + Note = new Note (); + Bubbles = new Bubbles (); + StatusIcon = new StatusIcon (); }); - Program.Controller.UIHasLoaded (); + SparkleShare.Controller.UIHasLoaded (); } public void Run () { - NSApplication.Main (Program.Arguments); + NSApplication.Main (SparkleShare.Arguments); } @@ -83,14 +84,14 @@ namespace SparkleShare { public override void WillTerminate (NSNotification notification) { - Program.Controller.Quit (); + SparkleShare.Controller.Quit (); } public override bool ApplicationShouldHandleReopen (NSApplication sender, bool has_visible_windows) { if (!has_visible_windows) - Program.Controller.HandleReopen (); + SparkleShare.Controller.HandleReopen (); return true; } diff --git a/SparkleShare/Mac/SparkleAbout.cs b/SparkleShare/Mac/UserInterface/About.cs old mode 100755 new mode 100644 similarity index 91% rename from SparkleShare/Mac/SparkleAbout.cs rename to SparkleShare/Mac/UserInterface/About.cs index 448f7a18..72abfd73 --- a/SparkleShare/Mac/SparkleAbout.cs +++ b/SparkleShare/Mac/UserInterface/About.cs @@ -17,14 +17,13 @@ using System; using System.Drawing; -using System.IO; using MonoMac.AppKit; using MonoMac.Foundation; namespace SparkleShare { - public class SparkleAbout : NSWindow { + public class About : NSWindow { public SparkleAboutController Controller = new SparkleAboutController (); @@ -35,9 +34,9 @@ namespace SparkleShare { private NSButton hidden_close_button; - public SparkleAbout (IntPtr handle) : base (handle) { } + public About (IntPtr handle) : base (handle) { } - public SparkleAbout () : base () + public About () : base () { SetFrame (new RectangleF (0, 0, 640, 281), true); Center (); @@ -63,15 +62,15 @@ namespace SparkleShare { this.hidden_close_button.Activated += delegate { Controller.WindowClosed (); }; Controller.HideWindowEvent += delegate { - Program.Controller.Invoke (() => PerformClose (this)); + SparkleShare.Controller.Invoke (() => PerformClose (this)); }; Controller.ShowWindowEvent += delegate { - Program.Controller.Invoke (() => OrderFrontRegardless ()); + SparkleShare.Controller.Invoke (() => OrderFrontRegardless ()); }; Controller.UpdateLabelEvent += delegate (string text) { - Program.Controller.Invoke (() => { this.updates_text_field.StringValue = text; }); + SparkleShare.Controller.Invoke (() => { this.updates_text_field.StringValue = text; }); }; @@ -146,8 +145,8 @@ namespace SparkleShare { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); MakeKeyAndOrderFront (this); - if (Program.UI != null) - Program.UI.UpdateDockIconVisibility (); + if (SparkleShare.UI != null) + SparkleShare.UI.UpdateDockIconVisibility (); base.OrderFrontRegardless (); } @@ -157,8 +156,8 @@ namespace SparkleShare { { base.OrderOut (this); - if (Program.UI != null) - Program.UI.UpdateDockIconVisibility (); + if (SparkleShare.UI != null) + SparkleShare.UI.UpdateDockIconVisibility (); return; } @@ -168,7 +167,7 @@ namespace SparkleShare { public override bool WindowShouldClose (NSObject sender) { - (sender as SparkleAbout).Controller.WindowClosed (); + (sender as About).Controller.WindowClosed (); return false; } } @@ -206,7 +205,7 @@ namespace SparkleShare { public override void MouseUp (NSEvent e) { - Program.Controller.OpenWebsite (this.url.ToString ()); + SparkleShare.Controller.OpenWebsite (this.url.ToString ()); } diff --git a/SparkleShare/Mac/SparkleBubbles.cs b/SparkleShare/Mac/UserInterface/Bubbles.cs similarity index 94% rename from SparkleShare/Mac/SparkleBubbles.cs rename to SparkleShare/Mac/UserInterface/Bubbles.cs index 1ac44e46..4f1f6ad0 100755 --- a/SparkleShare/Mac/SparkleBubbles.cs +++ b/SparkleShare/Mac/UserInterface/Bubbles.cs @@ -16,18 +16,16 @@ using System; - -using MonoMac.AppKit; using MonoMac.Foundation; namespace SparkleShare { - public class SparkleBubbles : NSObject { + public class Bubbles : NSObject { public SparkleBubblesController Controller = new SparkleBubblesController (); - public SparkleBubbles () + public Bubbles () { // The notification center was introduced in Mountain Lion if (Environment.OSVersion.Version.Major >= 12) diff --git a/SparkleShare/Mac/SparkleEventLog.cs b/SparkleShare/Mac/UserInterface/EventLog.cs old mode 100755 new mode 100644 similarity index 92% rename from SparkleShare/Mac/SparkleEventLog.cs rename to SparkleShare/Mac/UserInterface/EventLog.cs index 6859e1fc..3a289f31 --- a/SparkleShare/Mac/SparkleEventLog.cs +++ b/SparkleShare/Mac/UserInterface/EventLog.cs @@ -18,16 +18,14 @@ using System; using System.Drawing; using System.IO; -using System.Threading; -using MonoMac.Foundation; using MonoMac.AppKit; -using MonoMac.ObjCRuntime; +using MonoMac.Foundation; using MonoMac.WebKit; namespace SparkleShare { - public class SparkleEventLog : NSWindow { + public class EventLog : NSWindow { public SparkleEventLogController Controller = new SparkleEventLogController (); public float TitlebarHeight; @@ -41,9 +39,9 @@ namespace SparkleShare { private NSButton hidden_close_button; - public SparkleEventLog (IntPtr handle) : base (handle) { } + public EventLog (IntPtr handle) : base (handle) { } - public SparkleEventLog () : base () + public EventLog () : base () { Title = "Recent Changes"; Delegate = new SparkleEventsDelegate (); @@ -117,7 +115,7 @@ namespace SparkleShare { new PointF (60, ContentView.Frame.Height - 27), new SizeF (60, 20)), StringValue = "…", - Font = NSFont.FromFontName (SparkleUI.FontName + " Bold", NSFont.SystemFontSize) + Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) }; @@ -142,7 +140,7 @@ namespace SparkleShare { new SizeF (60, 20) ), StringValue = "…", - Font = NSFont.FromFontName (SparkleUI.FontName + " Bold", NSFont.SystemFontSize) + Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) }; this.popup_button = new NSPopUpButton () { @@ -180,32 +178,32 @@ namespace SparkleShare { ContentView.AddSubview (this.hidden_close_button); (Delegate as SparkleEventsDelegate).WindowResized += delegate (SizeF new_window_size) { - Program.Controller.Invoke (() => Relayout (new_window_size)); + SparkleShare.Controller.Invoke (() => Relayout (new_window_size)); }; // Hook up the controller events Controller.HideWindowEvent += delegate { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { this.progress_indicator.Hidden = true; PerformClose (this); }); }; Controller.ShowWindowEvent += delegate { - Program.Controller.Invoke (() => OrderFrontRegardless ()); + SparkleShare.Controller.Invoke (() => OrderFrontRegardless ()); }; Controller.UpdateChooserEvent += delegate (string [] folders) { - Program.Controller.Invoke (() => UpdateChooser (folders)); + SparkleShare.Controller.Invoke (() => UpdateChooser (folders)); }; Controller.UpdateChooserEnablementEvent += delegate (bool enabled) { - Program.Controller.Invoke (() => { this.popup_button.Enabled = enabled; }); + SparkleShare.Controller.Invoke (() => { this.popup_button.Enabled = enabled; }); }; Controller.UpdateContentEvent += delegate (string html) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { this.cover.RemoveFromSuperview (); this.progress_indicator.Hidden = true; UpdateContent (html); @@ -213,7 +211,7 @@ namespace SparkleShare { }; Controller.ContentLoadingEvent += delegate { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { this.web_view.RemoveFromSuperview (); // FIXME: Hack to hide that the WebView sometimes doesn't disappear ContentView.AddSubview (this.cover); @@ -223,14 +221,14 @@ namespace SparkleShare { }; Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { this.size_label_value.StringValue = size; this.history_label_value.StringValue = history_size; }); }; Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { NSSavePanel panel = new NSSavePanel () { DirectoryUrl = new NSUrl (target_folder_path, true), NameFieldStringValue = file_name, @@ -315,7 +313,7 @@ namespace SparkleShare { this.popup_button.AddItems (folders); this.popup_button.Activated += delegate { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { if (this.popup_button.IndexOfSelectedItem == 0) Controller.SelectedFolder = null; else @@ -369,8 +367,8 @@ namespace SparkleShare { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); MakeKeyAndOrderFront (this); - if (Program.UI != null) - Program.UI.UpdateDockIconVisibility (); + if (SparkleShare.UI != null) + SparkleShare.UI.UpdateDockIconVisibility (); base.OrderFrontRegardless (); } @@ -380,8 +378,8 @@ namespace SparkleShare { { base.OrderOut (this); - if (Program.UI != null) - Program.UI.UpdateDockIconVisibility (); + if (SparkleShare.UI != null) + SparkleShare.UI.UpdateDockIconVisibility (); return; } @@ -401,7 +399,7 @@ namespace SparkleShare { public override bool WindowShouldClose (NSObject sender) { - (sender as SparkleEventLog).Controller.WindowClosed (); + (sender as EventLog).Controller.WindowClosed (); return false; } } diff --git a/SparkleShare/Mac/SparkleNote.cs b/SparkleShare/Mac/UserInterface/Note.cs old mode 100755 new mode 100644 similarity index 89% rename from SparkleShare/Mac/SparkleNote.cs rename to SparkleShare/Mac/UserInterface/Note.cs index 9b9cbf2d..15db8b1e --- a/SparkleShare/Mac/SparkleNote.cs +++ b/SparkleShare/Mac/UserInterface/Note.cs @@ -23,7 +23,7 @@ using MonoMac.Foundation; namespace SparkleShare { - public class SparkleNote : NSWindow { + public class Note : NSWindow { public SparkleNoteController Controller = new SparkleNoteController (); @@ -34,9 +34,9 @@ namespace SparkleShare { private NSTextField user_name_text_field, user_email_text_field, balloon_text_field; - public SparkleNote (IntPtr handle) : base (handle) { } + public Note (IntPtr handle) : base (handle) { } - public SparkleNote () : base () + public Note () : base () { SetFrame (new RectangleF (0, 0, 480, 240), true); Center (); @@ -62,16 +62,16 @@ namespace SparkleShare { this.hidden_close_button.Activated += delegate { Controller.WindowClosed (); }; Controller.HideWindowEvent += delegate { - Program.Controller.Invoke (() => PerformClose (this)); + SparkleShare.Controller.Invoke (() => PerformClose (this)); }; Controller.ShowWindowEvent += delegate { - Program.Controller.Invoke (() => OrderFrontRegardless ()); + SparkleShare.Controller.Invoke (() => OrderFrontRegardless ()); CreateNote (); }; Controller.UpdateTitleEvent += delegate (string title) { - Program.Controller.Invoke (() => { Title = title; }); + SparkleShare.Controller.Invoke (() => { Title = title; }); }; @@ -99,8 +99,8 @@ namespace SparkleShare { Frame = new RectangleF ( new PointF (85, ContentView.Frame.Height - 41), new SizeF (320, 22)), - StringValue = Program.Controller.CurrentUser.Name, - Font = NSFont.FromFontName (SparkleUI.FontName + " Bold", NSFont.SystemFontSize) + StringValue = SparkleShare.Controller.CurrentUser.Name, + Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) }; this.user_email_text_field = new NSTextField () { @@ -112,7 +112,7 @@ namespace SparkleShare { Frame = new RectangleF ( new PointF (85, ContentView.Frame.Height - 60), new SizeF (320, 20)), - StringValue = Program.Controller.CurrentUser.Email, + StringValue = SparkleShare.Controller.CurrentUser.Email, }; @@ -198,8 +198,8 @@ namespace SparkleShare { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); MakeKeyAndOrderFront (this); - if (Program.UI != null) - Program.UI.UpdateDockIconVisibility (); + if (SparkleShare.UI != null) + SparkleShare.UI.UpdateDockIconVisibility (); base.OrderFrontRegardless (); } @@ -209,8 +209,8 @@ namespace SparkleShare { { base.OrderOut (this); - if (Program.UI != null) - Program.UI.UpdateDockIconVisibility (); + if (SparkleShare.UI != null) + SparkleShare.UI.UpdateDockIconVisibility (); return; } @@ -225,7 +225,7 @@ namespace SparkleShare { public override bool WindowShouldClose (NSObject sender) { - (sender as SparkleNote).Controller.WindowClosed (); + (sender as Note).Controller.WindowClosed (); return false; } } diff --git a/SparkleShare/Mac/SparkleSetup.cs b/SparkleShare/Mac/UserInterface/Setup.cs old mode 100755 new mode 100644 similarity index 94% rename from SparkleShare/Mac/SparkleSetup.cs rename to SparkleShare/Mac/UserInterface/Setup.cs index 9b72ebb1..3232b5e8 --- a/SparkleShare/Mac/SparkleSetup.cs +++ b/SparkleShare/Mac/UserInterface/Setup.cs @@ -28,7 +28,7 @@ using Mono.Unix; namespace SparkleShare { - public class SparkleSetup : SparkleSetupWindow { + public class Setup : SetupWindow { public SparkleSetupController Controller = new SparkleSetupController (); @@ -49,18 +49,18 @@ namespace SparkleShare { private SparkleDataSource DataSource; - public SparkleSetup () : base () + public Setup () : base () { Controller.HideWindowEvent += delegate { - Program.Controller.Invoke (() => PerformClose (this)); + SparkleShare.Controller.Invoke (() => PerformClose (this)); }; Controller.ShowWindowEvent += delegate { - Program.Controller.Invoke (() => OrderFrontRegardless ()); + SparkleShare.Controller.Invoke (() => OrderFrontRegardless ()); }; Controller.ChangePageEvent += delegate (PageType type, string [] warnings) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { Reset (); ShowPage (type, warnings); ShowAll (); @@ -118,7 +118,7 @@ namespace SparkleShare { CancelButton.Activated += delegate { Controller.SetupPageCancelled (); }; Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { ContinueButton.Enabled = button_enabled; }); }; @@ -146,7 +146,7 @@ namespace SparkleShare { AddressLabel = new SparkleLabel ("Address:", NSTextAlignment.Right); AddressLabel.Frame = new RectangleF (165, Frame.Height - 238, 160, 17); - AddressLabel.Font = NSFont.FromFontName (SparkleUI.FontName + " Bold", NSFont.SystemFontSize); + AddressLabel.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize); AddressTextField = new SparkleLabel (Controller.PendingInvite.Address, NSTextAlignment.Left) { Frame = new RectangleF (330, Frame.Height - 240, 260, 17) @@ -154,7 +154,7 @@ namespace SparkleShare { PathLabel = new SparkleLabel ("Remote Path:", NSTextAlignment.Right); PathLabel.Frame = new RectangleF (165, Frame.Height - 262, 160, 17); - PathLabel.Font = NSFont.FromFontName (SparkleUI.FontName + " Bold", NSFont.SystemFontSize); + PathLabel.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize); PathTextField = new SparkleLabel (Controller.PendingInvite.RemotePath, NSTextAlignment.Left) { @@ -184,7 +184,7 @@ namespace SparkleShare { AddressLabel = new SparkleLabel ("Address:", NSTextAlignment.Left) { Frame = new RectangleF (190, Frame.Height - 308, 160, 17), - Font = NSFont.FromFontName (SparkleUI.FontName + " Bold", NSFont.SystemFontSize) + Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) }; AddressTextField = new NSTextField () { @@ -198,7 +198,7 @@ namespace SparkleShare { PathLabel = new SparkleLabel ("Remote Path:", NSTextAlignment.Left) { Frame = new RectangleF (190 + 196 + 16, Frame.Height - 308, 160, 17), - Font = NSFont.FromFontName (SparkleUI.FontName + " Bold", NSFont.SystemFontSize) + Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) }; PathTextField = new NSTextField () { @@ -249,7 +249,7 @@ namespace SparkleShare { }; DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily ( - SparkleUI.FontName, NSFontTraitMask.Condensed, 0, 11); + UserInterface.FontName, NSFontTraitMask.Condensed, 0, 11); TableView.AddColumn (IconColumn); TableView.AddColumn (DescriptionColumn); @@ -292,7 +292,7 @@ namespace SparkleShare { Controller.ChangeAddressFieldEvent += delegate (string text, string example_text, FieldState state) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { AddressTextField.StringValue = text; AddressTextField.Enabled = (state == FieldState.Enabled); AddressHelpLabel.StringValue = example_text; @@ -300,7 +300,7 @@ namespace SparkleShare { }; Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { PathTextField.StringValue = text; PathTextField.Enabled = (state == FieldState.Enabled); PathHelpLabel.StringValue = example_text; @@ -328,7 +328,7 @@ namespace SparkleShare { CancelButton.Activated += delegate { Controller.PageCancelled (); }; Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { AddButton.Enabled = button_enabled; }); }; @@ -375,7 +375,7 @@ namespace SparkleShare { Controller.UpdateProgressBarEvent += delegate (double percentage, string speed) { - Program.Controller.Invoke (() => { + SparkleShare.Controller.Invoke (() => { ProgressIndicator.DoubleValue = percentage; ProgressLabel.StringValue = speed; }); @@ -403,7 +403,7 @@ namespace SparkleShare { string html = "