[controller] Add OnQuitWhileSyncing event

This commit is contained in:
Hylke Bons 2010-11-19 21:38:28 +00:00
parent b3c4ab11f7
commit e7b90cd91a
2 changed files with 32 additions and 3 deletions

View file

@ -31,6 +31,9 @@ namespace SparkleShare {
public string FolderSize;
public event OnQuitWhileSyncingEventHandler OnQuitWhileSyncing;
public delegate void OnQuitWhileSyncingEventHandler ();
public event FolderFetchedEventHandler FolderFetched;
public delegate void FolderFetchedEventHandler ();
@ -723,16 +726,38 @@ namespace SparkleShare {
// Quits the program
public void TryQuit ()
{
foreach (SparkleRepo repo in Repositories) {
if (repo.IsSyncing) {
if (OnQuitWhileSyncing != null)
OnQuitWhileSyncing ();
return;
}
}
Quit ();
}
public void Quit ()
{
// TODO: Pop up a warning when quitting whilst syncing
foreach (SparkleRepo repo in Repositories)
repo.Dispose ();
string pid_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, "sparkleshare.pid");
// Remove the process ID file
File.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, "sparkleshare.pid"));
if (File.Exists (pid_file_path))
File.Delete (pid_file_path);
Environment.Exit (0);

View file

@ -61,6 +61,10 @@ namespace SparkleShare {
});
};
SparkleShare.Controller.OnQuitWhileSyncing += delegate {
// TODO: Pop up a warning when quitting whilst syncing
};
SparkleShare.Controller.OnInvitation += delegate (string invitation_file_path) {
Application.Invoke (delegate {