Remove event handling boilerplate everywhere
This commit is contained in:
parent
e0949ae082
commit
78e96474b2
|
@ -29,15 +29,15 @@ namespace SparkleLib {
|
|||
// Sets up a fetcher that can get remote folders
|
||||
public abstract class SparkleFetcherBase {
|
||||
|
||||
public delegate void StartedEventHandler ();
|
||||
public event Action Started = delegate { };
|
||||
public event Action Failed = delegate { };
|
||||
|
||||
public event FinishedEventHandler Finished = delegate { };
|
||||
public delegate void FinishedEventHandler (bool repo_is_encrypted, bool repo_is_empty, string [] warnings);
|
||||
public delegate void FailedEventHandler ();
|
||||
|
||||
public event ProgressChangedEventHandler ProgressChanged = delegate { };
|
||||
public delegate void ProgressChangedEventHandler (double percentage);
|
||||
|
||||
public event StartedEventHandler Started;
|
||||
public event FinishedEventHandler Finished;
|
||||
public event FailedEventHandler Failed;
|
||||
public event ProgressChangedEventHandler ProgressChanged;
|
||||
|
||||
public abstract bool Fetch ();
|
||||
public abstract void Stop ();
|
||||
|
@ -117,9 +117,7 @@ namespace SparkleLib {
|
|||
public void Start ()
|
||||
{
|
||||
IsActive = true;
|
||||
|
||||
if (Started != null)
|
||||
Started ();
|
||||
Started ();
|
||||
|
||||
SparkleHelpers.DebugInfo ("Fetcher", TargetFolder + " | Fetching folder: " + RemoteUrl);
|
||||
|
||||
|
@ -130,9 +128,7 @@ namespace SparkleLib {
|
|||
string host_key = GetHostKey ();
|
||||
|
||||
if (string.IsNullOrEmpty (host) || host_key == null) {
|
||||
if (Failed != null)
|
||||
Failed ();
|
||||
|
||||
Failed ();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -144,9 +140,7 @@ namespace SparkleLib {
|
|||
!RequiredFingerprint.Equals (host_fingerprint)) {
|
||||
|
||||
SparkleHelpers.DebugInfo ("Auth", "Fingerprint doesn't match");
|
||||
|
||||
if (Failed != null)
|
||||
Failed ();
|
||||
Failed ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -170,18 +164,14 @@ namespace SparkleLib {
|
|||
|
||||
// TODO: Find better way to determine if folder should have crypto setup
|
||||
bool repo_is_encrypted = RemoteUrl.ToString ().Contains ("crypto");
|
||||
|
||||
if (Finished != null)
|
||||
Finished (repo_is_encrypted, IsFetchedRepoEmpty, Warnings);
|
||||
Finished (repo_is_encrypted, IsFetchedRepoEmpty, Warnings);
|
||||
|
||||
} else {
|
||||
Thread.Sleep (500);
|
||||
SparkleHelpers.DebugInfo ("Fetcher", "Failed");
|
||||
|
||||
IsActive = false;
|
||||
|
||||
if (Failed != null)
|
||||
Failed ();
|
||||
Failed ();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
@ -263,8 +253,7 @@ namespace SparkleLib {
|
|||
|
||||
|
||||
protected void OnProgressChanged (double percentage) {
|
||||
if (ProgressChanged != null)
|
||||
ProgressChanged (percentage);
|
||||
ProgressChanged (percentage);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,13 +25,10 @@ namespace SparkleLib {
|
|||
// listens for change notifications
|
||||
public abstract class SparkleListenerBase {
|
||||
|
||||
public event ConnectedEventHandler Connected;
|
||||
public delegate void ConnectedEventHandler ();
|
||||
public event Action Connected = delegate { };
|
||||
public event Action Disconnected = delegate { };
|
||||
|
||||
public event DisconnectedEventHandler Disconnected;
|
||||
public delegate void DisconnectedEventHandler ();
|
||||
|
||||
public event AnnouncementReceivedEventHandler AnnouncementReceived;
|
||||
public event AnnouncementReceivedEventHandler AnnouncementReceived = delegate { };
|
||||
public delegate void AnnouncementReceivedEventHandler (SparkleAnnouncement announcement);
|
||||
|
||||
public readonly Uri Server;
|
||||
|
@ -118,9 +115,7 @@ namespace SparkleLib {
|
|||
public void OnConnected ()
|
||||
{
|
||||
SparkleHelpers.DebugInfo ("Listener", "Listening for announcements on " + Server);
|
||||
|
||||
if (Connected != null)
|
||||
Connected ();
|
||||
Connected ();
|
||||
|
||||
if (this.queue_up.Count > 0) {
|
||||
SparkleHelpers.DebugInfo ("Listener", "Delivering " + this.queue_up.Count + " queued messages...");
|
||||
|
@ -138,9 +133,7 @@ namespace SparkleLib {
|
|||
public void OnDisconnected (string message)
|
||||
{
|
||||
SparkleHelpers.DebugInfo ("Listener", "Disconnected from " + Server + ": " + message);
|
||||
|
||||
if (Disconnected != null)
|
||||
Disconnected ();
|
||||
Disconnected ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,8 +156,7 @@ namespace SparkleLib {
|
|||
AddRecentAnnouncement (announcement);
|
||||
this.queue_down [announcement.FolderIdentifier] = announcement;
|
||||
|
||||
if (AnnouncementReceived != null)
|
||||
AnnouncementReceived (announcement);
|
||||
AnnouncementReceived (announcement);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,20 +48,18 @@ namespace SparkleLib {
|
|||
public abstract List<SparkleChangeSet> GetChangeSets (int count);
|
||||
|
||||
|
||||
public event SyncStatusChangedEventHandler SyncStatusChanged = delegate { };
|
||||
public delegate void SyncStatusChangedEventHandler (SyncStatus new_status);
|
||||
public event SyncStatusChangedEventHandler SyncStatusChanged;
|
||||
|
||||
public event ProgressChangedEventHandler ProgressChanged = delegate { };
|
||||
public delegate void ProgressChangedEventHandler (double percentage, string speed);
|
||||
public event ProgressChangedEventHandler ProgressChanged;
|
||||
|
||||
public event NewChangeSetEventHandler NewChangeSet = delegate { };
|
||||
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set);
|
||||
public event NewChangeSetEventHandler NewChangeSet;
|
||||
|
||||
public delegate void ConflictResolvedEventHandler ();
|
||||
public event ConflictResolvedEventHandler ConflictResolved;
|
||||
public event Action ConflictResolved = delegate { };
|
||||
public event Action ChangesDetected = delegate { };
|
||||
|
||||
public delegate void ChangesDetectedEventHandler ();
|
||||
public event ChangesDetectedEventHandler ChangesDetected;
|
||||
|
||||
public readonly string LocalPath;
|
||||
public readonly string Name;
|
||||
|
@ -200,9 +198,7 @@ namespace SparkleLib {
|
|||
if (IsBuffering)
|
||||
return;
|
||||
|
||||
if (ChangesDetected != null)
|
||||
ChangesDetected ();
|
||||
|
||||
ChangesDetected ();
|
||||
string relative_path = args.FullPath.Replace (LocalPath, "");
|
||||
|
||||
foreach (string exclude_path in ExcludePaths) {
|
||||
|
@ -242,8 +238,7 @@ namespace SparkleLib {
|
|||
} while (HasLocalChanges);
|
||||
|
||||
} else {
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -258,8 +253,7 @@ namespace SparkleLib {
|
|||
|
||||
protected void OnConflictResolved ()
|
||||
{
|
||||
if (ConflictResolved != null)
|
||||
ConflictResolved ();
|
||||
ConflictResolved ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -269,16 +263,14 @@ namespace SparkleLib {
|
|||
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;
|
||||
if (progress_percentage == 100.0)
|
||||
progress_percentage = 99.0;
|
||||
|
||||
ProgressPercentage = progress_percentage;
|
||||
ProgressSpeed = progress_speed;
|
||||
this.progress_last_change = DateTime.Now;
|
||||
ProgressPercentage = progress_percentage;
|
||||
ProgressSpeed = progress_speed;
|
||||
this.progress_last_change = DateTime.Now;
|
||||
|
||||
ProgressChanged (progress_percentage, progress_speed);
|
||||
}
|
||||
ProgressChanged (progress_percentage, progress_speed);
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,16 +280,13 @@ namespace SparkleLib {
|
|||
HasUnsyncedChanges = true;
|
||||
|
||||
this.remote_timer.Stop ();
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.SyncUp);
|
||||
SyncStatusChanged (SyncStatus.SyncUp);
|
||||
|
||||
if (SyncUp ()) {
|
||||
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done");
|
||||
HasUnsyncedChanges = false;
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
HasUnsyncedChanges = false;
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
|
||||
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
|
||||
|
||||
|
@ -307,17 +296,13 @@ namespace SparkleLib {
|
|||
|
||||
if (ServerOnline && SyncUp ()) {
|
||||
HasUnsyncedChanges = false;
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
|
||||
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
|
||||
|
||||
} else {
|
||||
ServerOnline = false;
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.Error);
|
||||
SyncStatusChanged (SyncStatus.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,9 +318,7 @@ namespace SparkleLib {
|
|||
SparkleHelpers.DebugInfo ("SyncDown", Name + " | Initiated");
|
||||
this.remote_timer.Stop ();
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.SyncDown);
|
||||
|
||||
SyncStatusChanged (SyncStatus.SyncDown);
|
||||
string pre_sync_revision = CurrentRevision;
|
||||
|
||||
if (SyncDown ()) {
|
||||
|
@ -347,11 +330,14 @@ namespace SparkleLib {
|
|||
ChangeSets.Count > 0) {
|
||||
|
||||
bool emit_change_event = true;
|
||||
foreach (SparkleChange change in ChangeSets [0].Changes)
|
||||
if (change.Path.EndsWith (".sparkleshare"))
|
||||
foreach (SparkleChange change in ChangeSets [0].Changes) {
|
||||
if (change.Path.EndsWith (".sparkleshare")) {
|
||||
emit_change_event = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NewChangeSet != null && emit_change_event)
|
||||
if (emit_change_event)
|
||||
NewChangeSet (ChangeSets [0]);
|
||||
}
|
||||
}
|
||||
|
@ -360,29 +346,25 @@ namespace SparkleLib {
|
|||
// conflict. Tries only once, then lets
|
||||
// the timer try again periodically
|
||||
if (HasUnsyncedChanges) {
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.SyncUp);
|
||||
SyncStatusChanged (SyncStatus.SyncUp);
|
||||
|
||||
SyncUp ();
|
||||
HasUnsyncedChanges = false;
|
||||
}
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
|
||||
} else {
|
||||
SparkleHelpers.DebugInfo ("SyncDown", Name + " | Error");
|
||||
ServerOnline = false;
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.Error);
|
||||
SyncStatusChanged (SyncStatus.Error);
|
||||
}
|
||||
|
||||
ProgressPercentage = 0.0;
|
||||
ProgressSpeed = "";
|
||||
|
||||
if (SyncStatusChanged != null)
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
SyncStatusChanged (SyncStatus.Idle);
|
||||
|
||||
this.remote_timer.Start ();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleBubblesController {
|
||||
|
||||
public event ShowBubbleEventHandler ShowBubbleEvent;
|
||||
public event ShowBubbleEventHandler ShowBubbleEvent = delegate { };
|
||||
public delegate void ShowBubbleEventHandler (string title, string subtext, string image_path);
|
||||
|
||||
|
||||
|
@ -41,8 +41,7 @@ namespace SparkleShare {
|
|||
|
||||
public void ShowBubble (string title, string subtext, string image_path)
|
||||
{
|
||||
if (ShowBubbleEvent != null)
|
||||
ShowBubbleEvent (title, subtext, image_path);
|
||||
ShowBubbleEvent (title, subtext, image_path);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,46 +45,36 @@ namespace SparkleShare {
|
|||
public string ProgressSpeed = "";
|
||||
|
||||
|
||||
public event ShowSetupWindowEventHandler ShowSetupWindowEvent;
|
||||
public event ShowSetupWindowEventHandler ShowSetupWindowEvent = delegate { };
|
||||
public delegate void ShowSetupWindowEventHandler (PageType page_type);
|
||||
|
||||
public event ShowAboutWindowEventHandler ShowAboutWindowEvent;
|
||||
public delegate void ShowAboutWindowEventHandler ();
|
||||
public event Action ShowAboutWindowEvent = delegate { };
|
||||
public event Action ShowEventLogWindowEvent = delegate { };
|
||||
|
||||
public event ShowEventLogWindowEventHandler ShowEventLogWindowEvent;
|
||||
public delegate void ShowEventLogWindowEventHandler ();
|
||||
|
||||
|
||||
public event FolderFetchedEventHandler FolderFetched;
|
||||
public event FolderFetchedEventHandler FolderFetched = delegate { };
|
||||
public delegate void FolderFetchedEventHandler (string remote_url, string [] warnings);
|
||||
|
||||
public event FolderFetchErrorHandler FolderFetchError;
|
||||
public event FolderFetchErrorHandler FolderFetchError = delegate { };
|
||||
public delegate void FolderFetchErrorHandler (string remote_url, string [] errors);
|
||||
|
||||
public event FolderFetchingHandler FolderFetching;
|
||||
public event FolderFetchingHandler FolderFetching = delegate { };
|
||||
public delegate void FolderFetchingHandler (double percentage);
|
||||
|
||||
public event FolderListChangedHandler FolderListChanged;
|
||||
public delegate void FolderListChangedHandler ();
|
||||
public event Action FolderListChanged = delegate { };
|
||||
|
||||
|
||||
public event OnIdleHandler OnIdle;
|
||||
public delegate void OnIdleHandler ();
|
||||
|
||||
public event OnSyncingHandler OnSyncing;
|
||||
public delegate void OnSyncingHandler ();
|
||||
|
||||
public event OnErrorHandler OnError;
|
||||
public delegate void OnErrorHandler ();
|
||||
public event Action OnIdle = delegate { };
|
||||
public event Action OnSyncing = delegate { };
|
||||
public event Action OnError = delegate { };
|
||||
|
||||
|
||||
public event InviteReceivedHandler InviteReceived;
|
||||
public event InviteReceivedHandler InviteReceived = delegate { };
|
||||
public delegate void InviteReceivedHandler (SparkleInvite invite);
|
||||
|
||||
public event NotificationRaisedEventHandler NotificationRaised;
|
||||
public event NotificationRaisedEventHandler NotificationRaised = delegate { };
|
||||
public delegate void NotificationRaisedEventHandler (SparkleChangeSet change_set);
|
||||
|
||||
public event AlertNotificationRaisedEventHandler AlertNotificationRaised;
|
||||
public event AlertNotificationRaisedEventHandler AlertNotificationRaised = delegate { };
|
||||
public delegate void AlertNotificationRaisedEventHandler (string title, string message);
|
||||
|
||||
|
||||
|
@ -247,9 +237,7 @@ namespace SparkleShare {
|
|||
new Thread (() => {
|
||||
CheckRepositories ();
|
||||
RepositoriesLoaded = true;
|
||||
|
||||
if (FolderListChanged != null)
|
||||
FolderListChanged ();
|
||||
FolderListChanged ();
|
||||
|
||||
}).Start ();
|
||||
}
|
||||
|
@ -302,14 +290,13 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
repo.NewChangeSet += delegate (SparkleChangeSet change_set) {
|
||||
if (NotificationsEnabled && NotificationRaised != null)
|
||||
if (NotificationsEnabled)
|
||||
NotificationRaised (change_set);
|
||||
};
|
||||
|
||||
repo.ConflictResolved += delegate {
|
||||
if (AlertNotificationRaised != null)
|
||||
AlertNotificationRaised ("Conflict detected",
|
||||
"Don't worry, SparkleShare made a copy of each conflicting file.");
|
||||
AlertNotificationRaised ("Conflict detected",
|
||||
"Don't worry, SparkleShare made a copy of each conflicting file.");
|
||||
};
|
||||
|
||||
this.repositories.Add (repo);
|
||||
|
@ -380,8 +367,7 @@ namespace SparkleShare {
|
|||
}
|
||||
}
|
||||
|
||||
if (FolderListChanged != null)
|
||||
FolderListChanged ();
|
||||
FolderListChanged ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,13 +390,13 @@ namespace SparkleShare {
|
|||
}
|
||||
}
|
||||
|
||||
if (has_syncing_repos && OnSyncing != null) {
|
||||
if (has_syncing_repos) {
|
||||
OnSyncing ();
|
||||
|
||||
} else if (has_unsynced_repos && OnError != null) {
|
||||
} else if (has_unsynced_repos) {
|
||||
OnError ();
|
||||
|
||||
} else if (OnIdle != null) {
|
||||
} else {
|
||||
OnIdle ();
|
||||
}
|
||||
}
|
||||
|
@ -442,35 +428,29 @@ namespace SparkleShare {
|
|||
if (this.fetcher != null &&
|
||||
this.fetcher.IsActive) {
|
||||
|
||||
if (AlertNotificationRaised != null)
|
||||
AlertNotificationRaised ("SparkleShare Setup seems busy",
|
||||
"Please wait for it to finish");
|
||||
AlertNotificationRaised ("SparkleShare Setup seems busy", "Please wait for it to finish");
|
||||
|
||||
} else {
|
||||
if (InviteReceived != null) {
|
||||
SparkleInvite invite = new SparkleInvite (args.FullPath);
|
||||
SparkleInvite invite = new SparkleInvite (args.FullPath);
|
||||
|
||||
// It may be that the invite we received a path to isn't
|
||||
// fully downloaded yet, so we try to read it several times
|
||||
int tries = 0;
|
||||
while (!invite.IsValid) {
|
||||
Thread.Sleep (250);
|
||||
invite = new SparkleInvite (args.FullPath);
|
||||
tries++;
|
||||
// It may be that the invite we received a path to isn't
|
||||
// fully downloaded yet, so we try to read it several times
|
||||
int tries = 0;
|
||||
while (!invite.IsValid) {
|
||||
Thread.Sleep (250);
|
||||
invite = new SparkleInvite (args.FullPath);
|
||||
tries++;
|
||||
|
||||
if (tries > 20) {
|
||||
if (AlertNotificationRaised != null)
|
||||
AlertNotificationRaised ("Oh noes!", "This invite seems screwed up...");
|
||||
|
||||
break;
|
||||
}
|
||||
if (tries > 20) {
|
||||
AlertNotificationRaised ("Oh noes!", "This invite seems screwed up...");
|
||||
break;
|
||||
}
|
||||
|
||||
if (invite.IsValid)
|
||||
InviteReceived (invite);
|
||||
|
||||
File.Delete (args.FullPath);
|
||||
}
|
||||
|
||||
if (invite.IsValid)
|
||||
InviteReceived (invite);
|
||||
|
||||
File.Delete (args.FullPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,8 +465,7 @@ namespace SparkleShare {
|
|||
|
||||
if (!Directory.Exists (tmp_path)) {
|
||||
Directory.CreateDirectory (tmp_path);
|
||||
File.SetAttributes (tmp_path,
|
||||
File.GetAttributes (tmp_path) | FileAttributes.Hidden);
|
||||
File.SetAttributes (tmp_path, File.GetAttributes (tmp_path) | FileAttributes.Hidden);
|
||||
}
|
||||
|
||||
string canonical_name = Path.GetFileNameWithoutExtension (remote_path);
|
||||
|
@ -507,10 +486,8 @@ namespace SparkleShare {
|
|||
SparkleHelpers.DebugInfo ("Controller",
|
||||
"Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message);
|
||||
|
||||
if (FolderFetchError != null)
|
||||
FolderFetchError (
|
||||
Path.Combine (address, remote_path).Replace (@"\", "/"),
|
||||
new string [] {"Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\""});
|
||||
FolderFetchError (Path.Combine (address, remote_path).Replace (@"\", "/"),
|
||||
new string [] {"Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\""});
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -518,12 +495,10 @@ namespace SparkleShare {
|
|||
|
||||
this.fetcher.Finished += delegate (bool repo_is_encrypted, bool repo_is_empty, string [] warnings) {
|
||||
if (repo_is_encrypted && repo_is_empty) {
|
||||
if (ShowSetupWindowEvent != null)
|
||||
ShowSetupWindowEvent (PageType.CryptoSetup);
|
||||
ShowSetupWindowEvent (PageType.CryptoSetup);
|
||||
|
||||
} else if (repo_is_encrypted) {
|
||||
if (ShowSetupWindowEvent != null)
|
||||
ShowSetupWindowEvent (PageType.CryptoPassword);
|
||||
ShowSetupWindowEvent (PageType.CryptoPassword);
|
||||
|
||||
} else {
|
||||
FinishFetcher ();
|
||||
|
@ -531,15 +506,12 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
this.fetcher.Failed += delegate {
|
||||
if (FolderFetchError != null)
|
||||
FolderFetchError (this.fetcher.RemoteUrl.ToString (), this.fetcher.Errors);
|
||||
|
||||
FolderFetchError (this.fetcher.RemoteUrl.ToString (), this.fetcher.Errors);
|
||||
StopFetcher ();
|
||||
};
|
||||
|
||||
this.fetcher.ProgressChanged += delegate (double percentage) {
|
||||
if (FolderFetching != null)
|
||||
FolderFetching (percentage);
|
||||
FolderFetching (percentage);
|
||||
};
|
||||
|
||||
this.fetcher.Start ();
|
||||
|
@ -553,8 +525,7 @@ namespace SparkleShare {
|
|||
if (Directory.Exists (this.fetcher.TargetFolder)) {
|
||||
try {
|
||||
Directory.Delete (this.fetcher.TargetFolder, true);
|
||||
SparkleHelpers.DebugInfo ("Controller",
|
||||
"Deleted " + this.fetcher.TargetFolder);
|
||||
SparkleHelpers.DebugInfo ("Controller", "Deleted " + this.fetcher.TargetFolder);
|
||||
|
||||
} catch (Exception e) {
|
||||
SparkleHelpers.DebugInfo ("Controller",
|
||||
|
@ -616,8 +587,7 @@ namespace SparkleShare {
|
|||
this.config.AddFolder (target_folder_name, this.fetcher.Identifier,
|
||||
this.fetcher.RemoteUrl.ToString (), backend);
|
||||
|
||||
if (FolderFetched != null)
|
||||
FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ());
|
||||
FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ());
|
||||
|
||||
/* TODO
|
||||
if (!string.IsNullOrEmpty (announcements_url)) {
|
||||
|
@ -626,9 +596,7 @@ namespace SparkleShare {
|
|||
*/
|
||||
|
||||
AddRepository (target_folder_path);
|
||||
|
||||
if (FolderListChanged != null)
|
||||
FolderListChanged ();
|
||||
FolderListChanged ();
|
||||
|
||||
this.fetcher.Dispose ();
|
||||
this.fetcher = null;
|
||||
|
@ -643,22 +611,19 @@ namespace SparkleShare {
|
|||
|
||||
public void ShowSetupWindow (PageType page_type)
|
||||
{
|
||||
if (ShowSetupWindowEvent != null)
|
||||
ShowSetupWindowEvent (page_type);
|
||||
ShowSetupWindowEvent (page_type);
|
||||
}
|
||||
|
||||
|
||||
public void ShowAboutWindow ()
|
||||
{
|
||||
if (ShowAboutWindowEvent != null)
|
||||
ShowAboutWindowEvent ();
|
||||
ShowAboutWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
public void ShowEventLogWindow ()
|
||||
{
|
||||
if (ShowEventLogWindowEvent != null)
|
||||
ShowEventLogWindowEvent ();
|
||||
ShowEventLogWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,23 +28,19 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleEventLogController {
|
||||
|
||||
public event ShowWindowEventHandler ShowWindowEvent;
|
||||
public delegate void ShowWindowEventHandler ();
|
||||
public event Action ShowWindowEvent = delegate { };
|
||||
public event Action HideWindowEvent = delegate { };
|
||||
public event Action ContentLoadingEvent = delegate { };
|
||||
|
||||
public event HideWindowEventHandler HideWindowEvent;
|
||||
public delegate void HideWindowEventHandler ();
|
||||
|
||||
public event UpdateContentEventEventHandler UpdateContentEvent;
|
||||
public event UpdateContentEventEventHandler UpdateContentEvent = delegate { };
|
||||
public delegate void UpdateContentEventEventHandler (string html);
|
||||
|
||||
public event UpdateChooserEventHandler UpdateChooserEvent;
|
||||
public event UpdateChooserEventHandler UpdateChooserEvent = delegate { };
|
||||
public delegate void UpdateChooserEventHandler (string [] folders);
|
||||
|
||||
public event UpdateSizeInfoEventHandler UpdateSizeInfoEvent;
|
||||
public event UpdateSizeInfoEventHandler UpdateSizeInfoEvent = delegate { };
|
||||
public delegate void UpdateSizeInfoEventHandler (string size, string history_size);
|
||||
|
||||
public event ContentLoadingEventHandler ContentLoadingEvent;
|
||||
public delegate void ContentLoadingEventHandler ();
|
||||
|
||||
private string selected_folder;
|
||||
|
||||
|
@ -57,11 +53,8 @@ namespace SparkleShare {
|
|||
set {
|
||||
this.selected_folder = value;
|
||||
|
||||
if (ContentLoadingEvent != null)
|
||||
ContentLoadingEvent ();
|
||||
|
||||
if (UpdateSizeInfoEvent != null)
|
||||
UpdateSizeInfoEvent ("…", "…");
|
||||
ContentLoadingEvent ();
|
||||
UpdateSizeInfoEvent ("…", "…");
|
||||
|
||||
Stopwatch watch = new Stopwatch ();
|
||||
watch.Start ();
|
||||
|
@ -77,11 +70,8 @@ namespace SparkleShare {
|
|||
if (watch.ElapsedMilliseconds < delay)
|
||||
Thread.Sleep (delay - (int) watch.ElapsedMilliseconds);
|
||||
|
||||
if (UpdateContentEvent != null)
|
||||
UpdateContentEvent (html);
|
||||
|
||||
if (UpdateSizeInfoEvent != null)
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
UpdateContentEvent (html);
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
|
||||
}).Start ();
|
||||
}
|
||||
|
@ -92,9 +82,7 @@ namespace SparkleShare {
|
|||
List<SparkleChangeSet> change_sets = GetLog (this.selected_folder);
|
||||
|
||||
string html = GetHTMLLog (change_sets);
|
||||
|
||||
if (UpdateSizeInfoEvent != null)
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
|
||||
return html;
|
||||
}
|
||||
|
@ -158,45 +146,33 @@ namespace SparkleShare {
|
|||
Program.Controller.ShowEventLogWindowEvent += delegate {
|
||||
if (this.selected_folder == null) {
|
||||
new Thread (() => {
|
||||
if (UpdateChooserEvent != null)
|
||||
UpdateChooserEvent (Folders);
|
||||
|
||||
if (UpdateContentEvent != null)
|
||||
UpdateContentEvent (HTML);
|
||||
UpdateChooserEvent (Folders);
|
||||
UpdateContentEvent (HTML);
|
||||
|
||||
}).Start ();
|
||||
}
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
ShowWindowEvent ();
|
||||
};
|
||||
|
||||
Program.Controller.OnIdle += delegate {
|
||||
if (UpdateContentEvent != null)
|
||||
UpdateContentEvent (HTML);
|
||||
|
||||
if (UpdateSizeInfoEvent != null)
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
UpdateContentEvent (HTML);
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
};
|
||||
|
||||
Program.Controller.FolderListChanged += delegate {
|
||||
if (this.selected_folder != null && !Program.Controller.Folders.Contains (this.selected_folder))
|
||||
this.selected_folder = null;
|
||||
|
||||
if (UpdateChooserEvent != null)
|
||||
UpdateChooserEvent (Folders);
|
||||
|
||||
if (UpdateSizeInfoEvent != null)
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
UpdateChooserEvent (Folders);
|
||||
UpdateSizeInfoEvent (Size, HistorySize);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void WindowClosed ()
|
||||
{
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
|
||||
HideWindowEvent ();
|
||||
this.selected_folder = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,34 +46,31 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleSetupController {
|
||||
|
||||
public event ShowWindowEventHandler ShowWindowEvent;
|
||||
public delegate void ShowWindowEventHandler ();
|
||||
public event Action ShowWindowEvent = delegate { };
|
||||
public event Action HideWindowEvent = delegate { };
|
||||
|
||||
public event HideWindowEventHandler HideWindowEvent;
|
||||
public delegate void HideWindowEventHandler ();
|
||||
|
||||
public event ChangePageEventHandler ChangePageEvent;
|
||||
public event ChangePageEventHandler ChangePageEvent = delegate { };
|
||||
public delegate void ChangePageEventHandler (PageType page, string [] warnings);
|
||||
|
||||
public event UpdateProgressBarEventHandler UpdateProgressBarEvent;
|
||||
public event UpdateProgressBarEventHandler UpdateProgressBarEvent = delegate { };
|
||||
public delegate void UpdateProgressBarEventHandler (double percentage);
|
||||
|
||||
public event UpdateSetupContinueButtonEventHandler UpdateSetupContinueButtonEvent;
|
||||
public event UpdateSetupContinueButtonEventHandler UpdateSetupContinueButtonEvent = delegate { };
|
||||
public delegate void UpdateSetupContinueButtonEventHandler (bool button_enabled);
|
||||
|
||||
public event UpdateCryptoSetupContinueButtonEventHandler UpdateCryptoSetupContinueButtonEvent;
|
||||
public event UpdateCryptoSetupContinueButtonEventHandler UpdateCryptoSetupContinueButtonEvent = delegate { };
|
||||
public delegate void UpdateCryptoSetupContinueButtonEventHandler (bool button_enabled);
|
||||
|
||||
public event UpdateCryptoPasswordContinueButtonEventHandler UpdateCryptoPasswordContinueButtonEvent;
|
||||
public event UpdateCryptoPasswordContinueButtonEventHandler UpdateCryptoPasswordContinueButtonEvent = delegate { };
|
||||
public delegate void UpdateCryptoPasswordContinueButtonEventHandler (bool button_enabled);
|
||||
|
||||
public event UpdateAddProjectButtonEventHandler UpdateAddProjectButtonEvent;
|
||||
public event UpdateAddProjectButtonEventHandler UpdateAddProjectButtonEvent = delegate { };
|
||||
public delegate void UpdateAddProjectButtonEventHandler (bool button_enabled);
|
||||
|
||||
public event ChangeAddressFieldEventHandler ChangeAddressFieldEvent;
|
||||
public event ChangeAddressFieldEventHandler ChangeAddressFieldEvent = delegate { };
|
||||
public delegate void ChangeAddressFieldEventHandler (string text, string example_text, FieldState state);
|
||||
|
||||
public event ChangePathFieldEventHandler ChangePathFieldEvent;
|
||||
public event ChangePathFieldEventHandler ChangePathFieldEvent = delegate { };
|
||||
public delegate void ChangePathFieldEventHandler (string text, string example_text, FieldState state);
|
||||
|
||||
public readonly List<SparklePlugin> Plugins = new List<SparklePlugin> ();
|
||||
|
@ -167,27 +164,19 @@ namespace SparkleShare {
|
|||
Program.Controller.InviteReceived += delegate (SparkleInvite invite) {
|
||||
PendingInvite = invite;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
ShowWindowEvent ();
|
||||
};
|
||||
|
||||
Program.Controller.ShowSetupWindowEvent += delegate (PageType page_type) {
|
||||
if (page_type == PageType.CryptoSetup || page_type == PageType.CryptoPassword) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (page_type, null);
|
||||
|
||||
ChangePageEvent (page_type, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PendingInvite != null) {
|
||||
WindowIsOpen = true;
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
|
||||
ShowWindowEvent ();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -196,9 +185,7 @@ namespace SparkleShare {
|
|||
this.current_page == PageType.CryptoSetup ||
|
||||
this.current_page == PageType.CryptoPassword) {
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
|
||||
ShowWindowEvent ();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -208,33 +195,23 @@ namespace SparkleShare {
|
|||
this.current_page == PageType.Finished ||
|
||||
this.current_page == PageType.None) {
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
}
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
ShowWindowEvent ();
|
||||
|
||||
} else if (!Program.Controller.FirstRun && TutorialPageNumber == 0) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
|
||||
WindowIsOpen = true;
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
ShowWindowEvent ();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
WindowIsOpen = true;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (page_type, null);
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
ChangePageEvent (page_type, null);
|
||||
ShowWindowEvent ();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -250,9 +227,7 @@ namespace SparkleShare {
|
|||
this.fetch_prior_history = false;
|
||||
|
||||
WindowIsOpen = false;
|
||||
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
HideWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -262,9 +237,7 @@ namespace SparkleShare {
|
|||
email = email.Trim ();
|
||||
|
||||
bool fields_valid = (!string.IsNullOrEmpty (full_name) && IsValidEmail (email));
|
||||
|
||||
if (UpdateSetupContinueButtonEvent != null)
|
||||
UpdateSetupContinueButtonEvent (fields_valid);
|
||||
UpdateSetupContinueButtonEvent (fields_valid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,18 +268,14 @@ namespace SparkleShare {
|
|||
}).Start ();
|
||||
|
||||
TutorialPageNumber = 1;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
}
|
||||
|
||||
|
||||
public void TutorialSkipped ()
|
||||
{
|
||||
TutorialPageNumber = 4;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
}
|
||||
|
||||
|
||||
|
@ -324,16 +293,13 @@ namespace SparkleShare {
|
|||
TutorialPageNumber = 0;
|
||||
|
||||
WindowIsOpen = false;
|
||||
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
HideWindowEvent ();
|
||||
|
||||
if (this.create_startup_item)
|
||||
Program.Controller.CreateStartupItem ();
|
||||
|
||||
} else {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,29 +309,23 @@ namespace SparkleShare {
|
|||
SelectedPlugin = Plugins [plugin_index];
|
||||
|
||||
if (SelectedPlugin.Address != null) {
|
||||
if (ChangeAddressFieldEvent != null)
|
||||
ChangeAddressFieldEvent (SelectedPlugin.Address, "", FieldState.Disabled);
|
||||
ChangeAddressFieldEvent (SelectedPlugin.Address, "", FieldState.Disabled);
|
||||
|
||||
} else if (SelectedPlugin.AddressExample != null) {
|
||||
if (ChangeAddressFieldEvent != null)
|
||||
ChangeAddressFieldEvent (this.saved_address, SelectedPlugin.AddressExample, FieldState.Enabled);
|
||||
ChangeAddressFieldEvent (this.saved_address, SelectedPlugin.AddressExample, FieldState.Enabled);
|
||||
|
||||
} else {
|
||||
if (ChangeAddressFieldEvent != null)
|
||||
ChangeAddressFieldEvent (this.saved_address, "", FieldState.Enabled);
|
||||
ChangeAddressFieldEvent (this.saved_address, "", FieldState.Enabled);
|
||||
}
|
||||
|
||||
if (SelectedPlugin.Path != null) {
|
||||
if (ChangePathFieldEvent != null)
|
||||
ChangePathFieldEvent (SelectedPlugin.Path, "", FieldState.Disabled);
|
||||
ChangePathFieldEvent (SelectedPlugin.Path, "", FieldState.Disabled);
|
||||
|
||||
} else if (SelectedPlugin.PathExample != null) {
|
||||
if (ChangePathFieldEvent != null)
|
||||
ChangePathFieldEvent (this.saved_remote_path, SelectedPlugin.PathExample, FieldState.Enabled);
|
||||
ChangePathFieldEvent (this.saved_remote_path, SelectedPlugin.PathExample, FieldState.Enabled);
|
||||
|
||||
} else {
|
||||
if (ChangePathFieldEvent != null)
|
||||
ChangePathFieldEvent (this.saved_remote_path, "", FieldState.Enabled);
|
||||
ChangePathFieldEvent (this.saved_remote_path, "", FieldState.Enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,11 +347,9 @@ namespace SparkleShare {
|
|||
this.saved_remote_path = remote_path;
|
||||
|
||||
bool fields_valid = (!string.IsNullOrEmpty (address) &&
|
||||
!string.IsNullOrEmpty (remote_path) &&
|
||||
!remote_path.Contains ("\""));
|
||||
!string.IsNullOrEmpty (remote_path) && !remote_path.Contains ("\""));
|
||||
|
||||
if (UpdateAddProjectButtonEvent != null)
|
||||
UpdateAddProjectButtonEvent (fields_valid);
|
||||
UpdateAddProjectButtonEvent (fields_valid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -400,8 +358,7 @@ namespace SparkleShare {
|
|||
SyncingFolder = Path.GetFileNameWithoutExtension (remote_path);
|
||||
ProgressBarPercentage = 1.0;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
|
||||
address = address.Trim ();
|
||||
remote_path = remote_path.Trim ();
|
||||
|
@ -453,8 +410,7 @@ namespace SparkleShare {
|
|||
}
|
||||
}
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Finished, warnings);
|
||||
ChangePageEvent (PageType.Finished, warnings);
|
||||
|
||||
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||
|
@ -466,8 +422,7 @@ namespace SparkleShare {
|
|||
SyncingFolder = "";
|
||||
PreviousUrl = remote_url;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Error, errors);
|
||||
ChangePageEvent (PageType.Error, errors);
|
||||
|
||||
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||
|
@ -477,9 +432,7 @@ namespace SparkleShare {
|
|||
private void SyncingPageFetchingDelegate (double percentage)
|
||||
{
|
||||
ProgressBarPercentage = percentage;
|
||||
|
||||
if (UpdateProgressBarEvent != null)
|
||||
UpdateProgressBarEvent (ProgressBarPercentage);
|
||||
UpdateProgressBarEvent (ProgressBarPercentage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -489,13 +442,10 @@ namespace SparkleShare {
|
|||
PreviousAddress = PendingInvite.Address;
|
||||
PreviousPath = PendingInvite.RemotePath;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
|
||||
if (!PendingInvite.Accept ()) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Error, null);
|
||||
|
||||
ChangePageEvent (PageType.Error, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -515,8 +465,7 @@ namespace SparkleShare {
|
|||
SyncingFolder = "";
|
||||
PendingInvite = null;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Finished, warnings);
|
||||
ChangePageEvent (PageType.Finished, warnings);
|
||||
|
||||
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||
|
@ -528,8 +477,7 @@ namespace SparkleShare {
|
|||
SyncingFolder = "";
|
||||
PreviousUrl = remote_url;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Error, errors);
|
||||
ChangePageEvent (PageType.Error, errors);
|
||||
|
||||
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||
|
@ -541,12 +489,10 @@ namespace SparkleShare {
|
|||
{
|
||||
Program.Controller.StopFetcher ();
|
||||
|
||||
if (ChangePageEvent != null) {
|
||||
if (PendingInvite != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
else
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
}
|
||||
if (PendingInvite != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
else
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
}
|
||||
|
||||
|
||||
|
@ -562,18 +508,14 @@ namespace SparkleShare {
|
|||
public void CheckCryptoSetupPage (string password)
|
||||
{
|
||||
bool valid_password = (password.Length > 0 && !password.Contains (" "));
|
||||
|
||||
if (UpdateCryptoSetupContinueButtonEvent != null)
|
||||
UpdateCryptoSetupContinueButtonEvent (valid_password);
|
||||
UpdateCryptoSetupContinueButtonEvent (valid_password);
|
||||
}
|
||||
|
||||
|
||||
public void CheckCryptoPasswordPage (string password)
|
||||
{
|
||||
bool password_correct = Program.Controller.CheckPassword (password);
|
||||
|
||||
if (UpdateCryptoPasswordContinueButtonEvent != null)
|
||||
UpdateCryptoPasswordContinueButtonEvent (password_correct);
|
||||
UpdateCryptoPasswordContinueButtonEvent (password_correct);
|
||||
}
|
||||
|
||||
|
||||
|
@ -592,9 +534,7 @@ namespace SparkleShare {
|
|||
public void CryptoPasswordPageCompleted (string password)
|
||||
{
|
||||
ProgressBarPercentage = 100.0;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
|
||||
new Thread (() => {
|
||||
Thread.Sleep (1000);
|
||||
|
@ -620,9 +560,7 @@ namespace SparkleShare {
|
|||
this.fetch_prior_history = false;
|
||||
|
||||
this.current_page = PageType.None;
|
||||
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
HideWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,19 +36,19 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleStatusIconController {
|
||||
|
||||
public event UpdateIconEventHandler UpdateIconEvent;
|
||||
public event UpdateIconEventHandler UpdateIconEvent = delegate { };
|
||||
public delegate void UpdateIconEventHandler (int icon_frame);
|
||||
|
||||
public event UpdateMenuEventHandler UpdateMenuEvent;
|
||||
public event UpdateMenuEventHandler UpdateMenuEvent = delegate { };
|
||||
public delegate void UpdateMenuEventHandler (IconState state);
|
||||
|
||||
public event UpdateStatusItemEventHandler UpdateStatusItemEvent;
|
||||
public event UpdateStatusItemEventHandler UpdateStatusItemEvent = delegate { };
|
||||
public delegate void UpdateStatusItemEventHandler (string state_text);
|
||||
|
||||
public event UpdateQuitItemEventHandler UpdateQuitItemEvent;
|
||||
public event UpdateQuitItemEventHandler UpdateQuitItemEvent = delegate { };
|
||||
public delegate void UpdateQuitItemEventHandler (bool quit_item_enabled);
|
||||
|
||||
public event UpdateOpenRecentEventsItemEventHandler UpdateOpenRecentEventsItemEvent;
|
||||
public event UpdateOpenRecentEventsItemEventHandler UpdateOpenRecentEventsItemEvent = delegate { };
|
||||
public delegate void UpdateOpenRecentEventsItemEventHandler (bool open_recent_events_item_enabled);
|
||||
|
||||
public IconState CurrentState = IconState.Idle;
|
||||
|
@ -138,14 +138,9 @@ namespace SparkleShare {
|
|||
StateText = "Files up to date " + FolderSize;
|
||||
}
|
||||
|
||||
if (UpdateStatusItemEvent != null)
|
||||
UpdateStatusItemEvent (StateText);
|
||||
|
||||
if (UpdateOpenRecentEventsItemEvent != null)
|
||||
UpdateOpenRecentEventsItemEvent (OpenRecentEventsItemEnabled);
|
||||
|
||||
if (UpdateMenuEvent != null)
|
||||
UpdateMenuEvent (CurrentState);
|
||||
UpdateStatusItemEvent (StateText);
|
||||
UpdateOpenRecentEventsItemEvent (OpenRecentEventsItemEnabled);
|
||||
UpdateMenuEvent (CurrentState);
|
||||
};
|
||||
|
||||
Program.Controller.OnIdle += delegate {
|
||||
|
@ -158,19 +153,13 @@ namespace SparkleShare {
|
|||
StateText = "Files up to date " + FolderSize;
|
||||
}
|
||||
|
||||
if (UpdateQuitItemEvent != null)
|
||||
UpdateQuitItemEvent (QuitItemEnabled);
|
||||
|
||||
if (UpdateStatusItemEvent != null)
|
||||
UpdateStatusItemEvent (StateText);
|
||||
UpdateQuitItemEvent (QuitItemEnabled);
|
||||
UpdateStatusItemEvent (StateText);
|
||||
|
||||
this.animation.Stop ();
|
||||
|
||||
if (UpdateIconEvent != null)
|
||||
UpdateIconEvent (0);
|
||||
|
||||
if (UpdateMenuEvent != null)
|
||||
UpdateMenuEvent (CurrentState);
|
||||
UpdateIconEvent (0);
|
||||
UpdateMenuEvent (CurrentState);
|
||||
};
|
||||
|
||||
Program.Controller.OnSyncing += delegate {
|
||||
|
@ -202,11 +191,8 @@ namespace SparkleShare {
|
|||
|
||||
StateText += " " + ProgressPercentage + "% " + ProgressSpeed;
|
||||
|
||||
if (UpdateStatusItemEvent != null)
|
||||
UpdateStatusItemEvent (StateText);
|
||||
|
||||
if (UpdateQuitItemEvent != null)
|
||||
UpdateQuitItemEvent (QuitItemEnabled);
|
||||
UpdateStatusItemEvent (StateText);
|
||||
UpdateQuitItemEvent (QuitItemEnabled);
|
||||
|
||||
this.animation.Start ();
|
||||
};
|
||||
|
@ -215,16 +201,12 @@ namespace SparkleShare {
|
|||
CurrentState = IconState.Error;
|
||||
StateText = "Failed to send some changes";
|
||||
|
||||
if (UpdateQuitItemEvent != null)
|
||||
UpdateQuitItemEvent (QuitItemEnabled);
|
||||
|
||||
if (UpdateStatusItemEvent != null)
|
||||
UpdateStatusItemEvent (StateText);
|
||||
UpdateQuitItemEvent (QuitItemEnabled);
|
||||
UpdateStatusItemEvent (StateText);
|
||||
|
||||
this.animation.Stop ();
|
||||
|
||||
if (UpdateIconEvent != null)
|
||||
UpdateIconEvent (-1);
|
||||
UpdateIconEvent (-1);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -279,8 +261,7 @@ namespace SparkleShare {
|
|||
else
|
||||
this.animation_frame_number = 0;
|
||||
|
||||
if (UpdateIconEvent != null)
|
||||
UpdateIconEvent (this.animation_frame_number);
|
||||
UpdateIconEvent (this.animation_frame_number);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue