From 453841d9daef30fedd02d9961cff7e3e061f5b47 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sun, 8 Apr 2018 20:41:59 -0700 Subject: [PATCH] Remove trailing whitespace --- SparkleShare/Common/Avatars.cs | 28 +-- SparkleShare/Common/BaseController.cs | 228 ++++++++++---------- SparkleShare/Common/EventLogController.cs | 46 ++-- SparkleShare/Linux/About.cs | 10 +- SparkleShare/Linux/Note.cs | 5 +- SparkleShare/Linux/README.md | 6 +- SparkleShare/Linux/SetupWindow.cs | 13 +- SparkleShare/Windows/UserInterface/About.cs | 38 ++-- Sparkles/AuthenticationInfo.cs | 4 +- Sparkles/BaseListener.cs | 6 +- Sparkles/Git/GitCommand.cs | 4 +- Sparkles/Git/GitFetcher.cs | 2 +- Sparkles/Git/GitRepository.cs | 62 +++--- 13 files changed, 225 insertions(+), 227 deletions(-) diff --git a/SparkleShare/Common/Avatars.cs b/SparkleShare/Common/Avatars.cs index 058dbc48..bf0738cc 100644 --- a/SparkleShare/Common/Avatars.cs +++ b/SparkleShare/Common/Avatars.cs @@ -39,10 +39,10 @@ namespace SparkleShare #endif email = email.ToLower (); - + if (skipped_avatars.Contains (email)) return null; - + string avatars_path = Path.Combine (Path.GetDirectoryName (target_path), "avatars", size + "x" + size); // Search avatars by file name, ignore extension @@ -66,10 +66,10 @@ namespace SparkleShare Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); return null; } - + var client = new WebClient (); string url = "https://gravatar.com/avatar/" + email.MD5 () + ".png?s=" + size + "&d=404"; - + try { byte [] buffer = client.DownloadData (url); @@ -78,30 +78,30 @@ namespace SparkleShare } else if (client.ResponseHeaders ["content-type"].Equals (MediaTypeNames.Image.Gif, StringComparison.InvariantCultureIgnoreCase)) { avatar_file_path += ".gif"; - + } else { avatar_file_path += ".png"; } - + if (buffer.Length > 255) { if (!Directory.Exists (avatars_path)) { Directory.CreateDirectory (avatars_path); Logger.LogInfo ("Avatars", "Created '" + avatars_path + "'"); } - + File.WriteAllBytes (avatar_file_path, buffer); Logger.LogInfo ("Avatars", "Fetched " + size + "x" + size + " avatar for " + email); - + return avatar_file_path; - + } else { return null; } - + } catch (Exception e) { Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); skipped_avatars.Add (email); - + return null; } } @@ -111,11 +111,11 @@ namespace SparkleShare X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { X509Certificate2 certificate2 = new X509Certificate2 (certificate.GetRawCertData ()); - + // On some systems (mostly Linux) we can't assume the needed certificates are // available, so we have to check the certificate's SHA-1 fingerprint manually. // - // SHA1 fingerprinter obtained from https://www.gravatar.com/ on Oct 16 2015 + // SHA1 fingerprinter obtained from https://www.gravatar.com/ on Oct 16 2015 // Set to expire on Oct 14 2018 string gravatar_cert_fingerprint = "1264B3F00814C6077D3853238771EE67FB6321C9"; @@ -123,7 +123,7 @@ namespace SparkleShare Logger.LogInfo ("Avatars", "Invalid certificate for https://www.gravatar.com/"); return false; } - + return true; } } diff --git a/SparkleShare/Common/BaseController.cs b/SparkleShare/Common/BaseController.cs index 1afdb6cf..b344ddb3 100644 --- a/SparkleShare/Common/BaseController.cs +++ b/SparkleShare/Common/BaseController.cs @@ -24,17 +24,17 @@ using System.Threading; using Sparkles; namespace SparkleShare { - + public abstract class BaseController { - + public BaseRepository [] Repositories { get { lock (this.repo_lock) return this.repositories.GetRange (0, this.repositories.Count).ToArray (); } } - - + + void AddRepository (BaseRepository repo) { lock (this.repo_lock) { @@ -42,15 +42,15 @@ namespace SparkleShare { this.repositories.Sort ((x, y) => string.Compare (x.Name, y.Name)); } } - - + + void RemoveRepository (BaseRepository repo) { lock (this.repo_lock) this.repositories.Remove (repo); } - - + + public BaseRepository GetRepoByName (string name) { lock (this.repo_lock) { @@ -58,15 +58,15 @@ namespace SparkleShare { if (repo.Name.Equals (name)) return repo; } - + return null; } - - + + public Configuration Config { get; private set; } public bool RepositoriesLoaded { get; private set; } public string FoldersPath { get; private set; } - + public double ProgressPercentage = 0.0; public double ProgressSpeedUp = 0.0; public double ProgressSpeedDown = 0.0; @@ -81,37 +81,37 @@ namespace SparkleShare { public event Action ShowAboutWindowEvent = delegate { }; public event Action ShowEventLogWindowEvent = delegate { }; - + public event FolderFetchedEventHandler FolderFetched = delegate { }; public delegate void FolderFetchedEventHandler (string remote_url, string [] warnings); - + public event FolderFetchErrorHandler FolderFetchError = delegate { }; public delegate void FolderFetchErrorHandler (string remote_url, string [] errors); - + public event FolderFetchingHandler FolderFetching = delegate { }; public delegate void FolderFetchingHandler (double percentage, double speed, string information); - - + + public event Action FolderListChanged = delegate { }; public event Action OnIdle = delegate { }; public event Action OnSyncing = delegate { }; public event Action OnError = delegate { }; - - + + public event InviteReceivedHandler InviteReceived = delegate { }; public delegate void InviteReceivedHandler (SparkleInvite invite); - + public event NotificationRaisedEventHandler NotificationRaised = delegate { }; public delegate void NotificationRaisedEventHandler (ChangeSet change_set); - + public event AlertNotificationRaisedEventHandler AlertNotificationRaised = delegate { }; public delegate void AlertNotificationRaisedEventHandler (string title, string message); - - + + public bool FirstRun { get { return Config.User.Email.Equals ("Unknown"); } } - + public List Folders { get { List folders = Config.Folders; @@ -131,32 +131,32 @@ namespace SparkleShare { public bool NotificationsEnabled { get { string notifications_enabled = Config.GetConfigOption ("notifications"); - + if (string.IsNullOrEmpty (notifications_enabled)) { Config.SetConfigOption ("notifications", bool.TrueString); return true; - + } else { return notifications_enabled.Equals (bool.TrueString); } } } - + public bool AvatarsEnabled { get { string fetch_avatars_option = Config.GetConfigOption ("fetch_avatars"); - + if (fetch_avatars_option == null || fetch_avatars_option.Equals (bool.FalseString)) return false; - + return true; } } - - + + // Path where the plugins are kept public abstract string PresetsPath { get; } - + // Enables SparkleShare to start automatically at login public abstract void CreateStartupItem (); @@ -168,16 +168,16 @@ namespace SparkleShare { // Creates the SparkleShare folder in the user's home folder public abstract void CreateSparkleShareFolder (); - + // Opens the SparkleShare folder or an (optional) subfolder public abstract void OpenFolder (string path); - + // Opens a file with the appropriate application public abstract void OpenFile (string path); - + // Opens a file with the appropriate application public virtual void OpenWebsite (string url) { } - + // Copies text to the clipboard public abstract void CopyToClipboard (string text); @@ -187,23 +187,23 @@ namespace SparkleShare { public abstract string EventLogHTML { get; } public abstract string DayEntryHTML { get; } public abstract string EventEntryHTML { get; } - - + + BaseFetcher fetcher; FileSystemWatcher watcher; object repo_lock = new object (); object check_repos_lock = new object (); List repositories = new List (); bool lost_folders_path = false; - - + + public BaseController (Configuration config) { Config = config; FoldersPath = Config.FoldersPath; } - - + + public virtual void Initialize () { string version = InstallationInfo.Version; @@ -221,7 +221,7 @@ namespace SparkleShare { Preset.PresetsPath = PresetsPath; InstallProtocolHandler (); - + try { CreateSparkleShareFolder (); @@ -237,19 +237,19 @@ namespace SparkleShare { IncludeSubdirectories = false, Path = FoldersPath }; - + watcher.Created += OnFolderActivity; watcher.EnableRaisingEvents = true; } - - + + int reopen_attempt_counts = 0; - + public void HandleReopen () { if (Repositories.Length > 0) { ShowEventLogWindow (); - + } else if (reopen_attempt_counts > 1) { AlertNotificationRaised ("Hello!", "SparkleShare sits right here, as a status icon."); reopen_attempt_counts = 0; @@ -265,31 +265,31 @@ namespace SparkleShare { if (this.lost_folders_path) { SparkleShare.UI.Bubbles.Controller.ShowBubble ("Where's your SparkleShare folder?", "Did you put it on a detached drive?", null); - + Environment.Exit (-1); } - + if (FirstRun) { ShowSetupWindow (PageType.Setup); - + } else { new Thread (() => { StartupInviteScan (); CheckRepositories (); RepositoriesLoaded = true; UpdateState (); - + }).Start (); } } - - + + public void ShowSetupWindow (PageType page_type) { ShowSetupWindowEvent (page_type); } - - + + public void ShowAboutWindow () { ShowAboutWindowEvent (); @@ -300,33 +300,33 @@ namespace SparkleShare { { ShowNoteWindowEvent (project); } - - + + public void ShowEventLogWindow () { ShowEventLogWindowEvent (); } - - + + public void OpenSparkleShareFolder () { OpenFolder (Config.FoldersPath); } - - + + public void OpenSparkleShareFolder (string name) { OpenFolder (new SparkleFolder (name).FullPath); } - - + + public void ToggleNotifications () { bool notifications_enabled = Config.GetConfigOption ("notifications").Equals (bool.TrueString); Config.SetConfigOption ("notifications", (!notifications_enabled).ToString ()); } - - + + void CheckRepositories () { lock (this.check_repos_lock) { @@ -393,21 +393,21 @@ namespace SparkleShare { BaseRepository repo = null; string folder_name = Path.GetFileName (folder_path); string backend = Config.BackendByName (folder_name); - + try { repo = (BaseRepository) Activator.CreateInstance ( Type.GetType ("Sparkles." + backend + "." + backend + "Repository, Sparkles." + backend), new object [] { folder_path, Config, SSHAuthenticationInfo.DefaultAuthenticationInfo }); - + } catch (Exception e) { Logger.LogInfo ("Controller", "Failed to load backend '" + backend + "' for '" + folder_name + "': ", e); return; } - + repo.ChangesDetected += delegate { UpdateState (); }; - + repo.SyncStatusChanged += delegate (SyncStatus status) { if (status == SyncStatus.Idle) { ProgressPercentage = 0.0; @@ -415,54 +415,54 @@ namespace SparkleShare { ProgressSpeedDown = 0.0; ProgressInformation = ""; } - + UpdateState (); }; - + repo.ProgressChanged += delegate { ProgressPercentage = 0.0; ProgressSpeedUp = 0.0; ProgressSpeedDown = 0.0; ProgressInformation = ""; - + double percentage = 0.0; int repo_count = 0; - + foreach (BaseRepository rep in Repositories) { if (rep.ProgressPercentage > 0) { percentage += rep.ProgressPercentage; repo_count++; } - + if (rep.Status == SyncStatus.SyncUp) ProgressSpeedUp += rep.ProgressSpeed; - + if (rep.Status == SyncStatus.SyncDown) ProgressSpeedDown += rep.ProgressSpeed; } if (repo_count == 1) ProgressInformation = repo.ProgressInformation; - + if (repo_count > 0) ProgressPercentage = percentage / repo_count; - + UpdateState (); }; - + repo.NewChangeSet += delegate (ChangeSet change_set) { if (AvatarsEnabled) change_set.User.AvatarFilePath = Avatars.GetAvatar (change_set.User.Email, 48, Config.DirectoryPath); - + NotificationRaised (change_set); }; - + repo.ConflictResolved += delegate { AlertNotificationRaised ("Resolved a file collision", "Local and server versions were kept."); }; - + AddRepository (repo); - repo.Initialize (); + repo.Initialize (); } @@ -475,31 +475,31 @@ namespace SparkleShare { return; } } - - + + void StartupInviteScan () { foreach (string invite in Directory.GetFiles (FoldersPath, "*.xml")) HandleInvite (invite); } - - + + void HandleInvite (FileSystemEventArgs args) { HandleInvite (args.FullPath); } - - + + void HandleInvite (string path) { if (this.fetcher != null && this.fetcher.IsActive) { - + AlertNotificationRaised ("SparkleShare Setup seems busy", "Please wait for it to finish"); - + } else { SparkleInvite invite = new SparkleInvite (path); - + // It may be that the invite we received a path to isn't // fully downloaded yet, so we try to read it several times int tries = 0; @@ -507,37 +507,37 @@ namespace SparkleShare { Thread.Sleep (100); invite = new SparkleInvite (path); tries++; - + if (tries > 10) { AlertNotificationRaised ("Oh noes!", "This invite seems screwed up..."); break; } } - + if (invite.IsValid) InviteReceived (invite); - + File.Delete (path); } } - - + + // Fires events for the current syncing state void UpdateState () { bool has_unsynced_repos = false; bool has_syncing_repos = false; - + foreach (BaseRepository repo in Repositories) { if (repo.Status == SyncStatus.SyncDown || repo.Status == SyncStatus.SyncUp || repo.IsBuffering) { has_syncing_repos = true; break; - + } else if (repo.Status == SyncStatus.Idle && repo.HasUnsyncedChanges) { has_unsynced_repos = true; } } - + if (has_syncing_repos) OnSyncing (); else if (has_unsynced_repos) @@ -545,7 +545,7 @@ namespace SparkleShare { else OnIdle (); } - + public List FetcherAvailableStorageTypes { get { @@ -557,31 +557,31 @@ namespace SparkleShare { public void StartFetcher (SparkleFetcherInfo info) { string canonical_name = Path.GetFileName (info.RemotePath); - string backend = info.Backend; - + string backend = info.Backend; + if (string.IsNullOrEmpty (backend)) backend = BaseFetcher.GetBackend (info.Address); - + info.TargetDirectory = Path.Combine (Config.TmpPath, canonical_name); if (Directory.Exists (info.TargetDirectory)) Directory.Delete (info.TargetDirectory, true); - + try { this.fetcher = (BaseFetcher) Activator.CreateInstance ( Type.GetType ("Sparkles." + backend + "." + backend + "Fetcher, Sparkles." + backend), new object [] { info, UserAuthenticationInfo}); - + } catch (Exception e) { Logger.LogInfo ("Controller", "Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message); - + FolderFetchError (Path.Combine (info.Address, info.RemotePath).Replace (@"\", "/"), new string [] {"Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\""}); - + return; } - + this.fetcher.Finished += FetcherFinishedDelegate; this.fetcher.Failed += FetcherFailedDelegate; this.fetcher.ProgressChanged += FetcherProgressChangedDelgate; @@ -623,12 +623,12 @@ namespace SparkleShare { { this.fetcher.Stop (); this.fetcher.Dispose (); - + this.fetcher = null; this.watcher.EnableRaisingEvents = true; } - - + + public bool CheckPassword (string password) { return this.fetcher.IsFetchedRepoPasswordCorrect (password); @@ -689,10 +689,10 @@ namespace SparkleShare { FolderListChanged (); FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ()); - + this.fetcher.Dispose (); this.fetcher = null; - + this.watcher.EnableRaisingEvents = true; } diff --git a/SparkleShare/Common/EventLogController.cs b/SparkleShare/Common/EventLogController.cs index 78831af6..706997bf 100644 --- a/SparkleShare/Common/EventLogController.cs +++ b/SparkleShare/Common/EventLogController.cs @@ -36,16 +36,16 @@ namespace SparkleShare { public event UpdateContentEventEventHandler UpdateContentEvent = delegate { }; public delegate void UpdateContentEventEventHandler (string html); - + public event UpdateChooserEventHandler UpdateChooserEvent = delegate { }; public delegate void UpdateChooserEventHandler (string [] folders); - + public event UpdateChooserEnablementEventHandler UpdateChooserEnablementEvent = delegate { }; public delegate void UpdateChooserEnablementEventHandler (bool enabled); - + public event UpdateSizeInfoEventHandler UpdateSizeInfoEvent = delegate { }; public delegate void UpdateSizeInfoEventHandler (string size, string history_size); - + public event ShowSaveDialogEventHandler ShowSaveDialogEvent = delegate { }; public delegate void ShowSaveDialogEventHandler (string file_name, string target_folder_path); @@ -162,7 +162,7 @@ namespace SparkleShare { if (!string.IsNullOrEmpty (html)) UpdateContentEvent (html); - + UpdateSizeInfoEvent (Size, HistorySize); }).Start (); @@ -172,7 +172,7 @@ namespace SparkleShare { WindowIsOpen = true; ShowWindowEvent (); }; - + SparkleShare.Controller.OnIdle += delegate { if (this.history_view_active) return; @@ -189,7 +189,7 @@ namespace SparkleShare { UpdateSizeInfoEvent (Size, HistorySize); }; - + SparkleShare.Controller.FolderListChanged += delegate { if (this.selected_folder != null && !SparkleShare.Controller.Folders.Contains (this.selected_folder)) this.selected_folder = null; @@ -212,16 +212,16 @@ namespace SparkleShare { { if (string.IsNullOrEmpty (href) || href.StartsWith ("about:")) return; - + href = href.Replace ("%20", " "); - + if (href.StartsWith ("http")) { SparkleShare.Controller.OpenWebsite (href); - + } else if (href.StartsWith ("restore://") && this.restore_revision_info == null) { Regex regex = new Regex ("restore://(.+)/([a-f0-9]+)/(.+)/(.{3} [0-9]+ [0-9]+h[0-9]+)/(.+)"); Match match = regex.Match (href); - + if (match.Success) { string author_name = match.Groups [3].Value; string timestamp = match.Groups [4].Value; @@ -240,7 +240,7 @@ namespace SparkleShare { ShowSaveDialogEvent (file_name, target_folder_path); } - + } else if (href.StartsWith ("back://")) { this.history_view_active = false; SelectedFolder = this.selected_folder; // TODO: Return to the same position on the page @@ -283,9 +283,9 @@ namespace SparkleShare { } else { if (href.StartsWith ("file:///")) href = href.Substring (7); - + SparkleShare.Controller.OpenFile (href); - } + } } @@ -374,13 +374,13 @@ namespace SparkleShare { html += "" + "" + "" + change_set.User.Name + "" + - "" + - change_set.Timestamp.ToString ("d MMM yyyy", CultureInfo.InvariantCulture) + + "" + + change_set.Timestamp.ToString ("d MMM yyyy", CultureInfo.InvariantCulture) + "" + "" + change_set.Timestamp.ToString ("HH:mm") + "" + "" + - "Restore…" + "" + @@ -407,7 +407,7 @@ namespace SparkleShare { foreach (ChangeSet change_set in change_sets) { bool change_set_inserted = false; - + foreach (ActivityDay stored_activity_day in activity_days) { if (stored_activity_day.Date.Year == change_set.Timestamp.Year && stored_activity_day.Date.Month == change_set.Timestamp.Month && @@ -443,7 +443,7 @@ namespace SparkleShare { event_entry += "
"; if (!change.IsFolder) { - event_entry += "" + change.Timestamp.ToString ("HH:mm") + " ▾  "; @@ -582,7 +582,7 @@ namespace SparkleShare { private string SafeCombine (string path1, string path2) { string result = path1; - + if (!result.EndsWith (Path.DirectorySeparatorChar.ToString ())) result += Path.DirectorySeparatorChar; @@ -597,9 +597,9 @@ namespace SparkleShare { { if (!SparkleShare.Controller.AvatarsEnabled) return "/user-icon-default.png"; - + string fetched_avatar = Avatars.GetAvatar (user.Email, 48, SparkleShare.Controller.Config.DirectoryPath); - + if (!string.IsNullOrEmpty (fetched_avatar)) return "file://" + fetched_avatar.Replace ("\\", "/"); else diff --git a/SparkleShare/Linux/About.cs b/SparkleShare/Linux/About.cs index 46ae1a56..cb4e0cde 100755 --- a/SparkleShare/Linux/About.cs +++ b/SparkleShare/Linux/About.cs @@ -45,11 +45,11 @@ namespace SparkleShare { Controller.WindowClosed (); args.RetVal = true; }; - + KeyPressEvent += delegate (object o, KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape || (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) { - + Controller.WindowClosed (); } }; @@ -151,13 +151,13 @@ namespace SparkleShare { Add (layout_horizontal); } } - - + + class Link : Label { public Link (string label, string url) { - Markup = string.Format ("{1}", url, label); + Markup = string.Format ("{1}", url, label); CanFocus = false; CssProvider css_provider = new CssProvider (); diff --git a/SparkleShare/Linux/Note.cs b/SparkleShare/Linux/Note.cs index 6beb31fe..6fe81872 100644 --- a/SparkleShare/Linux/Note.cs +++ b/SparkleShare/Linux/Note.cs @@ -41,11 +41,11 @@ namespace SparkleShare { Controller.WindowClosed (); args.RetVal = true; }; - + KeyPressEvent += delegate (object o, KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape || (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) { - + Controller.WindowClosed (); } }; @@ -144,4 +144,3 @@ namespace SparkleShare { } } } - diff --git a/SparkleShare/Linux/README.md b/SparkleShare/Linux/README.md index f4841986..75baf2d7 100644 --- a/SparkleShare/Linux/README.md +++ b/SparkleShare/Linux/README.md @@ -4,7 +4,7 @@ ### Common build requirements -You will need the packages listed below for the most used Linux distributions (some are run requirements): +You will need the packages listed below for the most used Linux distributions (some are run requirements): ```shell # On Ubuntu 16.04: @@ -40,8 +40,8 @@ sudo dnf install \ ### Additional source build requirements -Install the `soup-sharp` and `webkit2gtk-sharp` bindings from: -https://github.com/hbons/soup-sharp +Install the `soup-sharp` and `webkit2gtk-sharp` bindings from: +https://github.com/hbons/soup-sharp https://github.com/hbons/webkit2gtk-sharp Both with: diff --git a/SparkleShare/Linux/SetupWindow.cs b/SparkleShare/Linux/SetupWindow.cs index 73207882..120c2eab 100644 --- a/SparkleShare/Linux/SetupWindow.cs +++ b/SparkleShare/Linux/SetupWindow.cs @@ -82,7 +82,7 @@ namespace SparkleShare { public void AddOption (Widget widget) - { + { this.option_area.Add (widget); } @@ -99,7 +99,7 @@ namespace SparkleShare { LineWrap = true, LineWrapMode = Pango.WrapMode.WordChar }; - + layout_vertical.PackStart (description, false, false, 0); } @@ -109,7 +109,7 @@ namespace SparkleShare { this.content_area.Add (layout_vertical); } - + public void Reset () { Header = ""; @@ -124,13 +124,13 @@ namespace SparkleShare { foreach (Button button in this.buttons) this.buttons.Remove (button); } - - + + new public void ShowAll () { if (this.buttons.Children.Length > 0) { Button default_button = (Button) this.buttons.Children [this.buttons.Children.Length - 1]; - + default_button.CanDefault = true; Default = default_button; default_button.StyleContext.AddClass ("suggested-action"); @@ -141,4 +141,3 @@ namespace SparkleShare { } } } - diff --git a/SparkleShare/Windows/UserInterface/About.cs b/SparkleShare/Windows/UserInterface/About.cs index 85f6cf0e..36c1ecce 100644 --- a/SparkleShare/Windows/UserInterface/About.cs +++ b/SparkleShare/Windows/UserInterface/About.cs @@ -16,7 +16,7 @@ using System; -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Input; using System.Windows.Controls; @@ -38,7 +38,7 @@ namespace SparkleShare { Height = 288; Width = 720; Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico"); - + WindowStartupLocation = WindowStartupLocation.CenterScreen; Closing += Close; @@ -73,10 +73,10 @@ namespace SparkleShare { Width = 720, Height = 260 }; - + image.Source = UserInterfaceHelpers.GetImageSource ("about"); - - + + Label version = new Label () { Content = "version " + Controller.RunningVersion, FontSize = 11, @@ -88,7 +88,7 @@ namespace SparkleShare { FontSize = 11, Foreground = new SolidColorBrush (Color.FromArgb (128, 255, 255, 255)) }; - + TextBlock credits = new TextBlock () { FontSize = 11, Foreground = new SolidColorBrush (Colors.White), @@ -99,14 +99,14 @@ namespace SparkleShare { TextWrapping = TextWrapping.Wrap, Width = 318 }; - + SparkleLink website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress); SparkleLink credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress); SparkleLink report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress); SparkleLink debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress); Canvas canvas = new Canvas (); - + canvas.Children.Add (image); Canvas.SetLeft (image, 0); Canvas.SetTop (image, 0); @@ -114,18 +114,18 @@ namespace SparkleShare { canvas.Children.Add (version); Canvas.SetLeft (version, 289); Canvas.SetTop (version, 92); - + canvas.Children.Add (this.updates); Canvas.SetLeft (this.updates, 289); Canvas.SetTop (this.updates, 109); - + canvas.Children.Add (credits); Canvas.SetLeft (credits, 294); - Canvas.SetTop (credits, 142); + Canvas.SetTop (credits, 142); canvas.Children.Add (website_link); Canvas.SetLeft (website_link, 289); - Canvas.SetTop (website_link, 222); + Canvas.SetTop (website_link, 222); canvas.Children.Add (credits_link); Canvas.SetLeft (credits_link, 289 + website_link.ActualWidth + 60); @@ -133,21 +133,21 @@ namespace SparkleShare { canvas.Children.Add (report_problem_link); Canvas.SetLeft (report_problem_link, 289 + website_link.ActualWidth + credits_link.ActualWidth + 115); - Canvas.SetTop (report_problem_link, 222); + Canvas.SetTop (report_problem_link, 222); canvas.Children.Add (debug_log_link); Canvas.SetLeft (debug_log_link, 289 + website_link.ActualWidth + credits_link.ActualWidth + report_problem_link.ActualWidth + 220); - Canvas.SetTop (debug_log_link, 222); - + Canvas.SetTop (debug_log_link, 222); + Content = canvas; } - - + + private void Close (object sender, CancelEventArgs args) { Controller.WindowClosed (); - args.Cancel = true; + args.Cancel = true; } } @@ -177,7 +177,7 @@ namespace SparkleShare { MouseUp += delegate { SparkleShare.Controller.OpenWebsite (url); - }; + }; } } } diff --git a/Sparkles/AuthenticationInfo.cs b/Sparkles/AuthenticationInfo.cs index bb59e827..9bfaafe2 100644 --- a/Sparkles/AuthenticationInfo.cs +++ b/Sparkles/AuthenticationInfo.cs @@ -2,8 +2,8 @@ // Copyright (C) 2010 Hylke Bons // // This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation, either version 3 of the +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, diff --git a/Sparkles/BaseListener.cs b/Sparkles/BaseListener.cs index 26c30019..bd1a3f95 100644 --- a/Sparkles/BaseListener.cs +++ b/Sparkles/BaseListener.cs @@ -2,8 +2,8 @@ // Copyright (C) 2010 Hylke Bons // // This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation, either version 3 of the +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, @@ -33,7 +33,7 @@ namespace Sparkles { public abstract class BaseListener { public event Action Connected = delegate { }; - + public event DisconnectedEventHandler Disconnected = delegate { }; public delegate void DisconnectedEventHandler (DisconnectReason reason); diff --git a/Sparkles/Git/GitCommand.cs b/Sparkles/Git/GitCommand.cs index be604e6a..60d498ff 100644 --- a/Sparkles/Git/GitCommand.cs +++ b/Sparkles/Git/GitCommand.cs @@ -2,8 +2,8 @@ // Copyright (C) 2010 Hylke Bons // // This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation, either version 3 of the +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, diff --git a/Sparkles/Git/GitFetcher.cs b/Sparkles/Git/GitFetcher.cs index 45809941..72cb3c61 100644 --- a/Sparkles/Git/GitFetcher.cs +++ b/Sparkles/Git/GitFetcher.cs @@ -436,7 +436,7 @@ namespace Sparkles.Git { var git_config_clean = new GitCommand (TargetFolder, string.Format ("config filter.lfs.clean '{0}'", clean_command)); - + git_config_required.StartAndWaitForExit (); git_config_clean.StartAndWaitForExit (); git_config_smudge.StartAndWaitForExit (); diff --git a/Sparkles/Git/GitRepository.cs b/Sparkles/Git/GitRepository.cs index 5c024a52..ceb9515a 100644 --- a/Sparkles/Git/GitRepository.cs +++ b/Sparkles/Git/GitRepository.cs @@ -2,8 +2,8 @@ // Copyright (C) 2010 Hylke Bons // // This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation, either version 3 of the +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, @@ -34,7 +34,7 @@ namespace Sparkles.Git { string branch { get { - if (!string.IsNullOrEmpty (this.cached_branch)) + if (!string.IsNullOrEmpty (this.cached_branch)) return this.cached_branch; var git = new GitCommand (LocalPath, "config core.ignorecase true"); @@ -44,7 +44,7 @@ namespace Sparkles.Git { while (this.in_merge && HasLocalChanges) { try { ResolveConflict (); - + } catch (IOException e) { Logger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); } @@ -177,7 +177,7 @@ namespace Sparkles.Git { Error = ErrorStatus.None; return true; - + } else { Logger.LogInfo ("Git", Name + " | Remote " + remote_revision + " is already in our history"); return false; @@ -406,7 +406,7 @@ namespace Sparkles.Git { bool Merge () { string message = FormatCommitMessage (); - + if (message != null) { Add (); Commit (message); @@ -418,7 +418,7 @@ namespace Sparkles.Git { if (this.in_merge) { git = new GitCommand (LocalPath, "merge --abort"); git.StartAndWaitForExit (); - + return false; } @@ -446,11 +446,11 @@ namespace Sparkles.Git { git.StartAndWaitForExit (); return false; - + } else { Logger.LogInfo ("Git", error_output); Logger.LogInfo ("Git", Name + " | Conflict detected, trying to get out..."); - + while (this.in_merge && HasLocalChanges) { try { ResolveConflict (); @@ -546,7 +546,7 @@ namespace Sparkles.Git { string file_name_B = Path.GetFileNameWithoutExtension (conflicting_file_path) + clue_B + Path.GetExtension (conflicting_file_path); string abs_conflicting_file_path = Path.Combine (LocalPath, conflicting_file_path); - + string abs_file_path_A = Path.Combine (Path.GetDirectoryName (abs_conflicting_file_path), file_name_A); string abs_file_path_B = Path.Combine (Path.GetDirectoryName (abs_conflicting_file_path), file_name_B); @@ -583,15 +583,15 @@ namespace Sparkles.Git { var git_add = new GitCommand (LocalPath, "add \"" + conflicting_file_path + "\""); git_add.StartAndWaitForExit (); - + // The local version has been modified, but the server version was removed } else if (line.StartsWith ("UD")) { - + // Recover our version var git_theirs = new GitCommand (LocalPath, "checkout --ours \"" + conflicting_file_path + "\""); git_theirs.StartAndWaitForExit (); - + // Server and local versions were removed } else if (line.StartsWith ("DD")) { Logger.LogInfo ("Git", Name + " | No need to resolve: " + line); @@ -599,7 +599,7 @@ namespace Sparkles.Git { // New local files } else if (line.StartsWith ("??")) { Logger.LogInfo ("Git", Name + " | Found new file, no need to resolve: " + line); - + } else { Logger.LogInfo ("Git", Name + " | Don't know what to do with: " + line); } @@ -639,7 +639,7 @@ namespace Sparkles.Git { // ...move it... try { File.Move (local_file_path, target_file_path); - + } catch (Exception e) { string message = string.Format ("Failed to move \"{0}\" to \"{1}\"", local_file_path, target_file_path); Logger.LogInfo ("Git", Name + " | " + message, e); @@ -669,7 +669,7 @@ namespace Sparkles.Git { public override List GetChangeSets (string path) { return GetChangeSetsInternal (path); - } + } List GetChangeSetsInternal (string path) { @@ -946,18 +946,18 @@ namespace Sparkles.Git { continue; string HEAD_file_path = Path.Combine (child_path, "HEAD"); - + if (File.Exists (HEAD_file_path)) { File.Move (HEAD_file_path, HEAD_file_path + ".backup"); Logger.LogInfo ("Git", Name + " | Renamed " + HEAD_file_path); } - + continue; } - + PrepareDirectories (child_path); } - + if (Directory.GetFiles (path).Length == 0 && Directory.GetDirectories (path).Length == 0 && !path.Equals (LocalPath)) { @@ -986,26 +986,26 @@ namespace Sparkles.Git { var git_status = new GitCommand (LocalPath, "status --porcelain"); git_status.Start (); - + while (!git_status.StandardOutput.EndOfStream) { string line = git_status.StandardOutput.ReadLine (); line = line.Trim (); - + if (line.EndsWith (".empty") || line.EndsWith (".empty\"")) line = line.Replace (".empty", ""); Change change; - + if (line.StartsWith ("R")) { string path = line.Substring (3, line.IndexOf (" -> ") - 3).Trim ("\" ".ToCharArray ()); string moved_to_path = line.Substring (line.IndexOf (" -> ") + 4).Trim ("\" ".ToCharArray ()); - + change = new Change () { Type = ChangeType.Moved, Path = EnsureSpecialChars (path), MovedToPath = EnsureSpecialChars (moved_to_path) }; - + } else { string path = line.Substring (2).Trim ("\" ".ToCharArray ()); change = new Change () { Path = EnsureSpecialChars (path) }; @@ -1013,7 +1013,7 @@ namespace Sparkles.Git { if (line.StartsWith ("M")) { change.Type = ChangeType.Edited; - + } else if (line.StartsWith ("D")) { change.Type = ChangeType.Deleted; } @@ -1021,7 +1021,7 @@ namespace Sparkles.Git { changes.Add (change); } - + git_status.StandardOutput.ReadToEnd (); git_status.WaitForExit (); @@ -1071,7 +1071,7 @@ namespace Sparkles.Git { try { foreach (DirectoryInfo directory in parent.GetDirectories ()) { if (directory.FullName.IsSymlink () || - directory.Name.Equals (".git") || + directory.Name.Equals (".git") || directory.Name.Equals ("rebase-apply")) { continue; @@ -1088,13 +1088,13 @@ namespace Sparkles.Git { foreach (FileInfo file in parent.GetFiles ()) { if (file.FullName.IsSymlink ()) continue; - + if (file.Name.Equals (".empty")) File.SetAttributes (file.FullName, FileAttributes.Hidden); else size += file.Length; } - + } catch (Exception e) { Logger.LogInfo ("Local", "Error calculating file size", e); } @@ -1102,7 +1102,7 @@ namespace Sparkles.Git { return size; } - + bool IsSymlink (string file) { FileAttributes attributes = File.GetAttributes (file);