controller: Code cleanups
This commit is contained in:
parent
8ca3bd3b6b
commit
2ca2c12475
|
@ -105,7 +105,6 @@ namespace SparkleLib {
|
||||||
CreateInitialConfig ();
|
CreateInitialConfig ();
|
||||||
|
|
||||||
} catch (XmlException) {
|
} catch (XmlException) {
|
||||||
|
|
||||||
FileInfo file = new FileInfo (FullPath);
|
FileInfo file = new FileInfo (FullPath);
|
||||||
|
|
||||||
if (file.Length == 0) {
|
if (file.Length == 0) {
|
||||||
|
@ -180,10 +179,10 @@ namespace SparkleLib {
|
||||||
set {
|
set {
|
||||||
SparkleUser user = (SparkleUser) value;
|
SparkleUser user = (SparkleUser) value;
|
||||||
|
|
||||||
XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
||||||
name_node.InnerText = user.Name;
|
name_node.InnerText = user.Name;
|
||||||
|
|
||||||
XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
||||||
email_node.InnerText = user.Email;
|
email_node.InnerText = user.Email;
|
||||||
|
|
||||||
Save ();
|
Save ();
|
||||||
|
@ -205,16 +204,16 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public void AddFolder (string name, string identifier, string url, string backend)
|
public void AddFolder (string name, string identifier, string url, string backend)
|
||||||
{
|
{
|
||||||
XmlNode node_name = CreateElement ("name");
|
XmlNode node_name = CreateElement ("name");
|
||||||
node_name.InnerText = name;
|
node_name.InnerText = name;
|
||||||
|
|
||||||
XmlNode node_identifier = CreateElement ("identifier");
|
XmlNode node_identifier = CreateElement ("identifier");
|
||||||
node_identifier.InnerText = identifier;
|
node_identifier.InnerText = identifier;
|
||||||
|
|
||||||
XmlNode node_url = CreateElement ("url");
|
XmlNode node_url = CreateElement ("url");
|
||||||
node_url.InnerText = url;
|
node_url.InnerText = url;
|
||||||
|
|
||||||
XmlNode node_backend = CreateElement ("backend");
|
XmlNode node_backend = CreateElement ("backend");
|
||||||
node_backend.InnerText = backend;
|
node_backend.InnerText = backend;
|
||||||
|
|
||||||
XmlNode node_folder = CreateNode (XmlNodeType.Element, "folder", null);
|
XmlNode node_folder = CreateNode (XmlNodeType.Element, "folder", null);
|
||||||
|
@ -365,7 +364,7 @@ namespace SparkleLib {
|
||||||
node_root.AppendChild (node);
|
node_root.AppendChild (node);
|
||||||
}
|
}
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Config", "Updated " + name + ":" + content);
|
SparkleHelpers.DebugInfo ("Config", "Updated option " + name + ":" + content);
|
||||||
Save ();
|
Save ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,19 +372,10 @@ namespace SparkleLib {
|
||||||
private void Save ()
|
private void Save ()
|
||||||
{
|
{
|
||||||
if (!File.Exists (FullPath))
|
if (!File.Exists (FullPath))
|
||||||
throw new ConfigFileNotFoundException (FullPath + " does not exist");
|
throw new FileNotFoundException (FullPath + " does not exist");
|
||||||
|
|
||||||
Save (FullPath);
|
Save (FullPath);
|
||||||
SparkleHelpers.DebugInfo ("Config", "Updated \"" + FullPath + "\"");
|
SparkleHelpers.DebugInfo ("Config", "Writen to '" + FullPath + "'");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class ConfigFileNotFoundException : Exception {
|
|
||||||
|
|
||||||
public ConfigFileNotFoundException (string message) : base (message)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,14 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public readonly Uri Server;
|
public readonly Uri Server;
|
||||||
|
|
||||||
|
|
||||||
public abstract void Connect ();
|
public abstract void Connect ();
|
||||||
public abstract bool IsConnected { get; }
|
public abstract bool IsConnected { get; }
|
||||||
public abstract bool IsConnecting { get; }
|
public abstract bool IsConnecting { get; }
|
||||||
|
|
||||||
|
|
||||||
protected abstract void AnnounceInternal (SparkleAnnouncement announcent);
|
protected abstract void AnnounceInternal (SparkleAnnouncement announcent);
|
||||||
protected abstract void AlsoListenToInternal (string folder_identifier);
|
protected abstract void AlsoListenToInternal (string folder_identifier);
|
||||||
|
|
||||||
|
|
||||||
protected List<string> channels = new List<string> ();
|
protected List<string> channels = new List<string> ();
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,11 +52,8 @@ namespace SparkleLib {
|
||||||
private Dictionary<string, List<SparkleAnnouncement>> recent_announcements =
|
private Dictionary<string, List<SparkleAnnouncement>> recent_announcements =
|
||||||
new Dictionary<string, List<SparkleAnnouncement>> ();
|
new Dictionary<string, List<SparkleAnnouncement>> ();
|
||||||
|
|
||||||
private Dictionary<string, SparkleAnnouncement> queue_up =
|
private Dictionary<string, SparkleAnnouncement> queue_up = new Dictionary<string, SparkleAnnouncement> ();
|
||||||
new Dictionary<string, SparkleAnnouncement> ();
|
private Dictionary<string, SparkleAnnouncement> queue_down = new Dictionary<string, SparkleAnnouncement> ();
|
||||||
|
|
||||||
private Dictionary<string, SparkleAnnouncement> queue_down =
|
|
||||||
new Dictionary<string, SparkleAnnouncement> ();
|
|
||||||
|
|
||||||
private Timer reconnect_timer = new Timer {
|
private Timer reconnect_timer = new Timer {
|
||||||
Interval = 60 * 1000,
|
Interval = 60 * 1000,
|
||||||
|
@ -82,25 +79,20 @@ namespace SparkleLib {
|
||||||
{
|
{
|
||||||
if (!IsRecentAnnouncement (announcement)) {
|
if (!IsRecentAnnouncement (announcement)) {
|
||||||
if (IsConnected) {
|
if (IsConnected) {
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener", "Announcing message " + announcement.Message +
|
||||||
"Announcing message " + announcement.Message + " to " +
|
" to " + announcement.FolderIdentifier + " on " + Server);
|
||||||
announcement.FolderIdentifier + " on " + Server);
|
|
||||||
|
|
||||||
AnnounceInternal (announcement);
|
AnnounceInternal (announcement);
|
||||||
AddRecentAnnouncement (announcement);
|
AddRecentAnnouncement (announcement);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener", "Can't send message to " + Server + ". Queuing message");
|
||||||
"Can't send message to " +
|
|
||||||
Server + ". Queuing message");
|
|
||||||
|
|
||||||
this.queue_up [announcement.FolderIdentifier] = announcement;
|
this.queue_up [announcement.FolderIdentifier] = announcement;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener", "Already processed message " + announcement.Message +
|
||||||
"Already processed message " + announcement.Message + " to " +
|
" to " + announcement.FolderIdentifier + " from " + Server);
|
||||||
announcement.FolderIdentifier + " from " + Server);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +100,7 @@ namespace SparkleLib {
|
||||||
public void AlsoListenTo (string channel)
|
public void AlsoListenTo (string channel)
|
||||||
{
|
{
|
||||||
if (!this.channels.Contains (channel) && IsConnected) {
|
if (!this.channels.Contains (channel) && IsConnected) {
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener", "Subscribing to channel " + channel + " on " + Server);
|
||||||
"Subscribing to channel " + channel + " on " + Server);
|
|
||||||
|
|
||||||
this.channels.Add (channel);
|
this.channels.Add (channel);
|
||||||
AlsoListenToInternal (channel);
|
AlsoListenToInternal (channel);
|
||||||
|
@ -132,8 +123,7 @@ namespace SparkleLib {
|
||||||
Connected ();
|
Connected ();
|
||||||
|
|
||||||
if (this.queue_up.Count > 0) {
|
if (this.queue_up.Count > 0) {
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener", "Delivering " + this.queue_up.Count + " queued messages...");
|
||||||
"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;
|
||||||
|
@ -161,15 +151,13 @@ namespace SparkleLib {
|
||||||
announcement.FolderIdentifier + " on " + Server);
|
announcement.FolderIdentifier + " on " + Server);
|
||||||
|
|
||||||
if (IsRecentAnnouncement (announcement)) {
|
if (IsRecentAnnouncement (announcement)) {
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener", "Ignoring previously processed message " + announcement.Message +
|
||||||
"Ignoring previously processed message " + announcement.Message +
|
|
||||||
" from " + announcement.FolderIdentifier + " on " + Server);
|
" from " + announcement.FolderIdentifier + " on " + Server);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener", "Processing message " + announcement.Message + " from " +
|
||||||
"Processing message " + announcement.Message + " from " +
|
|
||||||
announcement.FolderIdentifier + " on " + Server);
|
announcement.FolderIdentifier + " on " + Server);
|
||||||
|
|
||||||
AddRecentAnnouncement (announcement);
|
AddRecentAnnouncement (announcement);
|
||||||
|
@ -188,16 +176,12 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private bool IsRecentAnnouncement (SparkleAnnouncement announcement)
|
private bool IsRecentAnnouncement (SparkleAnnouncement announcement)
|
||||||
{
|
{
|
||||||
if (!this.recent_announcements
|
if (!this.recent_announcements.ContainsKey (announcement.FolderIdentifier)) {
|
||||||
.ContainsKey (announcement.FolderIdentifier)) {
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
foreach (SparkleAnnouncement recent_announcement in
|
foreach (SparkleAnnouncement recent_announcement in GetRecentAnnouncements (announcement.FolderIdentifier)) {
|
||||||
GetRecentAnnouncements (announcement.FolderIdentifier)) {
|
if (recent_announcement.Message.Equals (recent_announcement.Message))
|
||||||
|
|
||||||
if (recent_announcement.Message.Equals (announcement.Message))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +195,7 @@ namespace SparkleLib {
|
||||||
if (!this.recent_announcements.ContainsKey (folder_identifier))
|
if (!this.recent_announcements.ContainsKey (folder_identifier))
|
||||||
this.recent_announcements [folder_identifier] = new List<SparkleAnnouncement> ();
|
this.recent_announcements [folder_identifier] = new List<SparkleAnnouncement> ();
|
||||||
|
|
||||||
return (List<SparkleAnnouncement>) this.recent_announcements [folder_identifier];
|
return this.recent_announcements [folder_identifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,8 +208,7 @@ namespace SparkleLib {
|
||||||
recent_announcements.Add (announcement);
|
recent_announcements.Add (announcement);
|
||||||
|
|
||||||
if (recent_announcements.Count > this.max_recent_announcements)
|
if (recent_announcements.Count > this.max_recent_announcements)
|
||||||
recent_announcements.RemoveRange (0,
|
recent_announcements.RemoveRange (0, recent_announcements.Count - this.max_recent_announcements);
|
||||||
(recent_announcements.Count - this.max_recent_announcements));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,7 @@ namespace SparkleLib {
|
||||||
private DateTime last_ping = DateTime.Now;
|
private DateTime last_ping = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
public SparkleListenerTcp (Uri server, string folder_identifier) :
|
public SparkleListenerTcp (Uri server, string folder_identifier) : base (server, folder_identifier)
|
||||||
base (server, folder_identifier)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,12 +178,9 @@ namespace SparkleLib {
|
||||||
string folder_identifier = line.Substring (0, line.IndexOf ("!"));
|
string folder_identifier = line.Substring (0, line.IndexOf ("!"));
|
||||||
string message = CleanMessage (line.Substring (line.IndexOf ("!") + 1));
|
string message = CleanMessage (line.Substring (line.IndexOf ("!") + 1));
|
||||||
|
|
||||||
if (!folder_identifier.Equals ("debug") &&
|
// We have a message!
|
||||||
!String.IsNullOrEmpty (message)) {
|
if (!folder_identifier.Equals ("debug") && !String.IsNullOrEmpty (message))
|
||||||
|
|
||||||
// We have a message!
|
|
||||||
OnAnnouncement (new SparkleAnnouncement (folder_identifier, message));
|
OnAnnouncement (new SparkleAnnouncement (folder_identifier, message));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -212,8 +208,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
protected override void AnnounceInternal (SparkleAnnouncement announcement)
|
protected override void AnnounceInternal (SparkleAnnouncement announcement)
|
||||||
{
|
{
|
||||||
string to_send = "announce " + announcement.FolderIdentifier
|
string to_send = "announce " + announcement.FolderIdentifier + " " + announcement.Message + "\n";
|
||||||
+ " " + announcement.Message + "\n";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.socket != null)
|
if (this.socket != null)
|
||||||
|
@ -244,9 +239,9 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private string CleanMessage (string message)
|
private string CleanMessage (string message)
|
||||||
{
|
{
|
||||||
return message.Trim ()
|
message = message.Replace ("\n", "");
|
||||||
.Replace ("\n", "")
|
message = message.Replace ("\0", "");
|
||||||
.Replace ("\0", "");
|
return message.Trim ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,11 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private string identifier;
|
private string identifier;
|
||||||
private SparkleListenerBase listener;
|
private SparkleListenerBase listener;
|
||||||
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 TimeSpan progress_change_interval = new TimeSpan (0, 0, 0, 1);
|
||||||
|
|
||||||
|
|
||||||
private Timers.Timer remote_timer = new Timers.Timer () {
|
private Timers.Timer remote_timer = new Timers.Timer () {
|
||||||
Interval = 5000
|
Interval = 5000
|
||||||
|
@ -138,22 +141,19 @@ namespace SparkleLib {
|
||||||
public SparkleRepoBase (string path, SparkleConfig config)
|
public SparkleRepoBase (string path, SparkleConfig config)
|
||||||
{
|
{
|
||||||
this.local_config = config;
|
this.local_config = config;
|
||||||
|
LocalPath = path;
|
||||||
LocalPath = path;
|
Name = Path.GetFileName (LocalPath);
|
||||||
Name = Path.GetFileName (LocalPath);
|
RemoteUrl = new Uri (this.local_config.GetUrlForFolder (Name));
|
||||||
RemoteUrl = new Uri (this.local_config.GetUrlForFolder (Name));
|
IsBuffering = false;
|
||||||
IsBuffering = false;
|
ServerOnline = true;
|
||||||
ServerOnline = true;
|
this.identifier = Identifier;
|
||||||
|
ChangeSets = GetChangeSets ();
|
||||||
|
|
||||||
SyncStatusChanged += delegate (SyncStatus status) {
|
SyncStatusChanged += delegate (SyncStatus status) {
|
||||||
Status = status;
|
Status = status;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.identifier = Identifier;
|
|
||||||
|
|
||||||
ChangeSets = GetChangeSets ();
|
|
||||||
SparkleWatcherFactory.CreateWatcher (this);
|
SparkleWatcherFactory.CreateWatcher (this);
|
||||||
|
|
||||||
new Thread (() => CreateListener ()).Start ();
|
new Thread (() => CreateListener ()).Start ();
|
||||||
|
|
||||||
this.remote_timer.Elapsed += delegate {
|
this.remote_timer.Elapsed += delegate {
|
||||||
|
@ -252,7 +252,6 @@ namespace SparkleLib {
|
||||||
|
|
||||||
} while (IsBuffering);
|
} while (IsBuffering);
|
||||||
|
|
||||||
|
|
||||||
this.remote_timer.Start ();
|
this.remote_timer.Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +263,25 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void OnProgressChanged (double progress_percentage, string progress_speed)
|
||||||
|
{
|
||||||
|
// Only trigger the ProgressChanged event once per second
|
||||||
|
if (DateTime.Compare (this.progress_last_change, DateTime.Now.Subtract (this.progress_change_interval)) >= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ProgressChanged != null) {
|
||||||
|
if (progress_percentage == 100.0)
|
||||||
|
progress_percentage = 99.0;
|
||||||
|
|
||||||
|
ProgressPercentage = progress_percentage;
|
||||||
|
ProgressSpeed = progress_speed;
|
||||||
|
this.progress_last_change = DateTime.Now;
|
||||||
|
|
||||||
|
ProgressChanged (progress_percentage, progress_speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void SyncUpBase ()
|
private void SyncUpBase ()
|
||||||
{
|
{
|
||||||
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Initiated");
|
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Initiated");
|
||||||
|
@ -274,7 +292,6 @@ namespace SparkleLib {
|
||||||
if (SyncStatusChanged != null)
|
if (SyncStatusChanged != null)
|
||||||
SyncStatusChanged (SyncStatus.SyncUp);
|
SyncStatusChanged (SyncStatus.SyncUp);
|
||||||
|
|
||||||
|
|
||||||
if (SyncUp ()) {
|
if (SyncUp ()) {
|
||||||
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done");
|
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done");
|
||||||
HasUnsyncedChanges = false;
|
HasUnsyncedChanges = false;
|
||||||
|
@ -442,29 +459,6 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private DateTime progress_last_change = DateTime.Now;
|
|
||||||
private TimeSpan progress_change_interval = new TimeSpan (0, 0, 0, 1);
|
|
||||||
|
|
||||||
protected void OnProgressChanged (double progress_percentage, string progress_speed)
|
|
||||||
{
|
|
||||||
// Only trigger the ProgressChanged event once per second
|
|
||||||
if (DateTime.Compare (this.progress_last_change, DateTime.Now.Subtract (this.progress_change_interval)) >= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (ProgressChanged != null) {
|
|
||||||
if (progress_percentage == 100.0)
|
|
||||||
progress_percentage = 99.0;
|
|
||||||
|
|
||||||
ProgressPercentage = progress_percentage;
|
|
||||||
ProgressSpeed = progress_speed;
|
|
||||||
|
|
||||||
this.progress_last_change = DateTime.Now;
|
|
||||||
|
|
||||||
ProgressChanged (progress_percentage, progress_speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Recursively gets a folder's size in bytes
|
// Recursively gets a folder's size in bytes
|
||||||
private double CalculateSize (DirectoryInfo parent)
|
private double CalculateSize (DirectoryInfo parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,19 +39,20 @@ namespace SparkleShare {
|
||||||
public static void Main (string [] args)
|
public static void Main (string [] args)
|
||||||
{
|
{
|
||||||
if (args.Length != 0 && !args [0].Equals ("start")) {
|
if (args.Length != 0 && !args [0].Equals ("start")) {
|
||||||
Console.WriteLine (" ");
|
string n = Environment.NewLine;
|
||||||
Console.WriteLine ("SparkleShare is a collaboration and sharing tool that is ");
|
|
||||||
Console.WriteLine ("designed to keep things simple and to stay out of your way.");
|
Console.WriteLine (n +
|
||||||
Console.WriteLine (" ");
|
"SparkleShare is a collaboration and sharing tool that is" + n +
|
||||||
Console.WriteLine ("Version: " + SparkleLib.SparkleBackend.Version);
|
"designed to keep things simple and to stay out of your way." + n +
|
||||||
Console.WriteLine ("Copyright (C) 2010 Hylke Bons");
|
n +
|
||||||
Console.WriteLine (" ");
|
"Version: " + SparkleLib.SparkleBackend.Version + n +
|
||||||
Console.WriteLine ("This program comes with ABSOLUTELY NO WARRANTY.");
|
"Copyright (C) 2010 Hylke Bons" + n +
|
||||||
Console.WriteLine (" ");
|
"This program comes with ABSOLUTELY NO WARRANTY." + n +
|
||||||
Console.WriteLine ("This is free software, and you are welcome to redistribute it ");
|
n +
|
||||||
Console.WriteLine ("under certain conditions. Please read the GNU GPLv3 for details.");
|
"This is free software, and you are welcome to redistribute it" + n +
|
||||||
Console.WriteLine (" ");
|
"under certain conditions. Please read the GNU GPLv3 for details." + n +
|
||||||
Console.WriteLine ("Usage: sparkleshare [start|stop|restart]");
|
n +
|
||||||
|
"Usage: sparkleshare [start|stop|restart]");
|
||||||
|
|
||||||
Environment.Exit (-1);
|
Environment.Exit (-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,12 +99,12 @@ namespace SparkleShare {
|
||||||
|
|
||||||
int running_major;
|
int running_major;
|
||||||
int running_minor;
|
int running_minor;
|
||||||
int running_build;
|
int running_micro;
|
||||||
try {
|
try {
|
||||||
string[] running_split = running_version_string.Split ('.');
|
string [] running_split = running_version_string.Split ('.');
|
||||||
running_major = int.Parse (running_split [0]);
|
running_major = int.Parse (running_split [0]);
|
||||||
running_minor = int.Parse (running_split [1]);
|
running_minor = int.Parse (running_split [1]);
|
||||||
running_build = int.Parse (running_split [2]);
|
running_micro = int.Parse (running_split [2]);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new FormatException ("running_version_string", e);
|
throw new FormatException ("running_version_string", e);
|
||||||
|
@ -112,12 +112,12 @@ namespace SparkleShare {
|
||||||
|
|
||||||
int latest_major;
|
int latest_major;
|
||||||
int latest_minor;
|
int latest_minor;
|
||||||
int latest_build;
|
int latest_micro;
|
||||||
try {
|
try {
|
||||||
string[] latest_split = latest_version_string.Split ('.');
|
string [] latest_split = latest_version_string.Split ('.');
|
||||||
latest_major = int.Parse (latest_split [0]);
|
latest_major = int.Parse (latest_split [0]);
|
||||||
latest_minor = int.Parse (latest_split [1]);
|
latest_minor = int.Parse (latest_split [1]);
|
||||||
latest_build = int.Parse (latest_split [2]);
|
latest_micro = int.Parse (latest_split [2]);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new FormatException ("latest_version_string", e);
|
throw new FormatException ("latest_version_string", e);
|
||||||
|
@ -125,9 +125,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
bool higher_major = latest_major > running_major;
|
bool higher_major = latest_major > running_major;
|
||||||
bool higher_minor = latest_major == running_major && latest_minor > running_minor;
|
bool higher_minor = latest_major == running_major && latest_minor > running_minor;
|
||||||
bool higher_build = latest_major == running_major && latest_minor == running_minor && latest_build > running_build;
|
bool higher_micro = latest_major == running_major && latest_minor == running_minor && latest_micro > running_micro;
|
||||||
|
|
||||||
return higher_major || higher_minor || higher_build;
|
return (higher_major || higher_minor || higher_micro);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,8 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.Controller.NotificationRaised += delegate (SparkleChangeSet change_set) {
|
Program.Controller.NotificationRaised += delegate (SparkleChangeSet change_set) {
|
||||||
if (Program.Controller.NotificationsEnabled)
|
ShowBubble (change_set.User.Name, FormatMessage (change_set),
|
||||||
ShowBubble (change_set.User.Name, FormatMessage (change_set),
|
Program.Controller.GetAvatar (change_set.User.Email, 48));
|
||||||
Program.Controller.GetAvatar (change_set.User.Email, 48));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,29 +54,23 @@ namespace SparkleShare {
|
||||||
|
|
||||||
private string FormatMessage (SparkleChangeSet change_set)
|
private string FormatMessage (SparkleChangeSet change_set)
|
||||||
{
|
{
|
||||||
string message = "";
|
string message = "added ‘{0}’";
|
||||||
|
|
||||||
if (change_set.Changes [0].Type == SparkleChangeType.Deleted)
|
switch (change_set.Changes [0].Type) {
|
||||||
message = string.Format ("moved ‘{0}’", change_set.Changes [0].Path);
|
case SparkleChangeType.Edited: message = "edited ‘{0}’"; break;
|
||||||
|
case SparkleChangeType.Deleted: message = "deleted ‘{0}’"; break;
|
||||||
if (change_set.Changes [0].Type == SparkleChangeType.Moved)
|
case SparkleChangeType.Moved: message = "moved ‘{0}’"; break;
|
||||||
message = string.Format ("moved ‘{0}’", change_set.Changes [0].Path);
|
|
||||||
|
|
||||||
if (change_set.Changes [0].Type == SparkleChangeType.Added)
|
|
||||||
message = string.Format ("added ‘{0}’", change_set.Changes [0].Path);
|
|
||||||
|
|
||||||
if (change_set.Changes [0].Type == SparkleChangeType.Edited)
|
|
||||||
message = string.Format ("moved ‘{0}’", change_set.Changes [0].Path);
|
|
||||||
|
|
||||||
if (change_set.Changes.Count > 0) {
|
|
||||||
string msg = string.Format ("and {0} more", change_set.Changes.Count);
|
|
||||||
message = message + " " + string.Format (msg, change_set.Changes.Count);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
message = "did something magical";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
if (change_set.Changes.Count == 1) {
|
||||||
|
return message = string.Format (message, change_set.Changes [0].Path);
|
||||||
|
|
||||||
|
} else if (change_set.Changes.Count > 1) {
|
||||||
|
return string.Format (message + " and {0} more", change_set.Changes.Count - 1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return "did something magical";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,6 @@ namespace SparkleShare {
|
||||||
// key in the user's SparkleShare folder
|
// key in the user's SparkleShare folder
|
||||||
if (File.Exists (pubkey_file_path) && !File.Exists (link_code_file_path))
|
if (File.Exists (pubkey_file_path) && !File.Exists (link_code_file_path))
|
||||||
File.Copy (pubkey_file_path, link_code_file_path, true /* Overwriting allowed */ );
|
File.Copy (pubkey_file_path, link_code_file_path, true /* Overwriting allowed */ );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SparkleKeys.ListPrivateKeys ();
|
SparkleKeys.ListPrivateKeys ();
|
||||||
|
@ -241,20 +240,19 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void UIHasLoaded ()
|
public void UIHasLoaded ()
|
||||||
{
|
{
|
||||||
if (FirstRun)
|
if (FirstRun) {
|
||||||
ShowSetupWindow (PageType.Setup);
|
ShowSetupWindow (PageType.Setup);
|
||||||
else
|
|
||||||
new Thread (() => PopulateRepositories ()).Start ();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new Thread (() => {
|
||||||
|
CheckRepositories ();
|
||||||
|
RepositoriesLoaded = true;
|
||||||
|
|
||||||
private void PopulateRepositories ()
|
if (FolderListChanged != null)
|
||||||
{
|
FolderListChanged ();
|
||||||
CheckRepositories ();
|
|
||||||
RepositoriesLoaded = true;
|
|
||||||
|
|
||||||
if (FolderListChanged != null)
|
}).Start ();
|
||||||
FolderListChanged ();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,7 +302,7 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
repo.NewChangeSet += delegate (SparkleChangeSet change_set) {
|
repo.NewChangeSet += delegate (SparkleChangeSet change_set) {
|
||||||
if (NotificationRaised != null)
|
if (NotificationsEnabled && NotificationRaised != null)
|
||||||
NotificationRaised (change_set);
|
NotificationRaised (change_set);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -406,17 +404,14 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_syncing_repos) {
|
if (has_syncing_repos && OnSyncing != null) {
|
||||||
if (OnSyncing != null)
|
OnSyncing ();
|
||||||
OnSyncing ();
|
|
||||||
|
|
||||||
} else if (has_unsynced_repos) {
|
} else if (has_unsynced_repos && OnError != null) {
|
||||||
if (OnError != null)
|
OnError ();
|
||||||
OnError ();
|
|
||||||
|
|
||||||
} else {
|
} else if (OnIdle != null) {
|
||||||
if (OnIdle != null)
|
OnIdle ();
|
||||||
OnIdle ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,6 +436,7 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void HandleInvite (FileSystemEventArgs args)
|
public void HandleInvite (FileSystemEventArgs args)
|
||||||
{
|
{
|
||||||
if (this.fetcher != null &&
|
if (this.fetcher != null &&
|
||||||
|
@ -458,22 +454,21 @@ namespace SparkleShare {
|
||||||
// fully downloaded yet, so we try to read it several times
|
// fully downloaded yet, so we try to read it several times
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
while (!invite.IsValid) {
|
while (!invite.IsValid) {
|
||||||
Thread.Sleep (1 * 250);
|
Thread.Sleep (250);
|
||||||
invite = new SparkleInvite (args.FullPath);
|
invite = new SparkleInvite (args.FullPath);
|
||||||
tries++;
|
tries++;
|
||||||
if (tries > 20)
|
|
||||||
|
if (tries > 20) {
|
||||||
|
if (AlertNotificationRaised != null)
|
||||||
|
AlertNotificationRaised ("Oh noes!", "This invite seems screwed up...");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invite.IsValid) {
|
if (invite.IsValid)
|
||||||
InviteReceived (invite);
|
InviteReceived (invite);
|
||||||
|
|
||||||
} else {
|
|
||||||
if (AlertNotificationRaised != null)
|
|
||||||
AlertNotificationRaised ("Oh noes!",
|
|
||||||
"This invite seems screwed up...");
|
|
||||||
}
|
|
||||||
|
|
||||||
File.Delete (args.FullPath);
|
File.Delete (args.FullPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -681,11 +676,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void ToggleNotifications () {
|
public void ToggleNotifications () {
|
||||||
bool notifications_enabled = this.config.GetConfigOption ("notifications").Equals (bool.TrueString);
|
bool notifications_enabled = this.config.GetConfigOption ("notifications").Equals (bool.TrueString);
|
||||||
|
this.config.SetConfigOption ("notifications", (!notifications_enabled).ToString ());
|
||||||
if (notifications_enabled)
|
|
||||||
this.config.SetConfigOption ("notifications", bool.FalseString);
|
|
||||||
else
|
|
||||||
this.config.SetConfigOption ("notifications", bool.TrueString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -111,9 +111,10 @@ namespace SparkleShare {
|
||||||
double size = 0;
|
double size = 0;
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
||||||
if (this.selected_folder == null)
|
if (this.selected_folder == null) {
|
||||||
size += repo.Size;
|
size += repo.Size;
|
||||||
else if (this.selected_folder.Equals (repo.Name)) {
|
|
||||||
|
} else if (this.selected_folder.Equals (repo.Name)) {
|
||||||
if (repo.Size == 0)
|
if (repo.Size == 0)
|
||||||
return "???";
|
return "???";
|
||||||
else
|
else
|
||||||
|
@ -133,9 +134,10 @@ namespace SparkleShare {
|
||||||
double size = 0;
|
double size = 0;
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
|
||||||
if (this.selected_folder == null)
|
if (this.selected_folder == null) {
|
||||||
size += repo.HistorySize;
|
size += repo.HistorySize;
|
||||||
else if (this.selected_folder.Equals (repo.Name)) {
|
|
||||||
|
} else if (this.selected_folder.Equals (repo.Name)) {
|
||||||
if (repo.HistorySize == 0)
|
if (repo.HistorySize == 0)
|
||||||
return "???";
|
return "???";
|
||||||
else
|
else
|
||||||
|
@ -178,11 +180,8 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.Controller.FolderListChanged += delegate {
|
Program.Controller.FolderListChanged += delegate {
|
||||||
if (this.selected_folder != null &&
|
if (this.selected_folder != null && !Program.Controller.Folders.Contains (this.selected_folder))
|
||||||
!Program.Controller.Folders.Contains (this.selected_folder)) {
|
|
||||||
|
|
||||||
this.selected_folder = null;
|
this.selected_folder = null;
|
||||||
}
|
|
||||||
|
|
||||||
if (UpdateChooserEvent != null)
|
if (UpdateChooserEvent != null)
|
||||||
UpdateChooserEvent (Folders);
|
UpdateChooserEvent (Folders);
|
||||||
|
@ -325,8 +324,10 @@ namespace SparkleShare {
|
||||||
string timestamp = change_set.Timestamp.ToString ("H:mm");
|
string timestamp = change_set.Timestamp.ToString ("H:mm");
|
||||||
|
|
||||||
if (!change_set.FirstTimestamp.Equals (new DateTime ()) &&
|
if (!change_set.FirstTimestamp.Equals (new DateTime ()) &&
|
||||||
!change_set.Timestamp.ToString ("H:mm").Equals (change_set.FirstTimestamp.ToString ("H:mm")))
|
!change_set.Timestamp.ToString ("H:mm").Equals (change_set.FirstTimestamp.ToString ("H:mm"))) {
|
||||||
|
|
||||||
timestamp = change_set.FirstTimestamp.ToString ("H:mm") + " – " + timestamp;
|
timestamp = change_set.FirstTimestamp.ToString ("H:mm") + " – " + timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
|
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
|
||||||
.Replace ("<!-- $event-user-name -->", change_set.User.Name)
|
.Replace ("<!-- $event-user-name -->", change_set.User.Name)
|
||||||
|
@ -345,16 +346,18 @@ namespace SparkleShare {
|
||||||
today.Year == activity_day.Date.Year) {
|
today.Year == activity_day.Date.Year) {
|
||||||
|
|
||||||
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
||||||
"<span id='today' name='" + activity_day.Date.ToString ("dddd, MMMM d") + "'>"
|
"<span id='today' name='" +
|
||||||
+ "Today" + "</span>");
|
activity_day.Date.ToString ("dddd, MMMM d") + "'>" + "Today" +
|
||||||
|
"</span>");
|
||||||
|
|
||||||
} else if (yesterday.Day == activity_day.Date.Day &&
|
} else if (yesterday.Day == activity_day.Date.Day &&
|
||||||
yesterday.Month == activity_day.Date.Month &&
|
yesterday.Month == activity_day.Date.Month &&
|
||||||
yesterday.Year == activity_day.Date.Year) {
|
yesterday.Year == activity_day.Date.Year) {
|
||||||
|
|
||||||
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
||||||
"<span id='yesterday' name='" + activity_day.Date.ToString ("dddd, MMMM d") + "'>"
|
"<span id='yesterday' name='" + activity_day.Date.ToString ("dddd, MMMM d") + "'>" +
|
||||||
+ "Yesterday" + "</span>");
|
"Yesterday" +
|
||||||
|
"</span>");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (activity_day.Date.Year != DateTime.Now.Year) {
|
if (activity_day.Date.Year != DateTime.Now.Year) {
|
||||||
|
@ -372,8 +375,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
int midnight = (int) (DateTime.Today.AddDays (1) - new DateTime (1970, 1, 1)).TotalSeconds;
|
int midnight = (int) (DateTime.Today.AddDays (1) - new DateTime (1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log)
|
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log);
|
||||||
.Replace ("<!-- $midnight -->", midnight.ToString ());
|
html = html.Replace ("<!-- $midnight -->", midnight.ToString ());
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public static class Extensions {
|
public static class Extensions {
|
||||||
|
|
||||||
public static string Combine (this String [] parts)
|
public static string Combine (this string [] parts)
|
||||||
{
|
{
|
||||||
string new_path = "";
|
string new_path = "";
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public bool IsValid {
|
public bool IsValid {
|
||||||
get {
|
get {
|
||||||
return (!string.IsNullOrEmpty (Address) &&
|
return (!string.IsNullOrEmpty (Address) && !string.IsNullOrEmpty (RemotePath));
|
||||||
!string.IsNullOrEmpty (RemotePath));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +100,6 @@ namespace SparkleShare {
|
||||||
WebResponse response = request.GetResponse ();
|
WebResponse response = request.GetResponse ();
|
||||||
response.Close ();
|
response.Close ();
|
||||||
|
|
||||||
|
|
||||||
if ((response as HttpWebResponse).StatusCode == HttpStatusCode.OK) {
|
if ((response as HttpWebResponse).StatusCode == HttpStatusCode.OK) {
|
||||||
SparkleHelpers.DebugInfo ("Invite", "Uploaded public key to " + AcceptUrl);
|
SparkleHelpers.DebugInfo ("Invite", "Uploaded public key to " + AcceptUrl);
|
||||||
return true;
|
return true;
|
||||||
|
@ -113,7 +111,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
} catch (WebException e) {
|
} catch (WebException e) {
|
||||||
SparkleHelpers.DebugInfo ("Invite", "Failed uploading public key to " + AcceptUrl + ": " + e.Message);
|
SparkleHelpers.DebugInfo ("Invite", "Failed uploading public key to " + AcceptUrl + ": " + e.Message);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SelectedPlugin = Plugins [0];
|
SelectedPlugin = Plugins [0];
|
||||||
|
|
||||||
|
|
||||||
Program.Controller.InviteReceived += delegate (SparkleInvite invite) {
|
Program.Controller.InviteReceived += delegate (SparkleInvite invite) {
|
||||||
PendingInvite = invite;
|
PendingInvite = invite;
|
||||||
|
|
||||||
|
@ -175,7 +174,6 @@ namespace SparkleShare {
|
||||||
ShowWindowEvent ();
|
ShowWindowEvent ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Program.Controller.ShowSetupWindowEvent += delegate (PageType page_type) {
|
Program.Controller.ShowSetupWindowEvent += delegate (PageType page_type) {
|
||||||
if (page_type == PageType.CryptoSetup || page_type == PageType.CryptoPassword) {
|
if (page_type == PageType.CryptoSetup || page_type == PageType.CryptoPassword) {
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
|
@ -263,8 +261,7 @@ namespace SparkleShare {
|
||||||
full_name = full_name.Trim ();
|
full_name = full_name.Trim ();
|
||||||
email = email.Trim ();
|
email = email.Trim ();
|
||||||
|
|
||||||
bool fields_valid = (!string.IsNullOrEmpty (full_name) &&
|
bool fields_valid = (!string.IsNullOrEmpty (full_name) && IsValidEmail (email));
|
||||||
IsValidEmail (email));
|
|
||||||
|
|
||||||
if (UpdateSetupContinueButtonEvent != null)
|
if (UpdateSetupContinueButtonEvent != null)
|
||||||
UpdateSetupContinueButtonEvent (fields_valid);
|
UpdateSetupContinueButtonEvent (fields_valid);
|
||||||
|
@ -544,13 +541,12 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
Program.Controller.StopFetcher ();
|
Program.Controller.StopFetcher ();
|
||||||
|
|
||||||
if (ChangePageEvent == null)
|
if (ChangePageEvent != null) {
|
||||||
return;
|
if (PendingInvite != null)
|
||||||
|
ChangePageEvent (PageType.Invite, null);
|
||||||
if (PendingInvite != null)
|
else
|
||||||
ChangePageEvent (PageType.Invite, null);
|
ChangePageEvent (PageType.Add, null);
|
||||||
else
|
}
|
||||||
ChangePageEvent (PageType.Add, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -610,9 +606,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void OpenFolderClicked ()
|
public void OpenFolderClicked ()
|
||||||
{
|
{
|
||||||
Program.Controller.OpenSparkleShareFolder (
|
Program.Controller.OpenSparkleShareFolder (Path.GetFileName (PreviousPath));
|
||||||
Path.GetFileName (PreviousPath));
|
|
||||||
|
|
||||||
FinishPageCompleted ();
|
FinishPageCompleted ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,17 +623,12 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (HideWindowEvent != null)
|
if (HideWindowEvent != null)
|
||||||
HideWindowEvent ();
|
HideWindowEvent ();
|
||||||
|
|
||||||
//Program.Controller.UpdateState (); TODO: still relevant?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool IsValidEmail (string email)
|
private bool IsValidEmail (string email)
|
||||||
{
|
{
|
||||||
Regex regex = new Regex (@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$",
|
return new Regex (@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", RegexOptions.IgnoreCase).IsMatch (email);
|
||||||
RegexOptions.IgnoreCase);
|
|
||||||
|
|
||||||
return regex.IsMatch (email);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,16 +55,16 @@ namespace SparkleShare {
|
||||||
public string StateText = "Welcome to SparkleShare!";
|
public string StateText = "Welcome to SparkleShare!";
|
||||||
|
|
||||||
|
|
||||||
public readonly int MenuOverFlowThreshold = 9;
|
public readonly int MenuOverflowThreshold = 9;
|
||||||
public readonly int MinSubmenuOverflowCount = 3;
|
public readonly int MinSubmenuOverflowCount = 3;
|
||||||
|
|
||||||
|
|
||||||
public string [] Folders {
|
public string [] Folders {
|
||||||
get {
|
get {
|
||||||
int overflow_count = (Program.Controller.Folders.Count - MenuOverFlowThreshold);
|
int overflow_count = (Program.Controller.Folders.Count - MenuOverflowThreshold);
|
||||||
|
|
||||||
if (overflow_count >= MinSubmenuOverflowCount)
|
if (overflow_count >= MinSubmenuOverflowCount)
|
||||||
return Program.Controller.Folders.GetRange (0, MenuOverFlowThreshold).ToArray ();
|
return Program.Controller.Folders.GetRange (0, MenuOverflowThreshold).ToArray ();
|
||||||
else
|
else
|
||||||
return Program.Controller.Folders.ToArray ();
|
return Program.Controller.Folders.ToArray ();
|
||||||
}
|
}
|
||||||
|
@ -72,16 +72,15 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public string [] OverflowFolders {
|
public string [] OverflowFolders {
|
||||||
get {
|
get {
|
||||||
int overflow_count = (Program.Controller.Folders.Count - MenuOverFlowThreshold);
|
int overflow_count = (Program.Controller.Folders.Count - MenuOverflowThreshold);
|
||||||
|
|
||||||
if (overflow_count >= MinSubmenuOverflowCount)
|
if (overflow_count >= MinSubmenuOverflowCount)
|
||||||
return Program.Controller.Folders.GetRange (MenuOverFlowThreshold, overflow_count).ToArray ();
|
return Program.Controller.Folders.GetRange (MenuOverflowThreshold, overflow_count).ToArray ();
|
||||||
else
|
else
|
||||||
return new string [0];
|
return new string [0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string FolderSize {
|
public string FolderSize {
|
||||||
get {
|
get {
|
||||||
double size = 0;
|
double size = 0;
|
||||||
|
@ -110,21 +109,17 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public bool QuitItemEnabled {
|
public bool QuitItemEnabled {
|
||||||
get {
|
get {
|
||||||
return (CurrentState != IconState.Syncing &&
|
return (CurrentState == IconState.Idle || CurrentState == IconState.Error);
|
||||||
CurrentState != IconState.SyncingDown &&
|
|
||||||
CurrentState != IconState.SyncingUp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OpenRecentEventsItemEnabled {
|
public bool OpenRecentEventsItemEnabled {
|
||||||
get {
|
get {
|
||||||
return (Program.Controller.RepositoriesLoaded &&
|
return (Program.Controller.RepositoriesLoaded && Program.Controller.Folders.Count > 0);
|
||||||
Program.Controller.Folders.Count > 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Timer animation;
|
private Timer animation;
|
||||||
private int animation_frame_number;
|
private int animation_frame_number;
|
||||||
|
|
||||||
|
@ -254,10 +249,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void OpenRecentEventsClicked ()
|
public void OpenRecentEventsClicked ()
|
||||||
{
|
{
|
||||||
new Threading.Thread (() => {
|
new Threading.Thread (() => Program.Controller.ShowEventLogWindow ()).Start ();
|
||||||
Program.Controller.ShowEventLogWindow ();
|
|
||||||
|
|
||||||
}).Start ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue