Merge pull request #1838 from IvanMalison/removeSomeTrailingWhitespace

Remove (some) trailing whitespace
This commit is contained in:
Hylke Bons 2018-04-09 10:30:49 +01:00 committed by GitHub
commit e448362352
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 225 additions and 227 deletions

View file

@ -39,10 +39,10 @@ namespace SparkleShare
#endif #endif
email = email.ToLower (); email = email.ToLower ();
if (skipped_avatars.Contains (email)) if (skipped_avatars.Contains (email))
return null; return null;
string avatars_path = Path.Combine (Path.GetDirectoryName (target_path), "avatars", size + "x" + size); string avatars_path = Path.Combine (Path.GetDirectoryName (target_path), "avatars", size + "x" + size);
// Search avatars by file name, ignore extension // Search avatars by file name, ignore extension
@ -66,10 +66,10 @@ namespace SparkleShare
Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e);
return null; return null;
} }
var client = new WebClient (); var client = new WebClient ();
string url = "https://gravatar.com/avatar/" + email.MD5 () + ".png?s=" + size + "&d=404"; string url = "https://gravatar.com/avatar/" + email.MD5 () + ".png?s=" + size + "&d=404";
try { try {
byte [] buffer = client.DownloadData (url); byte [] buffer = client.DownloadData (url);
@ -78,30 +78,30 @@ namespace SparkleShare
} else if (client.ResponseHeaders ["content-type"].Equals (MediaTypeNames.Image.Gif, StringComparison.InvariantCultureIgnoreCase)) { } else if (client.ResponseHeaders ["content-type"].Equals (MediaTypeNames.Image.Gif, StringComparison.InvariantCultureIgnoreCase)) {
avatar_file_path += ".gif"; avatar_file_path += ".gif";
} else { } else {
avatar_file_path += ".png"; avatar_file_path += ".png";
} }
if (buffer.Length > 255) { if (buffer.Length > 255) {
if (!Directory.Exists (avatars_path)) { if (!Directory.Exists (avatars_path)) {
Directory.CreateDirectory (avatars_path); Directory.CreateDirectory (avatars_path);
Logger.LogInfo ("Avatars", "Created '" + avatars_path + "'"); Logger.LogInfo ("Avatars", "Created '" + avatars_path + "'");
} }
File.WriteAllBytes (avatar_file_path, buffer); File.WriteAllBytes (avatar_file_path, buffer);
Logger.LogInfo ("Avatars", "Fetched " + size + "x" + size + " avatar for " + email); Logger.LogInfo ("Avatars", "Fetched " + size + "x" + size + " avatar for " + email);
return avatar_file_path; return avatar_file_path;
} else { } else {
return null; return null;
} }
} catch (Exception e) { } catch (Exception e) {
Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e); Logger.LogInfo ("Avatars", "Error fetching avatar for " + email, e);
skipped_avatars.Add (email); skipped_avatars.Add (email);
return null; return null;
} }
} }
@ -111,11 +111,11 @@ namespace SparkleShare
X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{ {
X509Certificate2 certificate2 = new X509Certificate2 (certificate.GetRawCertData ()); X509Certificate2 certificate2 = new X509Certificate2 (certificate.GetRawCertData ());
// On some systems (mostly Linux) we can't assume the needed certificates are // 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. // 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 // Set to expire on Oct 14 2018
string gravatar_cert_fingerprint = "1264B3F00814C6077D3853238771EE67FB6321C9"; string gravatar_cert_fingerprint = "1264B3F00814C6077D3853238771EE67FB6321C9";
@ -123,7 +123,7 @@ namespace SparkleShare
Logger.LogInfo ("Avatars", "Invalid certificate for https://www.gravatar.com/"); Logger.LogInfo ("Avatars", "Invalid certificate for https://www.gravatar.com/");
return false; return false;
} }
return true; return true;
} }
} }

View file

