setup controller: remove hooked up delegates after fetcher has finished
This commit is contained in:
parent
e1053ada73
commit
4aed67a534
|
@ -305,43 +305,54 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AddPageCompleted (string address, string path)
|
public void AddPageCompleted (string address, string remote_path)
|
||||||
{
|
{
|
||||||
SyncingFolder = Path.GetFileNameWithoutExtension (path);
|
SyncingFolder = Path.GetFileNameWithoutExtension (remote_path);
|
||||||
PreviousAddress = address;
|
PreviousAddress = address;
|
||||||
PreviousPath = path;
|
PreviousPath = remote_path;
|
||||||
|
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
ChangePageEvent (PageType.Syncing, null);
|
ChangePageEvent (PageType.Syncing, null);
|
||||||
|
|
||||||
// TODO: Remove events afterwards
|
Program.Controller.FolderFetched += AddPageFetchedDelegate;
|
||||||
|
Program.Controller.FolderFetchError += AddPageFetchErrorDelegate;
|
||||||
|
Program.Controller.FolderFetching += SyncingPageFetchingDelegate;
|
||||||
|
|
||||||
Program.Controller.FolderFetched += delegate (string [] warnings) {
|
Program.Controller.FetchFolder (address, remote_path, SelectedPlugin.AnnouncementsUrl);
|
||||||
if (ChangePageEvent != null)
|
}
|
||||||
ChangePageEvent (PageType.Finished, warnings);
|
|
||||||
|
|
||||||
PreviousAddress = "";
|
// The following private methods are
|
||||||
SyncingFolder = "";
|
// delegates used by the previous method
|
||||||
PreviousUrl = "";
|
|
||||||
SelectedPlugin = Plugins [0];
|
|
||||||
};
|
|
||||||
|
|
||||||
Program.Controller.FolderFetchError += delegate (string remote_url) {
|
private void AddPageFetchedDelegate (string [] warnings)
|
||||||
Thread.Sleep (1000);
|
{
|
||||||
PreviousUrl = remote_url;
|
SyncingFolder = "";
|
||||||
|
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
ChangePageEvent (PageType.Error, null);
|
ChangePageEvent (PageType.Finished, warnings);
|
||||||
|
|
||||||
SyncingFolder = "";
|
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||||
};
|
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||||
|
Program.Controller.FolderFetching -= SyncingPageFetchingDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
Program.Controller.FolderFetching += delegate (double percentage) {
|
private void AddPageFetchErrorDelegate (string remote_url)
|
||||||
if (UpdateProgressBarEvent != null)
|
{
|
||||||
UpdateProgressBarEvent (percentage);
|
SyncingFolder = "";
|
||||||
};
|
PreviousUrl = remote_url;
|
||||||
|
|
||||||
Program.Controller.FetchFolder (address, path, SelectedPlugin.AnnouncementsUrl);
|
if (ChangePageEvent != null)
|
||||||
|
ChangePageEvent (PageType.Error, null);
|
||||||
|
|
||||||
|
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||||
|
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||||
|
Program.Controller.FolderFetching -= SyncingPageFetchingDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SyncingPageFetchingDelegate (double percentage)
|
||||||
|
{
|
||||||
|
if (UpdateProgressBarEvent != null)
|
||||||
|
UpdateProgressBarEvent (percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -349,8 +360,7 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
SyncingFolder = Path.GetFileNameWithoutExtension (PendingInvite.RemotePath);
|
SyncingFolder = Path.GetFileNameWithoutExtension (PendingInvite.RemotePath);
|
||||||
PreviousAddress = PendingInvite.Address;
|
PreviousAddress = PendingInvite.Address;
|
||||||
// TODO: trailing slash should work
|
PreviousPath = PendingInvite.RemotePath; // FIXME: trailing slash should work
|
||||||
PreviousPath = PendingInvite.RemotePath;
|
|
||||||
|
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
ChangePageEvent (PageType.Syncing, null);
|
ChangePageEvent (PageType.Syncing, null);
|
||||||
|
@ -362,39 +372,43 @@ namespace SparkleShare {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Program.Controller.FolderFetched += InvitePageFetchedDelegate;
|
||||||
// TODO: Remove events afterwards
|
Program.Controller.FolderFetchError += InvitePageFetchErrorDelegate;
|
||||||
|
Program.Controller.FolderFetching += SyncingPageFetchingDelegate;
|
||||||
Program.Controller.FolderFetched += delegate (string [] warnings) {
|
|
||||||
if (ChangePageEvent != null)
|
|
||||||
ChangePageEvent (PageType.Finished, warnings);
|
|
||||||
|
|
||||||
PreviousAddress = "";
|
|
||||||
SyncingFolder = "";
|
|
||||||
PreviousUrl = "";
|
|
||||||
SelectedPlugin = Plugins [0];
|
|
||||||
|
|
||||||
PendingInvite = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
Program.Controller.FolderFetchError += delegate (string remote_url) {
|
|
||||||
PreviousUrl = remote_url;
|
|
||||||
|
|
||||||
if (ChangePageEvent != null)
|
|
||||||
ChangePageEvent (PageType.Error, null);
|
|
||||||
|
|
||||||
SyncingFolder = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
Program.Controller.FolderFetching += delegate (double percentage) {
|
|
||||||
if (UpdateProgressBarEvent != null)
|
|
||||||
UpdateProgressBarEvent (percentage);
|
|
||||||
};
|
|
||||||
|
|
||||||
Program.Controller.FetchFolder (PendingInvite.Address,
|
Program.Controller.FetchFolder (PendingInvite.Address,
|
||||||
PendingInvite.RemotePath, PendingInvite.AnnouncementsUrl.ToString ());
|
PendingInvite.RemotePath, PendingInvite.AnnouncementsUrl.ToString ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following private methods are
|
||||||
|
// delegates used by the previous method
|
||||||
|
|
||||||
|
private void InvitePageFetchedDelegate (string [] warnings)
|
||||||
|
{
|
||||||
|
SyncingFolder = "";
|
||||||
|
PendingInvite = null;
|
||||||
|
|
||||||
|
if (ChangePageEvent != null)
|
||||||
|
ChangePageEvent (PageType.Finished, warnings);
|
||||||
|
|
||||||
|
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||||
|
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||||
|
Program.Controller.FolderFetching -= SyncingPageFetchingDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvitePageFetchErrorDelegate (string remote_url)
|
||||||
|
{
|
||||||
|
SyncingFolder = "";
|
||||||
|
PreviousUrl = remote_url;
|
||||||
|
|
||||||
|
if (ChangePageEvent != null)
|
||||||
|
ChangePageEvent (PageType.Error, null);
|
||||||
|
|
||||||
|
Program.Controller.FolderFetched -= AddPageFetchedDelegate;
|
||||||
|
Program.Controller.FolderFetchError -= AddPageFetchErrorDelegate;
|
||||||
|
Program.Controller.FolderFetching -= SyncingPageFetchingDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SyncingCancelled ()
|
public void SyncingCancelled ()
|
||||||
{
|
{
|
||||||
|
@ -433,6 +447,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void FinishPageCompleted ()
|
public void FinishPageCompleted ()
|
||||||
{
|
{
|
||||||
|
SelectedPlugin = Plugins [0];
|
||||||
|
PreviousUrl = "";
|
||||||
PreviousAddress = "";
|
PreviousAddress = "";
|
||||||
PreviousPath = "";
|
PreviousPath = "";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue