diff --git a/SparkleLib/Makefile.am b/SparkleLib/Makefile.am
index 94a456e7..f46f7b52 100644
--- a/SparkleLib/Makefile.am
+++ b/SparkleLib/Makefile.am
@@ -13,7 +13,6 @@ SOURCES = \
SparkleListener.cs \
SparkleOptions.cs \
SparklePaths.cs \
- SparklePlatform.cs \
SparkleRepo.cs
SMARTIRC4NET_FILES_EXPANDED = $(foreach file, $(SMARTIRC4NET_FILES), $(top_builddir)/$(file))
diff --git a/SparkleLib/SparkleCommit.cs b/SparkleLib/SparkleCommit.cs
index ea91c0e6..f6ff7cc7 100644
--- a/SparkleLib/SparkleCommit.cs
+++ b/SparkleLib/SparkleCommit.cs
@@ -14,39 +14,24 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+
using System;
using System.Collections.Generic;
namespace SparkleLib {
- public class SparkleCommit
- {
+ public class SparkleCommit {
- public string UserName;
- public string UserEmail;
- public DateTime DateTime;
- public string Hash;
- public bool IsMerge;
-
- public List Added;
- public List Deleted;
- public List Edited;
- public List MovedFrom;
- public List MovedTo;
-
- public SparkleCommit ()
- {
-
- Edited = new List ();
- Added = new List ();
- Deleted = new List ();
- MovedFrom = new List ();
- MovedTo = new List ();
-
- IsMerge = false;
-
- }
-
- }
+ public string UserName;
+ public string UserEmail;
+ public string Hash;
+ public DateTime DateTime;
+ public bool IsMerge = false;
+ public List Added = new List ();
+ public List Deleted = new List ();
+ public List Edited = new List ();
+ public List MovedFrom = new List ();
+ public List MovedTo = new List ();
+ }
}
diff --git a/SparkleLib/SparkleEvents.cs b/SparkleLib/SparkleEvents.cs
index 41d0bb9d..ff60ca91 100644
--- a/SparkleLib/SparkleEvents.cs
+++ b/SparkleLib/SparkleEvents.cs
@@ -19,26 +19,21 @@ using System;
namespace SparkleLib {
// Arguments for most events
- public class SparkleEventArgs : System.EventArgs {
-
+ public class SparkleEventArgs : EventArgs {
+
public string Type;
public string Message;
-
public SparkleEventArgs (string type)
{
-
Type = type;
-
}
-
}
// Arguments for the NewCommit event
- public class NewCommitArgs : System.EventArgs {
+ public class NewCommitArgs : EventArgs {
-
public string Author;
public string Email;
public string Message;
@@ -46,14 +41,10 @@ namespace SparkleLib {
public NewCommitArgs (string author, string email, string message, string repository_path)
{
-
Author = author;
Email = email;
Message = message;
RepositoryPath = repository_path;
-
}
-
}
-
}
diff --git a/SparkleLib/SparkleFetcher.cs b/SparkleLib/SparkleFetcher.cs
index 89e8b7f4..3af82401 100644
--- a/SparkleLib/SparkleFetcher.cs
+++ b/SparkleLib/SparkleFetcher.cs
@@ -18,96 +18,86 @@
using System;
using System.IO;
using System.Diagnostics;
-using System.Timers;
namespace SparkleLib {
- // A helper class that fetches and configures
- // a remote repository
- public class SparkleFetcher {
+ // A helper class that fetches and configures
+ // a remote repository
+ public class SparkleFetcher {
- public delegate void CloningStartedEventHandler (object o, SparkleEventArgs args);
- public delegate void CloningFinishedEventHandler (object o, SparkleEventArgs args);
- public delegate void CloningFailedEventHandler (object o, SparkleEventArgs args);
+ // TODO: remove 'cloning' prefix
+ public delegate void CloningStartedEventHandler (object o, SparkleEventArgs args);
+ public delegate void CloningFinishedEventHandler (object o, SparkleEventArgs args);
+ public delegate void CloningFailedEventHandler (object o, SparkleEventArgs args);
- public event CloningStartedEventHandler CloningStarted;
- public event CloningFinishedEventHandler CloningFinished;
- public event CloningFailedEventHandler CloningFailed;
+ public event CloningStartedEventHandler CloningStarted;
+ public event CloningFinishedEventHandler CloningFinished;
+ public event CloningFailedEventHandler CloningFailed;
- private string TargetFolder;
- private string RemoteOriginUrl;
+ private string TargetFolder;
+ private string RemoteOriginUrl;
- public SparkleFetcher (string url, string folder)
- {
-
- TargetFolder = folder;
- RemoteOriginUrl = url;
-
- }
+ public SparkleFetcher (string url, string folder)
+ {
+ TargetFolder = folder;
+ RemoteOriginUrl = url;
+ }
- // Clones the remote repository
- public void Start ()
- {
+ // Clones the remote repository
+ public void Start ()
+ {
+ SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning Repository");
- if (Directory.Exists (TargetFolder))
- Directory.Delete (TargetFolder, true);
-
- SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning Repository");
-
- if (CloningStarted != null)
- CloningStarted (this, new SparkleEventArgs ("CloningStarted"));
+ if (Directory.Exists (TargetFolder))
+ Directory.Delete (TargetFolder, true);
- SparkleGit git = new SparkleGit (SparklePaths.SparkleTmpPath,
+
+ if (CloningStarted != null)
+ CloningStarted (this, new SparkleEventArgs ("CloningStarted"));
+
+ SparkleGit git = new SparkleGit (SparklePaths.SparkleTmpPath,
"clone \"" + RemoteOriginUrl + "\" " + "\"" + TargetFolder + "\"");
- git.Exited += delegate {
+ git.Exited += delegate {
+ SparkleHelpers.DebugInfo ("Git", "Exit code " + git.ExitCode.ToString ());
- SparkleHelpers.DebugInfo ("Git", "Exit code " + git.ExitCode.ToString ());
+ if (git.ExitCode != 0) {
+ SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning failed");
- if (git.ExitCode != 0) {
+ if (CloningFailed != null)
+ CloningFailed (this, new SparkleEventArgs ("CloningFailed"));
+ } else {
+ InstallConfiguration ();
+ InstallExcludeRules ();
+
+ SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Repository cloned");
- SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning failed");
+ if (CloningFinished != null)
+ CloningFinished (this, new SparkleEventArgs ("CloningFinished"));
+ }
+ };
- if (CloningFailed != null)
- CloningFailed (this, new SparkleEventArgs ("CloningFailed"));
-
- } else {
-
- InstallConfiguration ();
- InstallExcludeRules ();
-
- SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Repository cloned");
-
- if (CloningFinished != null)
- CloningFinished (this, new SparkleEventArgs ("CloningFinished"));
-
- }
-
- };
-
- git.Start ();
-
- }
+ git.Start ();
+ }
- // Install the user's name and email and some config into
- // the newly cloned repository
- private void InstallConfiguration ()
- {
-
- string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
+ // Install the user's name and email and some config into
+ // the newly cloned repository
+ private void InstallConfiguration ()
+ {
+ string global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config");
if (File.Exists (global_config_file_path)) {
-
StreamReader reader = new StreamReader (global_config_file_path);
string user_info = reader.ReadToEnd ();
reader.Close ();
string repo_config_file_path = SparkleHelpers.CombineMore (TargetFolder, ".git", "config");
-
string config = String.Join ("\n", File.ReadAllLines (repo_config_file_path));
+
+ // Be case sensitive explicitly to work on Mac
config = config.Replace ("ignorecase = true", "ignorecase = false");
config += Environment.NewLine + user_info;
@@ -116,60 +106,54 @@ namespace SparkleLib {
writer.Close ();
SparkleHelpers.DebugInfo ("Config", "Added configuration to '" + repo_config_file_path + "'");
-
}
-
}
- // Add a .gitignore file to the repo
- private void InstallExcludeRules ()
- {
+ // Add a .gitignore file to the repo
+ private void InstallExcludeRules ()
+ {
+ string exlude_rules_file_path = SparkleHelpers.CombineMore (
+ TargetFolder, ".git", "info", "exclude");
- string exlude_rules_file_path = SparkleHelpers.CombineMore
- (TargetFolder, ".git", "info", "exclude");
+ TextWriter writer = new StreamWriter (exlude_rules_file_path);
- TextWriter writer = new StreamWriter (exlude_rules_file_path);
+ // gedit and emacs
+ writer.WriteLine ("*~");
- // gedit and emacs
- writer.WriteLine ("*~");
+ // vi(m)
+ writer.WriteLine (".*.sw[a-z]");
+ writer.WriteLine ("*.un~");
+ writer.WriteLine ("*.swp");
+ writer.WriteLine ("*.swo");
+
+ // KDE
+ writer.WriteLine (".directory");
+
+ // Mac OSX
+ writer.WriteLine (".DS_Store");
+ writer.WriteLine ("Icon?");
+ writer.WriteLine ("._*");
+ writer.WriteLine (".Spotlight-V100");
+ writer.WriteLine (".Trashes");
- // vi(m)
- writer.WriteLine (".*.sw[a-z]");
- writer.WriteLine ("*.un~");
- writer.WriteLine ("*.swp");
- writer.WriteLine ("*.swo");
-
- // KDE
- writer.WriteLine (".directory");
-
- // Mac OSX
- writer.WriteLine (".DS_Store");
- writer.WriteLine ("Icon?");
- writer.WriteLine ("._*");
- writer.WriteLine (".Spotlight-V100");
- writer.WriteLine (".Trashes");
+ // Mac OSX
+ writer.WriteLine ("*(Autosaved).graffle");
+
+ // Windows
+ writer.WriteLine ("Thumbs.db");
+ writer.WriteLine ("Desktop.ini");
- // Mac OSX
- writer.WriteLine ("*(Autosaved).graffle");
-
- // Windows
- writer.WriteLine ("Thumbs.db");
- writer.WriteLine ("Desktop.ini");
+ // CVS
+ writer.WriteLine ("*/CVS/*");
+ writer.WriteLine (".cvsignore");
+ writer.WriteLine ("*/.cvsignore");
+
+ // Subversion
+ writer.WriteLine ("/.svn/*");
+ writer.WriteLine ("*/.svn/*");
- // CVS
- writer.WriteLine ("*/CVS/*");
- writer.WriteLine (".cvsignore");
- writer.WriteLine ("*/.cvsignore");
-
- // Subversion
- writer.WriteLine ("/.svn/*");
- writer.WriteLine ("*/.svn/*");
-
- writer.Close ();
-
- }
-
- }
-
+ writer.Close ();
+ }
+ }
}
diff --git a/SparkleLib/SparkleGit.cs b/SparkleLib/SparkleGit.cs
index ddfe3b65..a648603a 100644
--- a/SparkleLib/SparkleGit.cs
+++ b/SparkleLib/SparkleGit.cs
@@ -20,17 +20,17 @@ using System.Diagnostics;
namespace SparkleLib {
- public class SparkleGit : Process {
+ public class SparkleGit : Process {
- public SparkleGit (string path, string args) : base ()
- {
- EnableRaisingEvents = true;
- StartInfo.FileName = SparklePaths.GitPath;
- StartInfo.Arguments = args;
- StartInfo.RedirectStandardOutput = true;
- StartInfo.UseShellExecute = false;
- StartInfo.WorkingDirectory = path;
- }
+ public SparkleGit (string path, string args) : base ()
+ {
+ EnableRaisingEvents = true;
+ StartInfo.FileName = SparklePaths.GitPath;
+ StartInfo.Arguments = args;
+ StartInfo.RedirectStandardOutput = true;
+ StartInfo.UseShellExecute = false;
+ StartInfo.WorkingDirectory = path;
+ }
new public void Start ()
@@ -38,5 +38,5 @@ namespace SparkleLib {
SparkleHelpers.DebugInfo ("Cmd", StartInfo.FileName + " " + StartInfo.Arguments);
base.Start ();
}
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/SparkleLib/SparkleListener.cs b/SparkleLib/SparkleListener.cs
index 78c70761..3cd15736 100644
--- a/SparkleLib/SparkleListener.cs
+++ b/SparkleLib/SparkleListener.cs
@@ -25,126 +25,105 @@ using Meebey.SmartIrc4net;
namespace SparkleLib {
- public enum NotificationServerType
- {
-
- Own,
- Central
-
- }
+ public enum NotificationServerType
+ {
+ Own,
+ Central
+ }
- // A persistent connection to the server that
- // listens for change notifications
- public class SparkleListener {
+ // A persistent connection to the server that
+ // listens for change notifications
+ public class SparkleListener {
- // FIXME: The IrcClient is a public property because
- // extending it causes crashes
- public IrcClient Client;
- private Thread Thread;
- public readonly string Server;
- public readonly string FallbackServer;
- public readonly string Channel;
- public readonly string Nick;
+ private Thread Thread;
+
+ // FIXME: The IrcClient is a public property because
+ // extending it causes crashes
+ public IrcClient Client;
+ public readonly string Server;
+ public readonly string FallbackServer;
+ public readonly string Channel;
+ public readonly string Nick;
- public SparkleListener (string server, string folder_name,
- string user_email, NotificationServerType type)
- {
+ public SparkleListener (string server, string folder_name,
+ string user_email, NotificationServerType type)
+ {
+ if (type == NotificationServerType.Own) {
+ Server = server;
+ } else {
- if (type == NotificationServerType.Own) {
+ // This is SparkleShare's centralized notification service.
+ // Don't worry, we only use this server as a backup if you
+ // don't have your own. All data needed to connect is hashed and
+ // we don't store any personal information ever.
+ Server = "204.62.14.135";
+ }
- Server = server;
+ if (!String.IsNullOrEmpty (user_email))
+ Nick = SHA1 (folder_name + user_email + "sparkles");
+ else
+ Nick = SHA1 (DateTime.Now.ToString () + "sparkles");
- } else {
+ Nick = "s" + Nick.Substring (0, 7);
+ Channel = "#" + SHA1 (server + folder_name + "sparkles");
- // This is SparkleShare's centralized notification service.
- // Don't worry, we only use this server as a backup if you
- // don't have your own. All data needed to connect is hashed and
- // we don't store any personal information ever.
- Server = "204.62.14.135";
-
- }
-
- if (!user_email.Equals ("") && user_email != null)
- Nick = GetSHA1 (folder_name + user_email + "sparkles");
- else
- Nick = GetSHA1 (DateTime.Now.ToString () + "sparkles");
-
- Nick = "s" + Nick.Substring (0, 7);
- Channel = "#" + GetSHA1 (server + folder_name + "sparkles");
-
- Client = new IrcClient () {
- PingTimeout = 180,
- PingInterval = 90
- };
-
- }
+ Client = new IrcClient () {
+ PingTimeout = 180,
+ PingInterval = 90
+ };
+ }
- // Starts a new thread and listens to the channel
- public void Listen ()
- {
+ // Starts a new thread and listens to the channel
+ public void Listen ()
+ {
+ Thread = new Thread (
+ new ThreadStart (delegate {
+ try {
- Thread = new Thread (
- new ThreadStart (delegate {
+ // Connect, login, and join the channel
+ Client.Connect (new string [] {Server}, 6667);
+ Client.Login (Nick, Nick);
+ Client.RfcJoin (Channel);
- try {
+ // List to the channel, this blocks the thread
+ Client.Listen ();
+ Client.Disconnect ();
+ } catch (Meebey.SmartIrc4net.ConnectionException e) {
+ Console.WriteLine ("Could not connect: " + e.Message);
+ }
+ })
+ );
- // Connect to the server
- Client.Connect (new string [] {Server}, 6667);
-
- // Login to the server
- Client.Login (Nick, Nick);
-
- // Join the channel
- Client.RfcJoin (Channel);
-
- Client.Listen ();
-
- Client.Disconnect ();
-
- } catch (Meebey.SmartIrc4net.ConnectionException e) {
-
- Console.WriteLine ("Could not connect: " + e.Message);
-
- }
-
- })
- );
-
- Thread.Start ();
-
- }
-
-
- public void Announce (string message)
- {
-
- Client.SendMessage (SendType.Message, Channel, message);
-
- }
+ Thread.Start ();
+ }
- // Frees all resources for this Listener
- public void Dispose ()
- {
+ public void Announce (string message)
+ {
+ Client.SendMessage (SendType.Message, Channel, message);
+ }
- Thread.Abort ();
- Thread.Join ();
- }
+ // Frees all resources for this Listener
+ public void Dispose ()
+ {
+ Thread.Abort ();
+ Thread.Join ();
+ }
-
- // Creates an SHA-1 hash of input
- private static string GetSHA1 (string s)
- {
- SHA1 sha1 = new SHA1CryptoServiceProvider ();
- Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
- Byte[] encoded_bytes = sha1.ComputeHash (bytes);
- return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
- }
-
- }
+
+ // Creates an SHA-1 hash of input
+ private string SHA1 (string s)
+ {
+ SHA1 sha1 = new SHA1CryptoServiceProvider ();
+ Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
+ Byte[] encoded_bytes = sha1.ComputeHash (bytes);
+ return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
+ }
+
+ }
}
diff --git a/SparkleLib/SparklePaths.cs b/SparkleLib/SparklePaths.cs
index cb0f085d..c901f9b1 100644
--- a/SparkleLib/SparklePaths.cs
+++ b/SparkleLib/SparklePaths.cs
@@ -26,9 +26,7 @@ namespace SparkleLib {
public static string Name = "Git";
public static string Path {
-
get {
-
string [] possible_git_paths = {"/usr/bin/git",
"/usr/local/git/bin/git",
"/usr/local/bin/git"};
@@ -38,37 +36,29 @@ namespace SparkleLib {
return git_path;
return null;
-
}
-
}
public static bool IsPresent {
-
get {
-
return (Path != null);
-
}
-
}
-
}
-
- public static class SparklePaths {
-
- public static string GitPath = Backend.Path;
- public static string HomePath = new UnixUserInfo (UnixEnvironment.UserName).HomeDirectory;
- public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
- public static string SparkleTmpPath = Path.Combine (SparklePath, ".tmp");
- public static string SparkleConfigPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
- public static string SparkleKeysPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
- public static string SparkleInstallPath = Path.Combine (Defines.PREFIX, "sparkleshare");
- public static string SparkleLocalIconPath = SparkleHelpers.CombineMore (SparkleConfigPath, "icons");
- public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare", "icons");
- }
+ public static class SparklePaths {
+ public static string GitPath = Backend.Path;
+ public static string HomePath = new UnixUserInfo (UnixEnvironment.UserName).HomeDirectory;
+ public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
+ public static string SparkleTmpPath = Path.Combine (SparklePath, ".tmp");
+ public static string SparkleConfigPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
+ public static string SparkleKeysPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
+ public static string SparkleInstallPath = Path.Combine (Defines.PREFIX, "sparkleshare");
+ public static string SparkleLocalIconPath = SparkleHelpers.CombineMore (SparkleConfigPath, "icons");
+ public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare", "icons");
+
+ }
}
diff --git a/SparkleLib/SparklePlatform.cs b/SparkleLib/SparklePlatform.cs
deleted file mode 100644
index b42282b2..00000000
--- a/SparkleLib/SparklePlatform.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// SparkleShare, an instant update workflow to Git.
-// Copyright (C) 2010 Hylke Bons
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU 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,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-using System;
-
-namespace SparkleShare {
-
- public static class SparklePlatform {
-
- // Detect OSX, Windows, GNOME or KDE here
- public static string Name = "GNOME";
-
- }
-
-}
diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs
index 347f4c31..5df67db6 100644
--- a/SparkleShare/SparkleController.cs
+++ b/SparkleShare/SparkleController.cs
@@ -682,29 +682,23 @@ namespace SparkleShare {
public bool NotificationsEnabled {
-
get {
-
- string notify_setting_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
+ string notify_setting_file_path = Path.Combine (SparklePaths.SparkleConfigPath,
"sparkleshare.notify");
return File.Exists (notify_setting_file_path);
-
}
-
}
public void ToggleNotifications () {
-
- string notify_setting_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
+ string notify_setting_file_path = Path.Combine (SparklePaths.SparkleConfigPath,
"sparkleshare.notify");
if (File.Exists (notify_setting_file_path))
File.Delete (notify_setting_file_path);
else
File.Create (notify_setting_file_path);
-
}
diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs
index ebb15056..db27bdcd 100644
--- a/SparkleShare/SparkleIntro.cs
+++ b/SparkleShare/SparkleIntro.cs
@@ -645,6 +645,7 @@ namespace SparkleShare {
};
+
Button button = new Button () {
Sensitive = false,
Label = _("Finish")
@@ -671,6 +672,16 @@ namespace SparkleShare {
box.PackStart (table, false, false, 0);
+ Progressbar bar = new Progressbar ();
+ box.PackStart (bar, true, true, 0);
+ Timer timer = new Timer () {
+ Interval = 500
+ };
+ timer.Elapsed += delegate {
+ bar.Pulse ();
+ };
+ timer.Start ();
+
layout_vertical.PackStart (box, false, false, 0);
Add (layout_vertical);