@ -24,17 +24,17 @@ using System.Threading;
using Sparkles; using Sparkles;
namespace SparkleShare { namespace SparkleShare {
public abstract class BaseController { public abstract class BaseController {
public BaseRepository [] Repositories { public BaseRepository [] Repositories {
get { get {
lock (this.repo_lock) lock (this.repo_lock)
return this.repositories.GetRange (0, this.repositories.Count).ToArray (); return this.repositories.GetRange (0, this.repositories.Count).ToArray ();
} }
} }
void AddRepository (BaseRepository repo) void AddRepository (BaseRepository repo)
{ {
lock (this.repo_lock) { lock (this.repo_lock) {
@ -42,15 +42,15 @@ namespace SparkleShare {
this.repositories.Sort ((x, y) => string.Compare (x.Name, y.Name)); this.repositories.Sort ((x, y) => string.Compare (x.Name, y.Name));
} }
} }
void RemoveRepository (BaseRepository repo) void RemoveRepository (BaseRepository repo)
{ {
lock (this.repo_lock) lock (this.repo_lock)
this.repositories.Remove (repo); this.repositories.Remove (repo);
} }
public BaseRepository GetRepoByName (string name) public BaseRepository GetRepoByName (string name)
{ {
lock (this.repo_lock) { lock (this.repo_lock) {
@ -58,15 +58,15 @@ namespace SparkleShare {
if (repo.Name.Equals (name)) if (repo.Name.Equals (name))
return repo; return repo;
} }
return null; return null;
} }
public Configuration Config { get; private set; } public Configuration Config { get; private set; }
public bool RepositoriesLoaded { get; private set; } public bool RepositoriesLoaded { get; private set; }
public string FoldersPath { get; private set; } public string FoldersPath { get; private set; }
public double ProgressPercentage = 0.0; public double ProgressPercentage = 0.0;
public double ProgressSpeedUp = 0.0; public double ProgressSpeedUp = 0.0;
public double ProgressSpeedDown = 0.0; public double ProgressSpeedDown = 0.0;
@ -81,37 +81,37 @@ namespace SparkleShare {
public event Action ShowAboutWindowEvent = delegate { }; public event Action ShowAboutWindowEvent = delegate { };
public event Action ShowEventLogWindowEvent = delegate { }; public event Action ShowEventLogWindowEvent = delegate { };
public event FolderFetchedEventHandler FolderFetched = delegate { }; public event FolderFetchedEventHandler FolderFetched = delegate { };
public delegate void FolderFetchedEventHandler (string remote_url, string [] warnings); public delegate void FolderFetchedEventHandler (string remote_url, string [] warnings);
public event FolderFetchErrorHandler FolderFetchError = delegate { }; public event FolderFetchErrorHandler FolderFetchError = delegate { };
public delegate void FolderFetchErrorHandler (string remote_url, string [] errors); public delegate void FolderFetchErrorHandler (string remote_url, string [] errors);
public event FolderFetchingHandler FolderFetching = delegate { }; public event FolderFetchingHandler FolderFetching = delegate { };
public delegate void FolderFetchingHandler (double percentage, double speed, string information); public delegate void FolderFetchingHandler (double percentage, double speed, string information);
public event Action FolderListChanged = delegate { }; public event Action FolderListChanged = delegate { };
public event Action OnIdle = delegate { }; public event Action OnIdle = delegate { };
public event Action OnSyncing = delegate { }; public event Action OnSyncing = delegate { };
public event Action OnError = delegate { }; public event Action OnError = delegate { };
public event InviteReceivedHandler InviteReceived = delegate { }; public event InviteReceivedHandler InviteReceived = delegate { };
public delegate void InviteReceivedHandler (SparkleInvite invite); public delegate void InviteReceivedHandler (SparkleInvite invite);
public event NotificationRaisedEventHandler NotificationRaised = delegate { }; public event NotificationRaisedEventHandler NotificationRaised = delegate { };
public delegate void NotificationRaisedEventHandler (ChangeSet change_set); public delegate void NotificationRaisedEventHandler (ChangeSet change_set);
public event AlertNotificationRaisedEventHandler AlertNotificationRaised = delegate { }; public event AlertNotificationRaisedEventHandler AlertNotificationRaised = delegate { };
public delegate void AlertNotificationRaisedEventHandler (string title, string message); public delegate void AlertNotificationRaisedEventHandler (string title, string message);
public bool FirstRun { public bool FirstRun {
get { return Config.User.Email.Equals ("Unknown"); } get { return Config.User.Email.Equals ("Unknown"); }
} }
public List<string> Folders { public List<string> Folders {
get { get {
List<string> folders = Config.Folders; List<string> folders = Config.Folders;
@ -131,32 +131,32 @@ namespace SparkleShare {
public bool NotificationsEnabled { public bool NotificationsEnabled {
get { get {
string notifications_enabled = Config.GetConfigOption ("notifications"); string notifications_enabled = Config.GetConfigOption ("notifications");
if (string.IsNullOrEmpty (notifications_enabled)) { if (string.IsNullOrEmpty (notifications_enabled)) {
Config.SetConfigOption ("notifications", bool.TrueString); Config.SetConfigOption ("notifications", bool.TrueString);
return true; return true;
} else { } else {
return notifications_enabled.Equals (bool.TrueString); return notifications_enabled.Equals (bool.TrueString);
} }
} }
} }
public bool AvatarsEnabled { public bool AvatarsEnabled {
get { get {
string fetch_avatars_option = Config.GetConfigOption ("fetch_avatars"); string fetch_avatars_option = Config.GetConfigOption ("fetch_avatars");
if (fetch_avatars_option == null || fetch_avatars_option.Equals (bool.FalseString)) if (fetch_avatars_option == null || fetch_avatars_option.Equals (bool.FalseString))
return false; return false;
return true; return true;
} }
} }
// Path where the plugins are kept // Path where the plugins are kept
public abstract string PresetsPath { get; } public abstract string PresetsPath { get; }
// Enables SparkleShare to start automatically at login // Enables SparkleShare to start automatically at login
public abstract void CreateStartupItem (); public abstract void CreateStartupItem ();
@ -168,16 +168,16 @@ namespace SparkleShare {
// Creates the SparkleShare folder in the user's home folder // Creates the SparkleShare folder in the user's home folder
public abstract void CreateSparkleShareFolder (); public abstract void CreateSparkleShareFolder ();
// Opens the SparkleShare folder or an (optional) subfolder // Opens the SparkleShare folder or an (optional) subfolder
public abstract void OpenFolder (string path); public abstract void OpenFolder (string path);
// Opens a file with the appropriate application // Opens a file with the appropriate application
public abstract void OpenFile (string path); public abstract void OpenFile (string path);
// Opens a file with the appropriate application // Opens a file with the appropriate application
public virtual void OpenWebsite (string url) { } public virtual void OpenWebsite (string url) { }
// Copies text to the clipboard // Copies text to the clipboard
public abstract void CopyToClipboard (string text); public abstract void CopyToClipboard (string text);
@ -187,23 +187,23 @@ namespace SparkleShare {
public abstract string EventLogHTML { get; } public abstract string EventLogHTML { get; }
public abstract string DayEntryHTML { get; } public abstract string DayEntryHTML { get; }
public abstract string EventEntryHTML { get; } public abstract string EventEntryHTML { get; }
BaseFetcher fetcher; BaseFetcher fetcher;
FileSystemWatcher watcher; FileSystemWatcher watcher;
object repo_lock = new object (); object repo_lock = new object ();
object check_repos_lock = new object (); object check_repos_lock = new object ();
List<BaseRepository> repositories = new List<BaseRepository> (); List<BaseRepository> repositories = new List<BaseRepository> ();
bool lost_folders_path = false; bool lost_folders_path = false;
public BaseController (Configuration config) public BaseController (Configuration config)
{ {
Config = config; Config = config;
FoldersPath = Config.FoldersPath; FoldersPath = Config.FoldersPath;
} }
public virtual void Initialize () public virtual void Initialize ()
{ {
string version = InstallationInfo.Version; string version = InstallationInfo.Version;
@ -221,7 +221,7 @@ namespace SparkleShare {
Preset.PresetsPath = PresetsPath; Preset.PresetsPath = PresetsPath;
InstallProtocolHandler (); InstallProtocolHandler ();
try { try {
CreateSparkleShareFolder (); CreateSparkleShareFolder ();
@ -237,19 +237,19 @@ namespace SparkleShare {
IncludeSubdirectories = false, IncludeSubdirectories = false,
Path = FoldersPath Path = FoldersPath
}; };
watcher.Created += OnFolderActivity; watcher.Created += OnFolderActivity;
watcher.EnableRaisingEvents = true; watcher.EnableRaisingEvents = true;
} }
int reopen_attempt_counts = 0; int reopen_attempt_counts = 0;
public void HandleReopen () public void HandleReopen ()
{ {
if (Repositories.Length > 0) { if (Repositories.Length > 0) {
ShowEventLogWindow (); ShowEventLogWindow ();
} else if (reopen_attempt_counts > 1) { } else if (reopen_attempt_counts > 1) {
AlertNotificationRaised ("Hello!", "SparkleShare sits right here, as a status icon."); AlertNotificationRaised ("Hello!", "SparkleShare sits right here, as a status icon.");
reopen_attempt_counts = 0; reopen_attempt_counts = 0;
@ -265,31 +265,31 @@ namespace SparkleShare {
if (this.lost_folders_path) { if (this.lost_folders_path) {
SparkleShare.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); "Did you put it on a detached drive?", null);
Environment.Exit (-1); Environment.Exit (-1);
} }
if (FirstRun) { if (FirstRun) {
ShowSetupWindow (PageType.Setup); ShowSetupWindow (PageType.Setup);
} else { } else {
new Thread (() => { new Thread (() => {
StartupInviteScan (); StartupInviteScan ();
CheckRepositories (); CheckRepositories ();
RepositoriesLoaded = true; RepositoriesLoaded = true;
UpdateState (); UpdateState ();
}).Start (); }).Start ();
} }
} }
public void ShowSetupWindow (PageType page_type) public void ShowSetupWindow (PageType page_type)
{ {
ShowSetupWindowEvent (page_type); ShowSetupWindowEvent (page_type);
} }
public void ShowAboutWindow () public void ShowAboutWindow ()
{ {
ShowAboutWindowEvent (); ShowAboutWindowEvent ();
@ -300,33 +300,33 @@ namespace SparkleShare {
{ {
ShowNoteWindowEvent (project); ShowNoteWindowEvent (project);
} }
public void ShowEventLogWindow () public void ShowEventLogWindow ()
{ {
ShowEventLogWindowEvent (); ShowEventLogWindowEvent ();
} }
public void OpenSparkleShareFolder () public void OpenSparkleShareFolder ()
{ {
OpenFolder (Config.FoldersPath); OpenFolder (Config.FoldersPath);
} }
public void OpenSparkleShareFolder (string name) public void OpenSparkleShareFolder (string name)
{ {
OpenFolder (new SparkleFolder (name).FullPath); OpenFolder (new SparkleFolder (name).FullPath);
} }
public void ToggleNotifications () public void ToggleNotifications ()
{ {
bool notifications_enabled = Config.GetConfigOption ("notifications").Equals (bool.TrueString); bool notifications_enabled = Config.GetConfigOption ("notifications").Equals (bool.TrueString);
Config.SetConfigOption ("notifications", (!notifications_enabled).ToString ()); Config.SetConfigOption ("notifications", (!notifications_enabled).ToString ());
} }
void CheckRepositories () void CheckRepositories ()
{ {
lock (this.check_repos_lock) { lock (this.check_repos_lock) {
@ -393,21 +393,21 @@ namespace SparkleShare {
BaseRepository repo = null; BaseRepository repo = null;
string folder_name = Path.GetFileName (folder_path); string folder_name = Path.GetFileName (folder_path);
string backend = Config.BackendByName (folder_name); string backend = Config.BackendByName (folder_name);
try { try {
repo = (BaseRepository) Activator.CreateInstance ( repo = (BaseRepository) Activator.CreateInstance (
Type.GetType ("Sparkles." + backend + "." + backend + "Repository, Sparkles." + backend), Type.GetType ("Sparkles." + backend + "." + backend + "Repository, Sparkles." + backend),
new object [] { folder_path, Config, SSHAuthenticationInfo.DefaultAuthenticationInfo }); new object [] { folder_path, Config, SSHAuthenticationInfo.DefaultAuthenticationInfo });
} catch (Exception e) { } catch (Exception e) {
Logger.LogInfo ("Controller", "Failed to load backend '" + backend + "' for '" + folder_name + "': ", e); Logger.LogInfo ("Controller", "Failed to load backend '" + backend + "' for '" + folder_name + "': ", e);
return; return;
} }
repo.ChangesDetected += delegate { repo.ChangesDetected += delegate {
UpdateState (); UpdateState ();
}; };
repo.SyncStatusChanged += delegate (SyncStatus status) { repo.SyncStatusChanged += delegate (SyncStatus status) {
if (status == SyncStatus.Idle) { if (status == SyncStatus.Idle) {
ProgressPercentage = 0.0; ProgressPercentage = 0.0;
@ -415,54 +415,54 @@ namespace SparkleShare {
ProgressSpeedDown = 0.0; ProgressSpeedDown = 0.0;
ProgressInformation = ""; ProgressInformation = "";
} }
UpdateState (); UpdateState ();
}; };
repo.ProgressChanged += delegate { repo.ProgressChanged += delegate {
ProgressPercentage = 0.0; ProgressPercentage = 0.0;
ProgressSpeedUp = 0.0; ProgressSpeedUp = 0.0;
ProgressSpeedDown = 0.0; ProgressSpeedDown = 0.0;
ProgressInformation = ""; ProgressInformation = "";
double percentage = 0.0; double percentage = 0.0;
int repo_count = 0; int repo_count = 0;
foreach (BaseRepository rep in Repositories) { foreach (BaseRepository rep in Repositories) {
if (rep.ProgressPercentage > 0) { if (rep.ProgressPercentage > 0) {
percentage += rep.ProgressPercentage; percentage += rep.ProgressPercentage;
repo_count++; repo_count++;
} }
if (rep.Status == SyncStatus.SyncUp) if (rep.Status == SyncStatus.SyncUp)
ProgressSpeedUp += rep.ProgressSpeed; ProgressSpeedUp += rep.ProgressSpeed;
if (rep.Status == SyncStatus.SyncDown) if (rep.Status == SyncStatus.SyncDown)
ProgressSpeedDown += rep.ProgressSpeed; ProgressSpeedDown += rep.ProgressSpeed;
} }
if (repo_count == 1) if (repo_count == 1)
ProgressInformation = repo.ProgressInformation; ProgressInformation = repo.ProgressInformation;
if (repo_count > 0) if (repo_count > 0)
ProgressPercentage = percentage / repo_count; ProgressPercentage = percentage / repo_count;
UpdateState (); UpdateState ();
}; };
repo.NewChangeSet += delegate (ChangeSet change_set) { repo.NewChangeSet += delegate (ChangeSet change_set) {
if (AvatarsEnabled) if (AvatarsEnabled)
change_set.User.AvatarFilePath = Avatars.GetAvatar (change_set.User.Email, 48, Config.DirectoryPath); change_set.User.AvatarFilePath = Avatars.GetAvatar (change_set.User.Email, 48, Config.DirectoryPath);
NotificationRaised (change_set); NotificationRaised (change_set);
}; };
repo.ConflictResolved += delegate { repo.ConflictResolved += delegate {
AlertNotificationRaised ("Resolved a file collision", "Local and server versions were kept."); AlertNotificationRaised ("Resolved a file collision", "Local and server versions were kept.");
}; };
AddRepository (repo); AddRepository (repo);
repo.Initialize (); repo.Initialize ();
} }
@ -475,31 +475,31 @@ namespace SparkleShare {
return; return;
} }
} }
void StartupInviteScan () void StartupInviteScan ()
{ {
foreach (string invite in Directory.GetFiles (FoldersPath, "*.xml")) foreach (string invite in Directory.GetFiles (FoldersPath, "*.xml"))
HandleInvite (invite); HandleInvite (invite);
} }
void HandleInvite (FileSystemEventArgs args) void HandleInvite (FileSystemEventArgs args)
{ {
HandleInvite (args.FullPath); HandleInvite (args.FullPath);
} }
void HandleInvite (string path) void HandleInvite (string path)
{ {
if (this.fetcher != null && if (this.fetcher != null &&
this.fetcher.IsActive) { this.fetcher.IsActive) {
AlertNotificationRaised ("SparkleShare Setup seems busy", "Please wait for it to finish"); AlertNotificationRaised ("SparkleShare Setup seems busy", "Please wait for it to finish");
} else { } else {
SparkleInvite invite = new SparkleInvite (path); SparkleInvite invite = new SparkleInvite (path);
// It may be that the invite we received a path to isn't // It may be that the invite we received a path to isn't
// fully downloaded yet, so we try to read it several times // fully downloaded yet, so we try to read it several times
int tries = 0; int tries = 0;
@ -507,37 +507,37 @@ namespace SparkleShare {
Thread.Sleep (100); Thread.Sleep (100);
invite = new SparkleInvite (path); invite = new SparkleInvite (path);
tries++; tries++;
if (tries > 10) { if (tries > 10) {
AlertNotificationRaised ("Oh noes!", "This invite seems screwed up..."); AlertNotificationRaised ("Oh noes!", "This invite seems screwed up...");
break; break;
} }
} }
if (invite.IsValid) if (invite.IsValid)
InviteReceived (invite); InviteReceived (invite);
File.Delete (path); File.Delete (path);
} }
} }
// Fires events for the current syncing state // Fires events for the current syncing state
void UpdateState () void UpdateState ()
{ {
bool has_unsynced_repos = false; bool has_unsynced_repos = false;
bool has_syncing_repos = false; bool has_syncing_repos = false;
foreach (BaseRepository repo in Repositories) { foreach (BaseRepository repo in Repositories) {
if (repo.Status == SyncStatus.SyncDown || repo.Status == SyncStatus.SyncUp || repo.IsBuffering) { if (repo.Status == SyncStatus.SyncDown || repo.Status == SyncStatus.SyncUp || repo.IsBuffering) {
has_syncing_repos = true; has_syncing_repos = true;
break; break;
} else if (repo.Status == SyncStatus.Idle && repo.HasUnsyncedChanges) { } else if (repo.Status == SyncStatus.Idle && repo.HasUnsyncedChanges) {
has_unsynced_repos = true; has_unsynced_repos = true;
} }
} }
if (has_syncing_repos) if (has_syncing_repos)
OnSyncing (); OnSyncing ();
else if (has_unsynced_repos) else if (has_unsynced_repos)
@ -545,7 +545,7 @@ namespace SparkleShare {
else else
OnIdle (); OnIdle ();
} }
public List<StorageTypeInfo> FetcherAvailableStorageTypes { public List<StorageTypeInfo> FetcherAvailableStorageTypes {
get { get {
@ -557,31 +557,31 @@ namespace SparkleShare {
public void StartFetcher (SparkleFetcherInfo info) public void StartFetcher (SparkleFetcherInfo info)
{ {
string canonical_name = Path.GetFileName (info.RemotePath); string canonical_name = Path.GetFileName (info.RemotePath);
string backend = info.Backend; string backend = info.Backend;
if (string.IsNullOrEmpty (backend)) if (string.IsNullOrEmpty (backend))
backend = BaseFetcher.GetBackend (info.Address); backend = BaseFetcher.GetBackend (info.Address);
info.TargetDirectory = Path.Combine (Config.TmpPath, canonical_name); info.TargetDirectory = Path.Combine (Config.TmpPath, canonical_name);
if (Directory.Exists (info.TargetDirectory)) if (Directory.Exists (info.TargetDirectory))
Directory.Delete (info.TargetDirectory, true); Directory.Delete (info.TargetDirectory, true);
try { try {
this.fetcher = (BaseFetcher) Activator.CreateInstance ( this.fetcher = (BaseFetcher) Activator.CreateInstance (
Type.GetType ("Sparkles." + backend + "." + backend + "Fetcher, Sparkles." + backend), Type.GetType ("Sparkles." + backend + "." + backend + "Fetcher, Sparkles." + backend),
new object [] { info, UserAuthenticationInfo}); new object [] { info, UserAuthenticationInfo});
} catch (Exception e) { } catch (Exception e) {
Logger.LogInfo ("Controller", Logger.LogInfo ("Controller",
"Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message); "Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message);
FolderFetchError (Path.Combine (info.Address, info.RemotePath).Replace (@"\", "/"), FolderFetchError (Path.Combine (info.Address, info.RemotePath).Replace (@"\", "/"),
new string [] {"Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\""}); new string [] {"Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\""});
return; return;
} }
this.fetcher.Finished += FetcherFinishedDelegate; this.fetcher.Finished += FetcherFinishedDelegate;
this.fetcher.Failed += FetcherFailedDelegate; this.fetcher.Failed += FetcherFailedDelegate;
this.fetcher.ProgressChanged += FetcherProgressChangedDelgate; this.fetcher.ProgressChanged += FetcherProgressChangedDelgate;
@ -623,12 +623,12 @@ namespace SparkleShare {
{ {
this.fetcher.Stop (); this.fetcher.Stop ();
this.fetcher.Dispose (); this.fetcher.Dispose ();
this.fetcher = null; this.fetcher = null;
this.watcher.EnableRaisingEvents = true; this.watcher.EnableRaisingEvents = true;
} }
public bool CheckPassword (string password) public bool CheckPassword (string password)
{ {
return this.fetcher.IsFetchedRepoPasswordCorrect (password); return this.fetcher.IsFetchedRepoPasswordCorrect (password);
@ -689,10 +689,10 @@ namespace SparkleShare {
FolderListChanged (); FolderListChanged ();
FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ()); FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ());
this.fetcher.Dispose (); this.fetcher.Dispose ();
this.fetcher = null; this.fetcher = null;
this.watcher.EnableRaisingEvents = true; this.watcher.EnableRaisingEvents = true;
} }

View file

@ -36,16 +36,16 @@ namespace SparkleShare {
public event UpdateContentEventEventHandler UpdateContentEvent = delegate { }; public event UpdateContentEventEventHandler UpdateContentEvent = delegate { };
public delegate void UpdateContentEventEventHandler (string html); public delegate void UpdateContentEventEventHandler (string html);
public event UpdateChooserEventHandler UpdateChooserEvent = delegate { }; public event UpdateChooserEventHandler UpdateChooserEvent = delegate { };
public delegate void UpdateChooserEventHandler (string [] folders); public delegate void UpdateChooserEventHandler (string [] folders);
public event UpdateChooserEnablementEventHandler UpdateChooserEnablementEvent = delegate { }; public event UpdateChooserEnablementEventHandler UpdateChooserEnablementEvent = delegate { };
public delegate void UpdateChooserEnablementEventHandler (bool enabled); public delegate void UpdateChooserEnablementEventHandler (bool enabled);
public event UpdateSizeInfoEventHandler UpdateSizeInfoEvent = delegate { }; public event UpdateSizeInfoEventHandler UpdateSizeInfoEvent = delegate { };
public delegate void UpdateSizeInfoEventHandler (string size, string history_size); public delegate void UpdateSizeInfoEventHandler (string size, string history_size);
public event ShowSaveDialogEventHandler ShowSaveDialogEvent = delegate { }; public event ShowSaveDialogEventHandler ShowSaveDialogEvent = delegate { };
public delegate void ShowSaveDialogEventHandler (string file_name, string target_folder_path); public delegate void ShowSaveDialogEventHandler (string file_name, string target_folder_path);
@ -162,7 +162,7 @@ namespace SparkleShare {
if (!string.IsNullOrEmpty (html)) if (!string.IsNullOrEmpty (html))
UpdateContentEvent (html); UpdateContentEvent (html);
UpdateSizeInfoEvent (Size, HistorySize); UpdateSizeInfoEvent (Size, HistorySize);
}).Start (); }).Start ();
@ -172,7 +172,7 @@ namespace SparkleShare {
WindowIsOpen = true; WindowIsOpen = true;
ShowWindowEvent (); ShowWindowEvent ();
}; };
SparkleShare.Controller.OnIdle += delegate { SparkleShare.Controller.OnIdle += delegate {
if (this.history_view_active) if (this.history_view_active)
return; return;
@ -189,7 +189,7 @@ namespace SparkleShare {
UpdateSizeInfoEvent (Size, HistorySize); UpdateSizeInfoEvent (Size, HistorySize);
}; };
SparkleShare.Controller.FolderListChanged += delegate { SparkleShare.Controller.FolderListChanged += delegate {
if (this.selected_folder != null && !SparkleShare.Controller.Folders.Contains (this.selected_folder)) if (this.selected_folder != null && !SparkleShare.Controller.Folders.Contains (this.selected_folder))
this.selected_folder = null; this.selected_folder = null;
@ -212,16 +212,16 @@ namespace SparkleShare {
{ {
if (string.IsNullOrEmpty (href) || href.StartsWith ("about:")) if (string.IsNullOrEmpty (href) || href.StartsWith ("about:"))
return; return;
href = href.Replace ("%20", " "); href = href.Replace ("%20", " ");
if (href.StartsWith ("http")) { if (href.StartsWith ("http")) {
SparkleShare.Controller.OpenWebsite (href); SparkleShare.Controller.OpenWebsite (href);
} else if (href.StartsWith ("restore://") && this.restore_revision_info == null) { } 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]+)/(.+)"); Regex regex = new Regex ("restore://(.+)/([a-f0-9]+)/(.+)/(.{3} [0-9]+ [0-9]+h[0-9]+)/(.+)");
Match match = regex.Match (href); Match match = regex.Match (href);
if (match.Success) { if (match.Success) {
string author_name = match.Groups [3].Value; string author_name = match.Groups [3].Value;
string timestamp = match.Groups [4].Value; string timestamp = match.Groups [4].Value;
@ -240,7 +240,7 @@ namespace SparkleShare {
ShowSaveDialogEvent (file_name, target_folder_path); ShowSaveDialogEvent (file_name, target_folder_path);
} }
} else if (href.StartsWith ("back://")) { } else if (href.StartsWith ("back://")) {
this.history_view_active = false; this.history_view_active = false;
SelectedFolder = this.selected_folder; // TODO: Return to the same position on the page SelectedFolder = this.selected_folder; // TODO: Return to the same position on the page
@ -283,9 +283,9 @@ namespace SparkleShare {
} else { } else {
if (href.StartsWith ("file:///")) if (href.StartsWith ("file:///"))
href = href.Substring (7); href = href.Substring (7);
SparkleShare.Controller.OpenFile (href); SparkleShare.Controller.OpenFile (href);
} }
} }
@ -374,13 +374,13 @@ namespace SparkleShare {
html += "<tr>" + html += "<tr>" +
"<td class='avatar'><img src='" + GetAvatarFilePath (change_set.User) + "'></td>" + "<td class='avatar'><img src='" + GetAvatarFilePath (change_set.User) + "'></td>" +
"<td class='name'>" + change_set.User.Name + "</td>" + "<td class='name'>" + change_set.User.Name + "</td>" +
"<td class='date'>" + "<td class='date'>" +
change_set.Timestamp.ToString ("d MMM yyyy", CultureInfo.InvariantCulture) + change_set.Timestamp.ToString ("d MMM yyyy", CultureInfo.InvariantCulture) +
"</td>" + "</td>" +
"<td class='time'>" + change_set.Timestamp.ToString ("HH:mm") + "</td>" + "<td class='time'>" + change_set.Timestamp.ToString ("HH:mm") + "</td>" +
"<td class='restore'>" + "<td class='restore'>" +
"<a href='restore://" + change_set.Folder.Name + "/" + "<a href='restore://" + change_set.Folder.Name + "/" +
change_set.Revision + "/" + change_set.User.Name + "/" + change_set.Revision + "/" + change_set.User.Name + "/" +
change_set.Timestamp.ToString ("MMM d H\\hmm", CultureInfo.InvariantCulture) + "/" + change_set.Timestamp.ToString ("MMM d H\\hmm", CultureInfo.InvariantCulture) + "/" +
file_path + "'>Restore&hellip;</a>" + file_path + "'>Restore&hellip;</a>" +
"</td>" + "</td>" +
@ -407,7 +407,7 @@ namespace SparkleShare {
foreach (ChangeSet change_set in change_sets) { foreach (ChangeSet change_set in change_sets) {
bool change_set_inserted = false; bool change_set_inserted = false;
foreach (ActivityDay stored_activity_day in activity_days) { foreach (ActivityDay stored_activity_day in activity_days) {
if (stored_activity_day.Date.Year == change_set.Timestamp.Year && if (stored_activity_day.Date.Year == change_set.Timestamp.Year &&
stored_activity_day.Date.Month == change_set.Timestamp.Month && stored_activity_day.Date.Month == change_set.Timestamp.Month &&
@ -443,7 +443,7 @@ namespace SparkleShare {
event_entry += "<dd class='" + change.Type.ToString ().ToLower () + "'>"; event_entry += "<dd class='" + change.Type.ToString ().ToLower () + "'>";
if (!change.IsFolder) { if (!change.IsFolder) {
event_entry += "<small><a href=\"history://" + change_set.Folder.Name + "/" + event_entry += "<small><a href=\"history://" + change_set.Folder.Name + "/" +
change.Path + "\" title=\"View revisions\">" + change.Timestamp.ToString ("HH:mm") + change.Path + "\" title=\"View revisions\">" + change.Timestamp.ToString ("HH:mm") +
" &#x25BE;</a></small> &nbsp;"; " &#x25BE;</a></small> &nbsp;";
@ -582,7 +582,7 @@ namespace SparkleShare {
private string SafeCombine (string path1, string path2) private string SafeCombine (string path1, string path2)
{ {
string result = path1; string result = path1;
if (!result.EndsWith (Path.DirectorySeparatorChar.ToString ())) if (!result.EndsWith (Path.DirectorySeparatorChar.ToString ()))
result += Path.DirectorySeparatorChar; result += Path.DirectorySeparatorChar;
@ -597,9 +597,9 @@ namespace SparkleShare {
{ {
if (!SparkleShare.Controller.AvatarsEnabled) if (!SparkleShare.Controller.AvatarsEnabled)
return "<!-- $pixmaps-path -->/user-icon-default.png"; return "<!-- $pixmaps-path -->/user-icon-default.png";
string fetched_avatar = Avatars.GetAvatar (user.Email, 48, SparkleShare.Controller.Config.DirectoryPath); string fetched_avatar = Avatars.GetAvatar (user.Email, 48, SparkleShare.Controller.Config.DirectoryPath);
if (!string.IsNullOrEmpty (fetched_avatar)) if (!string.IsNullOrEmpty (fetched_avatar))
return "file://" + fetched_avatar.Replace ("\\", "/"); return "file://" + fetched_avatar.Replace ("\\", "/");
else else

View file

@ -45,11 +45,11 @@ namespace SparkleShare {
Controller.WindowClosed (); Controller.WindowClosed ();
args.RetVal = true; args.RetVal = true;
}; };
KeyPressEvent += delegate (object o, KeyPressEventArgs args) { KeyPressEvent += delegate (object o, KeyPressEventArgs args) {
if (args.Event.Key == Gdk.Key.Escape || if (args.Event.Key == Gdk.Key.Escape ||
(args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) { (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) {
Controller.WindowClosed (); Controller.WindowClosed ();
} }
}; };
@ -151,13 +151,13 @@ namespace SparkleShare {
Add (layout_horizontal); Add (layout_horizontal);
} }
} }
class Link : Label { class Link : Label {
public Link (string label, string url) public Link (string label, string url)
{ {
Markup = string.Format ("<a href=\"{0}\">{1}</a>", url, label); Markup = string.Format ("<a href=\"{0}\">{1}</a>", url, label);
CanFocus = false; CanFocus = false;
CssProvider css_provider = new CssProvider (); CssProvider css_provider = new CssProvider ();

View file

@ -41,11 +41,11 @@ namespace SparkleShare {
Controller.WindowClosed (); Controller.WindowClosed ();
args.RetVal = true; args.RetVal = true;
}; };
KeyPressEvent += delegate (object o, KeyPressEventArgs args) { KeyPressEvent += delegate (object o, KeyPressEventArgs args) {
if (args.Event.Key == Gdk.Key.Escape || if (args.Event.Key == Gdk.Key.Escape ||
(args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) { (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) {
Controller.WindowClosed (); Controller.WindowClosed ();
} }
}; };
@ -144,4 +144,3 @@ namespace SparkleShare {
} }
} }
} }

View file

@ -4,7 +4,7 @@
### Common build requirements ### 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 ```shell
# On Ubuntu 16.04: # On Ubuntu 16.04:
@ -40,8 +40,8 @@ sudo dnf install \
### Additional source build requirements ### Additional source build requirements
Install the `soup-sharp` and `webkit2gtk-sharp` bindings from: Install the `soup-sharp` and `webkit2gtk-sharp` bindings from:
https://github.com/hbons/soup-sharp https://github.com/hbons/soup-sharp
https://github.com/hbons/webkit2gtk-sharp https://github.com/hbons/webkit2gtk-sharp
Both with: Both with:

View file

@ -82,7 +82,7 @@ namespace SparkleShare {
public void AddOption (Widget widget) public void AddOption (Widget widget)
{ {
this.option_area.Add (widget); this.option_area.Add (widget);
} }
@ -99,7 +99,7 @@ namespace SparkleShare {
LineWrap = true, LineWrap = true,
LineWrapMode = Pango.WrapMode.WordChar LineWrapMode = Pango.WrapMode.WordChar
}; };
layout_vertical.PackStart (description, false, false, 0); layout_vertical.PackStart (description, false, false, 0);
} }
@ -109,7 +109,7 @@ namespace SparkleShare {
this.content_area.Add (layout_vertical); this.content_area.Add (layout_vertical);
} }
public void Reset () public void Reset ()
{ {
Header = ""; Header = "";
@ -124,13 +124,13 @@ namespace SparkleShare {
foreach (Button button in this.buttons) foreach (Button button in this.buttons)
this.buttons.Remove (button); this.buttons.Remove (button);
} }
new public void ShowAll () new public void ShowAll ()
{ {
if (this.buttons.Children.Length > 0) { if (this.buttons.Children.Length > 0) {
Button default_button = (Button) this.buttons.Children [this.buttons.Children.Length - 1]; Button default_button = (Button) this.buttons.Children [this.buttons.Children.Length - 1];
default_button.CanDefault = true; default_button.CanDefault = true;
Default = default_button; Default = default_button;
default_button.StyleContext.AddClass ("suggested-action"); default_button.StyleContext.AddClass ("suggested-action");
@ -141,4 +141,3 @@ namespace SparkleShare {
} }
} }
} }

View file

@ -16,7 +16,7 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Controls; using System.Windows.Controls;
@ -38,7 +38,7 @@ namespace SparkleShare {
Height = 288; Height = 288;
Width = 720; Width = 720;
Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico"); Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico");
WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStartupLocation = WindowStartupLocation.CenterScreen;
Closing += Close; Closing += Close;
@ -73,10 +73,10 @@ namespace SparkleShare {
Width = 720, Width = 720,
Height = 260 Height = 260
}; };
image.Source = UserInterfaceHelpers.GetImageSource ("about"); image.Source = UserInterfaceHelpers.GetImageSource ("about");
Label version = new Label () { Label version = new Label () {
Content = "version " + Controller.RunningVersion, Content = "version " + Controller.RunningVersion,
FontSize = 11, FontSize = 11,
@ -88,7 +88,7 @@ namespace SparkleShare {
FontSize = 11, FontSize = 11,
Foreground = new SolidColorBrush (Color.FromArgb (128, 255, 255, 255)) Foreground = new SolidColorBrush (Color.FromArgb (128, 255, 255, 255))
}; };
TextBlock credits = new TextBlock () { TextBlock credits = new TextBlock () {
FontSize = 11, FontSize = 11,
Foreground = new SolidColorBrush (Colors.White), Foreground = new SolidColorBrush (Colors.White),
@ -99,14 +99,14 @@ namespace SparkleShare {
TextWrapping = TextWrapping.Wrap, TextWrapping = TextWrapping.Wrap,
Width = 318 Width = 318
}; };
SparkleLink website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress); SparkleLink website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress);
SparkleLink credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress); SparkleLink credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress);
SparkleLink report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress); SparkleLink report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress);
SparkleLink debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress); SparkleLink debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress);
Canvas canvas = new Canvas (); Canvas canvas = new Canvas ();
canvas.Children.Add (image); canvas.Children.Add (image);
Canvas.SetLeft (image, 0); Canvas.SetLeft (image, 0);
Canvas.SetTop (image, 0); Canvas.SetTop (image, 0);
@ -114,18 +114,18 @@ namespace SparkleShare {
canvas.Children.Add (version); canvas.Children.Add (version);
Canvas.SetLeft (version, 289); Canvas.SetLeft (version, 289);
Canvas.SetTop (version, 92); Canvas.SetTop (version, 92);
canvas.Children.Add (this.updates); canvas.Children.Add (this.updates);
Canvas.SetLeft (this.updates, 289); Canvas.SetLeft (this.updates, 289);
Canvas.SetTop (this.updates, 109); Canvas.SetTop (this.updates, 109);
canvas.Children.Add (credits); canvas.Children.Add (credits);
Canvas.SetLeft (credits, 294); Canvas.SetLeft (credits, 294);
Canvas.SetTop (credits, 142); Canvas.SetTop (credits, 142);
canvas.Children.Add (website_link); canvas.Children.Add (website_link);
Canvas.SetLeft (website_link, 289); Canvas.SetLeft (website_link, 289);
Canvas.SetTop (website_link, 222); Canvas.SetTop (website_link, 222);
canvas.Children.Add (credits_link); canvas.Children.Add (credits_link);
Canvas.SetLeft (credits_link, 289 + website_link.ActualWidth + 60); Canvas.SetLeft (credits_link, 289 + website_link.ActualWidth + 60);
@ -133,21 +133,21 @@ namespace SparkleShare {
canvas.Children.Add (report_problem_link); canvas.Children.Add (report_problem_link);
Canvas.SetLeft (report_problem_link, 289 + website_link.ActualWidth + credits_link.ActualWidth + 115); 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.Children.Add (debug_log_link);
Canvas.SetLeft (debug_log_link, 289 + website_link.ActualWidth + credits_link.ActualWidth + Canvas.SetLeft (debug_log_link, 289 + website_link.ActualWidth + credits_link.ActualWidth +
report_problem_link.ActualWidth + 220); report_problem_link.ActualWidth + 220);
Canvas.SetTop (debug_log_link, 222); Canvas.SetTop (debug_log_link, 222);
Content = canvas; Content = canvas;
} }
private void Close (object sender, CancelEventArgs args) private void Close (object sender, CancelEventArgs args)
{ {
Controller.WindowClosed (); Controller.WindowClosed ();
args.Cancel = true; args.Cancel = true;
} }
} }
@ -177,7 +177,7 @@ namespace SparkleShare {
MouseUp += delegate { MouseUp += delegate {
SparkleShare.Controller.OpenWebsite (url); SparkleShare.Controller.OpenWebsite (url);
}; };
} }
} }
} }

View file

@ -2,8 +2,8 @@
// Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk> // Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,

View file

@ -2,8 +2,8 @@
// Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk> // Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
@ -33,7 +33,7 @@ namespace Sparkles {
public abstract class BaseListener { public abstract class BaseListener {
public event Action Connected = delegate { }; public event Action Connected = delegate { };
public event DisconnectedEventHandler Disconnected = delegate { }; public event DisconnectedEventHandler Disconnected = delegate { };
public delegate void DisconnectedEventHandler (DisconnectReason reason); public delegate void DisconnectedEventHandler (DisconnectReason reason);

View file

@ -2,8 +2,8 @@
// Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk> // Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,

View file

@ -436,7 +436,7 @@ namespace Sparkles.Git {
var git_config_clean = new GitCommand (TargetFolder, var git_config_clean = new GitCommand (TargetFolder,
string.Format ("config filter.lfs.clean '{0}'", clean_command)); string.Format ("config filter.lfs.clean '{0}'", clean_command));
git_config_required.StartAndWaitForExit (); git_config_required.StartAndWaitForExit ();
git_config_clean.StartAndWaitForExit (); git_config_clean.StartAndWaitForExit ();
git_config_smudge.StartAndWaitForExit (); git_config_smudge.StartAndWaitForExit ();

View file

@ -2,8 +2,8 @@
// Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk> // Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
@ -34,7 +34,7 @@ namespace Sparkles.Git {
string branch { string branch {
get { get {
if (!string.IsNullOrEmpty (this.cached_branch)) if (!string.IsNullOrEmpty (this.cached_branch))
return this.cached_branch; return this.cached_branch;
var git = new GitCommand (LocalPath, "config core.ignorecase true"); var git = new GitCommand (LocalPath, "config core.ignorecase true");
@ -44,7 +44,7 @@ namespace Sparkles.Git {
while (this.in_merge && HasLocalChanges) { while (this.in_merge && HasLocalChanges) {
try { try {
ResolveConflict (); ResolveConflict ();
} catch (IOException e) { } catch (IOException e) {
Logger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); Logger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e);
} }
@ -177,7 +177,7 @@ namespace Sparkles.Git {
Error = ErrorStatus.None; Error = ErrorStatus.None;
return true; return true;
} else { } else {
Logger.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; return false;
@ -406,7 +406,7 @@ namespace Sparkles.Git {
bool Merge () bool Merge ()
{ {
string message = FormatCommitMessage (); string message = FormatCommitMessage ();
if (message != null) { if (message != null) {
Add (); Add ();
Commit (message); Commit (message);
@ -418,7 +418,7 @@ namespace Sparkles.Git {
if (this.in_merge) { if (this.in_merge) {
git = new GitCommand (LocalPath, "merge --abort"); git = new GitCommand (LocalPath, "merge --abort");
git.StartAndWaitForExit (); git.StartAndWaitForExit ();
return false; return false;
} }
@ -446,11 +446,11 @@ namespace Sparkles.Git {
git.StartAndWaitForExit (); git.StartAndWaitForExit ();
return false; return false;
} else { } else {
Logger.LogInfo ("Git", error_output); Logger.LogInfo ("Git", error_output);
Logger.LogInfo ("Git", Name + " | Conflict detected, trying to get out..."); Logger.LogInfo ("Git", Name + " | Conflict detected, trying to get out...");
while (this.in_merge && HasLocalChanges) { while (this.in_merge && HasLocalChanges) {
try { try {
ResolveConflict (); 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 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_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_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); 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 + "\""); var git_add = new GitCommand (LocalPath, "add \"" + conflicting_file_path + "\"");
git_add.StartAndWaitForExit (); git_add.StartAndWaitForExit ();
// The local version has been modified, but the server version was removed // The local version has been modified, but the server version was removed
} else if (line.StartsWith ("UD")) { } else if (line.StartsWith ("UD")) {
// Recover our version // Recover our version
var git_theirs = new GitCommand (LocalPath, "checkout --ours \"" + conflicting_file_path + "\""); var git_theirs = new GitCommand (LocalPath, "checkout --ours \"" + conflicting_file_path + "\"");
git_theirs.StartAndWaitForExit (); git_theirs.StartAndWaitForExit ();
// Server and local versions were removed // Server and local versions were removed
} else if (line.StartsWith ("DD")) { } else if (line.StartsWith ("DD")) {
Logger.LogInfo ("Git", Name + " | No need to resolve: " + line); Logger.LogInfo ("Git", Name + " | No need to resolve: " + line);
@ -599,7 +599,7 @@ namespace Sparkles.Git {
// New local files // New local files
} else if (line.StartsWith ("??")) { } else if (line.StartsWith ("??")) {
Logger.LogInfo ("Git", Name + " | Found new file, no need to resolve: " + line); Logger.LogInfo ("Git", Name + " | Found new file, no need to resolve: " + line);
} else { } else {
Logger.LogInfo ("Git", Name + " | Don't know what to do with: " + line); Logger.LogInfo ("Git", Name + " | Don't know what to do with: " + line);
} }
@ -639,7 +639,7 @@ namespace Sparkles.Git {
// ...move it... // ...move it...
try { try {
File.Move (local_file_path, target_file_path); File.Move (local_file_path, target_file_path);
} catch (Exception e) { } catch (Exception e) {
string message = string.Format ("Failed to move \"{0}\" to \"{1}\"", local_file_path, target_file_path); string message = string.Format ("Failed to move \"{0}\" to \"{1}\"", local_file_path, target_file_path);
Logger.LogInfo ("Git", Name + " | " + message, e); Logger.LogInfo ("Git", Name + " | " + message, e);
@ -669,7 +669,7 @@ namespace Sparkles.Git {
public override List<ChangeSet> GetChangeSets (string path) public override List<ChangeSet> GetChangeSets (string path)
{ {
return GetChangeSetsInternal (path); return GetChangeSetsInternal (path);
} }
List<ChangeSet> GetChangeSetsInternal (string path) List<ChangeSet> GetChangeSetsInternal (string path)
{ {
@ -946,18 +946,18 @@ namespace Sparkles.Git {
continue; continue;
string HEAD_file_path = Path.Combine (child_path, "HEAD"); string HEAD_file_path = Path.Combine (child_path, "HEAD");
if (File.Exists (HEAD_file_path)) { if (File.Exists (HEAD_file_path)) {
File.Move (HEAD_file_path, HEAD_file_path + ".backup"); File.Move (HEAD_file_path, HEAD_file_path + ".backup");
Logger.LogInfo ("Git", Name + " | Renamed " + HEAD_file_path); Logger.LogInfo ("Git", Name + " | Renamed " + HEAD_file_path);
} }
continue; continue;
} }
PrepareDirectories (child_path); PrepareDirectories (child_path);
} }
if (Directory.GetFiles (path).Length == 0 && if (Directory.GetFiles (path).Length == 0 &&
Directory.GetDirectories (path).Length == 0 && Directory.GetDirectories (path).Length == 0 &&
!path.Equals (LocalPath)) { !path.Equals (LocalPath)) {
@ -986,26 +986,26 @@ namespace Sparkles.Git {
var git_status = new GitCommand (LocalPath, "status --porcelain"); var git_status = new GitCommand (LocalPath, "status --porcelain");
git_status.Start (); git_status.Start ();
while (!git_status.StandardOutput.EndOfStream) { while (!git_status.StandardOutput.EndOfStream) {
string line = git_status.StandardOutput.ReadLine (); string line = git_status.StandardOutput.ReadLine ();
line = line.Trim (); line = line.Trim ();
if (line.EndsWith (".empty") || line.EndsWith (".empty\"")) if (line.EndsWith (".empty") || line.EndsWith (".empty\""))
line = line.Replace (".empty", ""); line = line.Replace (".empty", "");
Change change; Change change;
if (line.StartsWith ("R")) { if (line.StartsWith ("R")) {
string path = line.Substring (3, line.IndexOf (" -> ") - 3).Trim ("\" ".ToCharArray ()); string path = line.Substring (3, line.IndexOf (" -> ") - 3).Trim ("\" ".ToCharArray ());
string moved_to_path = line.Substring (line.IndexOf (" -> ") + 4).Trim ("\" ".ToCharArray ()); string moved_to_path = line.Substring (line.IndexOf (" -> ") + 4).Trim ("\" ".ToCharArray ());
change = new Change () { change = new Change () {
Type = ChangeType.Moved, Type = ChangeType.Moved,
Path = EnsureSpecialChars (path), Path = EnsureSpecialChars (path),
MovedToPath = EnsureSpecialChars (moved_to_path) MovedToPath = EnsureSpecialChars (moved_to_path)
}; };
} else { } else {
string path = line.Substring (2).Trim ("\" ".ToCharArray ()); string path = line.Substring (2).Trim ("\" ".ToCharArray ());
change = new Change () { Path = EnsureSpecialChars (path) }; change = new Change () { Path = EnsureSpecialChars (path) };
@ -1013,7 +1013,7 @@ namespace Sparkles.Git {
if (line.StartsWith ("M")) { if (line.StartsWith ("M")) {
change.Type = ChangeType.Edited; change.Type = ChangeType.Edited;
} else if (line.StartsWith ("D")) { } else if (line.StartsWith ("D")) {
change.Type = ChangeType.Deleted; change.Type = ChangeType.Deleted;
} }
@ -1021,7 +1021,7 @@ namespace Sparkles.Git {
changes.Add (change); changes.Add (change);
} }
git_status.StandardOutput.ReadToEnd (); git_status.StandardOutput.ReadToEnd ();
git_status.WaitForExit (); git_status.WaitForExit ();
@ -1071,7 +1071,7 @@ namespace Sparkles.Git {
try { try {
foreach (DirectoryInfo directory in parent.GetDirectories ()) { foreach (DirectoryInfo directory in parent.GetDirectories ()) {
if (directory.FullName.IsSymlink () || if (directory.FullName.IsSymlink () ||
directory.Name.Equals (".git") || directory.Name.Equals (".git") ||
directory.Name.Equals ("rebase-apply")) { directory.Name.Equals ("rebase-apply")) {
continue; continue;
@ -1088,13 +1088,13 @@ namespace Sparkles.Git {
foreach (FileInfo file in parent.GetFiles ()) { foreach (FileInfo file in parent.GetFiles ()) {
if (file.FullName.IsSymlink ()) if (file.FullName.IsSymlink ())
continue; continue;
if (file.Name.Equals (".empty")) if (file.Name.Equals (".empty"))
File.SetAttributes (file.FullName, FileAttributes.Hidden); File.SetAttributes (file.FullName, FileAttributes.Hidden);
else else
size += file.Length; size += file.Length;
} }
} catch (Exception e) { } catch (Exception e) {
Logger.LogInfo ("Local", "Error calculating file size", e); Logger.LogInfo ("Local", "Error calculating file size", e);
} }
@ -1102,7 +1102,7 @@ namespace Sparkles.Git {
return size; return size;
} }
bool IsSymlink (string file) bool IsSymlink (string file)
{ {
FileAttributes attributes = File.GetAttributes (file); FileAttributes attributes = File.GetAttributes (file);