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