Finish support for invite.xml files dropped in ~/SparkleShare
This commit is contained in:
parent
2db5c8366c
commit
44298936ec
|
@ -33,10 +33,9 @@ namespace SparkleShare {
|
|||
public SparkleSetupController Controller = new SparkleSetupController ();
|
||||
|
||||
private NSButton ContinueButton;
|
||||
private NSButton SyncButton;
|
||||
private NSButton AddButton;
|
||||
private NSButton TryAgainButton;
|
||||
private NSButton CancelButton;
|
||||
private NSButton AcceptButton;
|
||||
private NSButton SkipTutorialButton;
|
||||
private NSButton OpenFolderButton;
|
||||
private NSButton FinishButton;
|
||||
|
@ -65,6 +64,18 @@ namespace SparkleShare {
|
|||
|
||||
public SparkleSetup () : base ()
|
||||
{
|
||||
Controller.HideWindowEvent += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
PerformClose (this);
|
||||
});
|
||||
};
|
||||
|
||||
Controller.ShowWindowEvent += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
OrderFrontRegardless ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
|
||||
InvokeOnMainThread (delegate {
|
||||
Reset ();
|
||||
|
@ -72,6 +83,7 @@ namespace SparkleShare {
|
|||
switch (type) {
|
||||
case PageType.Setup: {
|
||||
|
||||
// TODO: Improve text
|
||||
Header = "Welcome to SparkleShare!";
|
||||
Description = "We'll need some info to mark your changes in the event log. " +
|
||||
"Don't worry, this stays between you and your peers.";
|
||||
|
@ -165,25 +177,70 @@ namespace SparkleShare {
|
|||
Description = "Do you want to add this project to SparkleShare?";
|
||||
|
||||
|
||||
AddressLabel = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Right,
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
Bordered = false,
|
||||
Editable = false,
|
||||
Frame = new RectangleF (165, Frame.Height - 240, 160, 17),
|
||||
StringValue = "Address:",
|
||||
Font = SparkleUI.Font
|
||||
};
|
||||
|
||||
PathLabel = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Right,
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
Bordered = false,
|
||||
Editable = false,
|
||||
Frame = new RectangleF (165, Frame.Height - 264, 160, 17),
|
||||
StringValue = "Remote Path:",
|
||||
Font = SparkleUI.Font
|
||||
};
|
||||
|
||||
AddressTextField = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Left,
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
Bordered = false,
|
||||
Editable = false,
|
||||
Frame = new RectangleF (330, Frame.Height - 240, 260, 17),
|
||||
StringValue = Controller.PendingInvite.Address,
|
||||
Font = SparkleUI.BoldFont
|
||||
};
|
||||
|
||||
PathTextField = new NSTextField () {
|
||||
Alignment = NSTextAlignment.Left,
|
||||
BackgroundColor = NSColor.WindowBackground,
|
||||
Bordered = false,
|
||||
Editable = false,
|
||||
Frame = new RectangleF (330, Frame.Height - 264, 260, 17),
|
||||
StringValue = Controller.PendingInvite.RemotePath,
|
||||
Font = SparkleUI.BoldFont
|
||||
};
|
||||
|
||||
|
||||
ContentView.AddSubview (AddressLabel);
|
||||
ContentView.AddSubview (PathLabel);
|
||||
ContentView.AddSubview (AddressTextField);
|
||||
ContentView.AddSubview (PathTextField);
|
||||
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
PerformClose (this);
|
||||
});
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
AcceptButton = new NSButton () {
|
||||
Title = "Accept"
|
||||
AddButton = new NSButton () {
|
||||
Title = "Add"
|
||||
};
|
||||
|
||||
AcceptButton.Activated += delegate {
|
||||
AddButton.Activated += delegate {
|
||||
Controller.InvitePageCompleted ();
|
||||
};
|
||||
|
||||
Buttons.Add (AcceptButton);
|
||||
Buttons.Add (AddButton);
|
||||
Buttons.Add (CancelButton);
|
||||
|
||||
break;
|
||||
|
@ -201,7 +258,7 @@ namespace SparkleShare {
|
|||
Editable = false,
|
||||
Frame = new RectangleF (190, Frame.Height - 308, 160, 17),
|
||||
StringValue = "Address:",
|
||||
Font = SparkleUI.Font
|
||||
Font = SparkleUI.BoldFont
|
||||
};
|
||||
|
||||
AddressTextField = new NSTextField () {
|
||||
|
@ -220,7 +277,7 @@ namespace SparkleShare {
|
|||
Editable = false,
|
||||
Frame = new RectangleF (190 + 196 + 16, Frame.Height - 308, 160, 17),
|
||||
StringValue = "Remote Path:",
|
||||
Font = SparkleUI.Font
|
||||
Font = SparkleUI.BoldFont
|
||||
};
|
||||
|
||||
PathTextField = new NSTextField () {
|
||||
|
@ -345,7 +402,7 @@ namespace SparkleShare {
|
|||
|
||||
Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
|
||||
InvokeOnMainThread (delegate {
|
||||
SyncButton.Enabled = button_enabled;
|
||||
AddButton.Enabled = button_enabled;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -357,28 +414,26 @@ namespace SparkleShare {
|
|||
ContentView.AddSubview (PathTextField);
|
||||
ContentView.AddSubview (PathHelpLabel);
|
||||
|
||||
SyncButton = new NSButton () {
|
||||
AddButton = new NSButton () {
|
||||
Title = "Add",
|
||||
Enabled = false
|
||||
};
|
||||
|
||||
SyncButton.Activated += delegate {
|
||||
AddButton.Activated += delegate {
|
||||
Controller.AddPageCompleted (
|
||||
AddressTextField.StringValue,
|
||||
PathTextField.StringValue
|
||||
);
|
||||
};
|
||||
|
||||
Buttons.Add (SyncButton);
|
||||
Buttons.Add (AddButton);
|
||||
|
||||
CancelButton = new NSButton () {
|
||||
Title = "Cancel"
|
||||
};
|
||||
|
||||
CancelButton.Activated += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
PerformClose (this);
|
||||
});
|
||||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
Buttons.Add (CancelButton);
|
||||
|
@ -524,10 +579,7 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
FinishButton.Activated += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
Controller.FinishedPageCompleted ();
|
||||
PerformClose (this);
|
||||
});
|
||||
Controller.FinishPageCompleted ();
|
||||
};
|
||||
|
||||
OpenFolderButton = new NSButton () {
|
||||
|
@ -674,9 +726,7 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
FinishButton.Activated += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
PerformClose (this);
|
||||
});
|
||||
Controller.TutorialPageCompleted ();
|
||||
};
|
||||
|
||||
string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||
|
|
|
@ -83,11 +83,6 @@ namespace SparkleShare {
|
|||
Font = SparkleUI.Font
|
||||
};
|
||||
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
MakeKeyAndOrderFront (this);
|
||||
|
||||
OrderFrontRegardless ();
|
||||
|
||||
if (Program.UI != null)
|
||||
Program.UI.UpdateDockIconVisibility ();
|
||||
}
|
||||
|
@ -140,6 +135,9 @@ namespace SparkleShare {
|
|||
public override void OrderFrontRegardless ()
|
||||
{
|
||||
NSApplication.SharedApplication.AddWindowsItem (this, "SparkleShare Setup", false);
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
MakeKeyAndOrderFront (this);
|
||||
|
||||
base.OrderFrontRegardless ();
|
||||
}
|
||||
|
||||
|
|
|
@ -230,26 +230,13 @@ namespace SparkleShare {
|
|||
Menu.AddItem (NSMenuItem.SeparatorItem);
|
||||
|
||||
SyncMenuItem = new NSMenuItem () {
|
||||
Title = "Add Hosted Project…",
|
||||
Title = "Add Hosted Project…",
|
||||
Enabled = true
|
||||
};
|
||||
|
||||
if (!Program.Controller.FirstRun) {
|
||||
SyncMenuItem.Activated += delegate {
|
||||
InvokeOnMainThread (delegate {
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
|
||||
if (SparkleUI.Setup == null) {
|
||||
SparkleUI.Setup = new SparkleSetup ();
|
||||
SparkleUI.Setup.Controller.ShowAddPage ();
|
||||
}
|
||||
|
||||
if (!SparkleUI.Setup.IsVisible)
|
||||
SparkleUI.Setup.Controller.ShowAddPage ();
|
||||
|
||||
SparkleUI.Setup.OrderFrontRegardless ();
|
||||
SparkleUI.Setup.MakeKeyAndOrderFront (this);
|
||||
});
|
||||
Controller.AddHostedProjectClicked ();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -262,7 +249,9 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
if (Controller.Folders.Length > 0) {
|
||||
// TODO: move this logic
|
||||
RecentEventsMenuItem.Activated += delegate {
|
||||
// Controller.OpenRecentEventsClicked ()
|
||||
InvokeOnMainThread (delegate {
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
|
||||
|
@ -304,8 +293,10 @@ namespace SparkleShare {
|
|||
Title = "About SparkleShare",
|
||||
Enabled = true
|
||||
};
|
||||
|
||||
|
||||
// TODO: move this logic
|
||||
AboutMenuItem.Activated += delegate {
|
||||
// Controller.AboutClicked ();
|
||||
InvokeOnMainThread (delegate {
|
||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||
|
||||
|
|
|
@ -65,11 +65,11 @@ namespace SparkleShare {
|
|||
|
||||
StatusIcon = new SparkleStatusIcon ();
|
||||
Bubbles = new SparkleBubbles ();
|
||||
Setup = new SparkleSetup ();
|
||||
// About = new SparkleAbout ();
|
||||
|
||||
if (Program.Controller.FirstRun) {
|
||||
Setup = new SparkleSetup ();
|
||||
Setup.Controller.ShowSetupPage ();
|
||||
|
||||
Program.Controller.ShowSetupWindow (PageType.Setup);
|
||||
UpdateDockIconVisibility ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,17 @@ namespace SparkleShare {
|
|||
public double ProgressPercentage = 0.0;
|
||||
public string ProgressSpeed = "";
|
||||
|
||||
|
||||
public event ShowSetupWindowEventHandler ShowSetupWindowEvent;
|
||||
public delegate void ShowSetupWindowEventHandler (PageType page_type);
|
||||
|
||||
public event ShowAboutWindowEventHandler ShowAboutWindowEvent;
|
||||
public delegate void ShowAboutWindowEventHandler ();
|
||||
|
||||
public event ShowEventsWindowEventHandler ShowEventsWindowEvent;
|
||||
public delegate void ShowEventsWindowEventHandler ();
|
||||
|
||||
|
||||
public event FolderFetchedEventHandler FolderFetched;
|
||||
public delegate void FolderFetchedEventHandler (string [] warnings);
|
||||
|
||||
|
@ -64,8 +75,8 @@ namespace SparkleShare {
|
|||
public event OnErrorHandler OnError;
|
||||
public delegate void OnErrorHandler ();
|
||||
|
||||
public event OnInviteHandler OnInvite;
|
||||
public delegate void OnInviteHandler (SparkleInvite invite);
|
||||
public event InviteReceivedHandler InviteReceived;
|
||||
public delegate void InviteReceivedHandler (SparkleInvite invite);
|
||||
|
||||
public event NotificationRaisedEventHandler NotificationRaised;
|
||||
public delegate void NotificationRaisedEventHandler (SparkleChangeSet change_set);
|
||||
|
@ -130,7 +141,7 @@ namespace SparkleShare {
|
|||
if (!args.FullPath.EndsWith (".xml"))
|
||||
return;
|
||||
|
||||
if (this.fetcher == null ||
|
||||
if (this.fetcher != null &&
|
||||
this.fetcher.IsActive) {
|
||||
|
||||
if (AlertNotificationRaised != null)
|
||||
|
@ -138,8 +149,12 @@ namespace SparkleShare {
|
|||
"Please try again later");
|
||||
|
||||
} else {
|
||||
if (OnInvite != null)
|
||||
OnInvite (new SparkleInvite (args.FullPath));
|
||||
if (InviteReceived != null) {
|
||||
SparkleInvite invite = new SparkleInvite (args.FullPath);
|
||||
|
||||
if (invite.Valid)
|
||||
InviteReceived (invite);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -154,39 +169,6 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
// Uploads the user's public key to the server TODO
|
||||
public bool AcceptInvitation (string server, string folder, string token)
|
||||
{
|
||||
// The location of the user's public key for SparkleShare
|
||||
string public_key_file_path = SparkleHelpers.CombineMore (SparkleConfig.DefaultConfig.HomePath,
|
||||
".ssh", "sparkleshare." + UserEmail + ".key.pub");
|
||||
|
||||
if (!File.Exists (public_key_file_path))
|
||||
return false;
|
||||
|
||||
StreamReader reader = new StreamReader (public_key_file_path);
|
||||
string public_key = reader.ReadToEnd ();
|
||||
reader.Close ();
|
||||
|
||||
string url = "https://" + server + "/?folder=" + folder +
|
||||
"&token=" + token + "&pubkey=" + public_key;
|
||||
|
||||
SparkleHelpers.DebugInfo ("WebRequest", url);
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
|
||||
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK) {
|
||||
response.Close ();
|
||||
return true;
|
||||
|
||||
} else {
|
||||
response.Close ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<string> Folders {
|
||||
get {
|
||||
List<string> folders = SparkleConfig.DefaultConfig.Folders;
|
||||
|
@ -202,6 +184,7 @@ namespace SparkleShare {
|
|||
List<string> hosts = SparkleConfig.DefaultConfig.HostsWithUsername;
|
||||
hosts.AddRange(SparkleConfig.DefaultConfig.Hosts);
|
||||
hosts.Sort ();
|
||||
|
||||
return hosts;
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +204,28 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void ShowSetupWindow (PageType page_type)
|
||||
{
|
||||
if (ShowSetupWindowEvent != null)
|
||||
ShowSetupWindowEvent (page_type);
|
||||
}
|
||||
|
||||
|
||||
public void ShowAboutWindow ()
|
||||
{
|
||||
if (ShowAboutWindowEvent != null)
|
||||
ShowAboutWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
public void ShowEventsWindow ()
|
||||
{
|
||||
if (ShowEventsWindowEvent != null)
|
||||
ShowEventsWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<SparkleChangeSet> GetLog ()
|
||||
{
|
||||
List<SparkleChangeSet> list = new List<SparkleChangeSet> ();
|
||||
|
|
|
@ -16,12 +16,8 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Threading;
|
||||
|
||||
using SparkleLib;
|
||||
|
||||
|
@ -29,22 +25,22 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleInvite {
|
||||
|
||||
public readonly string Address;
|
||||
public readonly string RemotePath;
|
||||
public readonly Uri AcceptUrl;
|
||||
public string Address { get; private set; }
|
||||
public string RemotePath { get; private set; }
|
||||
public Uri AcceptUrl { get; private set; }
|
||||
|
||||
public bool Valid {
|
||||
get {
|
||||
return (!string.IsNullOrEmpty (Address) &&
|
||||
!string.IsNullOrEmpty (RemotePath) &&
|
||||
!string.IsNullOrEmpty (AcceptUrl.ToString ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public SparkleInvite (string address, string remote_path, string accept_url)
|
||||
{
|
||||
if (remote_path.StartsWith ("/"))
|
||||
remote_path = remote_path.Substring (1);
|
||||
|
||||
if (!address.EndsWith ("/"))
|
||||
address = address + "/";
|
||||
|
||||
Address = address;
|
||||
RemotePath = remote_path;
|
||||
AcceptUrl = new Uri (accept_url);
|
||||
Initialize (address, remote_path, accept_url);
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +49,10 @@ namespace SparkleShare {
|
|||
XmlDocument xml_document = new XmlDocument ();
|
||||
XmlNode node;
|
||||
|
||||
string address = "", remote_path = "", accept_url = "";
|
||||
string address = "";
|
||||
string remote_path = "";
|
||||
string accept_url = "";
|
||||
|
||||
|
||||
try {
|
||||
xml_document.Load (xml_file_path);
|
||||
|
@ -67,21 +66,12 @@ namespace SparkleShare {
|
|||
node = xml_document.SelectSingleNode ("/sparkleshare/invite/accept_url/text()");
|
||||
if (node != null) { accept_url = node.Value; }
|
||||
|
||||
Initialize (address, remote_path, accept_url);
|
||||
|
||||
} catch (XmlException e) {
|
||||
SparkleHelpers.DebugInfo ("Invite", "Invalid XML: " + e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (remote_path.StartsWith ("/"))
|
||||
remote_path = remote_path.Substring (1);
|
||||
|
||||
if (!address.EndsWith ("/"))
|
||||
address = address + "/";
|
||||
|
||||
Address = address;
|
||||
RemotePath = remote_path;
|
||||
AcceptUrl = new Uri (accept_url);
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,5 +92,19 @@ namespace SparkleShare {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Initialize (string address, string remote_path, string accept_url)
|
||||
{/*
|
||||
if (!remote_path.StartsWith ("/"))
|
||||
remote_path = "/" + remote_path;
|
||||
|
||||
if (!address.EndsWith ("/"))
|
||||
address = address + "/";
|
||||
*/
|
||||
Address = address;
|
||||
RemotePath = remote_path;
|
||||
AcceptUrl = new Uri (accept_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,12 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleSetupController {
|
||||
|
||||
public event ShowWindowEventHandler ShowWindowEvent;
|
||||
public delegate void ShowWindowEventHandler ();
|
||||
|
||||
public event HideWindowEventHandler HideWindowEvent;
|
||||
public delegate void HideWindowEventHandler ();
|
||||
|
||||
public event ChangePageEventHandler ChangePageEvent;
|
||||
public delegate void ChangePageEventHandler (PageType page, string [] warnings);
|
||||
|
||||
|
@ -60,12 +66,17 @@ namespace SparkleShare {
|
|||
string example_text, FieldState state);
|
||||
|
||||
public event ChangePathFieldEventHandler ChangePathFieldEvent;
|
||||
public delegate void ChangePathFieldEventHandler (string text,
|
||||
string example_text, FieldState state);
|
||||
public delegate void ChangePathFieldEventHandler (string text, string example_text, FieldState state);
|
||||
|
||||
public readonly List<SparklePlugin> Plugins = new List<SparklePlugin> ();
|
||||
public SparklePlugin SelectedPlugin;
|
||||
|
||||
public int TutorialPageNumber { get; private set; }
|
||||
public string PreviousUrl { get; private set; }
|
||||
public string PreviousAddress { get; private set; }
|
||||
public string PreviousPath { get; private set; }
|
||||
public string SyncingFolder { get; private set; }
|
||||
|
||||
|
||||
public int SelectedPluginIndex {
|
||||
get {
|
||||
|
@ -73,42 +84,6 @@ namespace SparkleShare {
|
|||
}
|
||||
}
|
||||
|
||||
public int TutorialPageNumber {
|
||||
get {
|
||||
return this.tutorial_page_number;
|
||||
}
|
||||
}
|
||||
|
||||
public string PreviousUrl {
|
||||
get {
|
||||
return this.previous_url;
|
||||
}
|
||||
}
|
||||
|
||||
public string PreviousAddress {
|
||||
get {
|
||||
return this.previous_address;
|
||||
}
|
||||
}
|
||||
|
||||
public string PreviousPath {
|
||||
get {
|
||||
return this.previous_path;
|
||||
}
|
||||
}
|
||||
|
||||
public string SyncingFolder {
|
||||
get {
|
||||
return this.syncing_folder;
|
||||
}
|
||||
}
|
||||
|
||||
public PageType PreviousPage {
|
||||
get {
|
||||
return this.previous_page;
|
||||
}
|
||||
}
|
||||
|
||||
public string GuessedUserName {
|
||||
get {
|
||||
return Program.Controller.UserName;
|
||||
|
@ -125,16 +100,14 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
private string previous_address = "";
|
||||
private string previous_path = "";
|
||||
private string previous_url = "";
|
||||
private string syncing_folder = "";
|
||||
private int tutorial_page_number = 1;
|
||||
private PageType previous_page;
|
||||
|
||||
|
||||
public SparkleSetupController ()
|
||||
{
|
||||
TutorialPageNumber = 1;
|
||||
PreviousAddress = "";
|
||||
PreviousPath = "";
|
||||
PreviousUrl = "";
|
||||
SyncingFolder = "";
|
||||
|
||||
string local_plugins_path = SparkleHelpers.CombineMore (
|
||||
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
|
||||
"sparkleshare", "plugins");
|
||||
|
@ -154,16 +127,37 @@ namespace SparkleShare {
|
|||
|
||||
SelectedPlugin = Plugins [0];
|
||||
|
||||
ChangePageEvent += delegate (PageType page, string [] warning) {
|
||||
this.previous_page = page;
|
||||
|
||||
Program.Controller.InviteReceived += delegate (SparkleInvite invite) {
|
||||
PendingInvite = invite;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
};
|
||||
|
||||
|
||||
Program.Controller.ShowSetupWindowEvent += delegate (PageType page_type) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (page_type, null);
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
|
||||
if (page_type == PageType.Add)
|
||||
SelectedPluginChanged (SelectedPluginIndex);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void ShowSetupPage ()
|
||||
public void PageCancelled ()
|
||||
{
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Setup, null);
|
||||
// PendingInvite = null;
|
||||
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,171 +188,27 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void TutorialPageCompleted ()
|
||||
{
|
||||
this.tutorial_page_number++;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
}
|
||||
|
||||
|
||||
public void TutorialSkipped ()
|
||||
{
|
||||
this.tutorial_page_number = 4;
|
||||
TutorialPageNumber = 4;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
}
|
||||
|
||||
|
||||
public void ShowAddPage ()
|
||||
public void TutorialPageCompleted ()
|
||||
{
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
TutorialPageNumber++;
|
||||
|
||||
SelectedPluginChanged (SelectedPluginIndex);
|
||||
}
|
||||
if (TutorialPageNumber == 4) {
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
|
||||
|
||||
public void CheckAddPage (string address, string remote_path, int selected_plugin)
|
||||
{
|
||||
if (SelectedPluginIndex != selected_plugin)
|
||||
SelectedPluginChanged (selected_plugin);
|
||||
|
||||
address = address.Trim ();
|
||||
remote_path = remote_path.Trim ();
|
||||
|
||||
bool fields_valid = address != null && address.Trim().Length > 0 &&
|
||||
remote_path != null && remote_path.Trim().Length > 0;
|
||||
|
||||
if (UpdateAddProjectButtonEvent != null)
|
||||
UpdateAddProjectButtonEvent (fields_valid);
|
||||
}
|
||||
|
||||
|
||||
public void AddPageCompleted (string address, string path)
|
||||
{
|
||||
this.syncing_folder = Path.GetFileNameWithoutExtension (path);
|
||||
this.previous_address = address;
|
||||
this.previous_path = path;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
|
||||
// TODO: Remove events afterwards
|
||||
|
||||
Program.Controller.FolderFetched += delegate (string [] warnings) {
|
||||
} else {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Finished, warnings);
|
||||
|
||||
this.previous_address = "";
|
||||
this.syncing_folder = "";
|
||||
this.previous_url = "";
|
||||
SelectedPlugin = Plugins [0];
|
||||
};
|
||||
|
||||
Program.Controller.FolderFetchError += delegate (string remote_url) {
|
||||
Thread.Sleep (1000);
|
||||
this.previous_url = remote_url;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Error, null);
|
||||
|
||||
this.syncing_folder = "";
|
||||
};
|
||||
|
||||
Program.Controller.FolderFetching += delegate (double percentage) {
|
||||
if (UpdateProgressBarEvent != null)
|
||||
UpdateProgressBarEvent (percentage);
|
||||
};
|
||||
|
||||
Program.Controller.FetchFolder (address, path);
|
||||
}
|
||||
|
||||
|
||||
public SparkleInvite PendingInvite = new SparkleInvite ("ssh://git@sparkleshare.org/",
|
||||
"/home/stuff/",
|
||||
"http://www.sparkleshare.org/");
|
||||
|
||||
public void InvitePageCompleted ()
|
||||
{
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
|
||||
if (!PendingInvite.Accept ()) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Error, null);
|
||||
|
||||
return;
|
||||
ChangePageEvent (PageType.Tutorial, null);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Remove events afterwards
|
||||
|
||||
Program.Controller.FolderFetched += delegate (string [] warnings) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Finished, warnings);
|
||||
|
||||
this.previous_address = "";
|
||||
this.syncing_folder = "";
|
||||
this.previous_url = "";
|
||||
SelectedPlugin = Plugins [0];
|
||||
};
|
||||
|
||||
Program.Controller.FolderFetchError += delegate (string remote_url) {
|
||||
Thread.Sleep (1000);
|
||||
this.previous_url = remote_url;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Error, null);
|
||||
|
||||
this.syncing_folder = "";
|
||||
};
|
||||
|
||||
Program.Controller.FolderFetching += delegate (double percentage) {
|
||||
if (UpdateProgressBarEvent != null)
|
||||
UpdateProgressBarEvent (percentage);
|
||||
};
|
||||
|
||||
Program.Controller.FetchFolder (PendingInvite.Address, PendingInvite.RemotePath);
|
||||
}
|
||||
|
||||
|
||||
public void ErrorPageCompleted ()
|
||||
{
|
||||
if (ChangePageEvent == null)
|
||||
return;
|
||||
|
||||
if (PendingInvite != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
else
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
}
|
||||
|
||||
|
||||
public void SyncingCancelled ()
|
||||
{
|
||||
Program.Controller.StopFetcher ();
|
||||
|
||||
if (ChangePageEvent == null)
|
||||
return;
|
||||
|
||||
if (PendingInvite != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
else
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
}
|
||||
|
||||
|
||||
// TODO: public void WindowClosed () { }
|
||||
|
||||
|
||||
public void FinishedPageCompleted ()
|
||||
{
|
||||
this.previous_address = "";
|
||||
this.previous_path = "";
|
||||
Program.Controller.UpdateState ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -393,6 +243,155 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void CheckAddPage (string address, string remote_path, int selected_plugin)
|
||||
{
|
||||
if (SelectedPluginIndex != selected_plugin)
|
||||
SelectedPluginChanged (selected_plugin);
|
||||
|
||||
address = address.Trim ();
|
||||
remote_path = remote_path.Trim ();
|
||||
|
||||
bool fields_valid = address != null && address.Trim().Length > 0 &&
|
||||
remote_path != null && remote_path.Trim().Length > 0;
|
||||
|
||||
if (UpdateAddProjectButtonEvent != null)
|
||||
UpdateAddProjectButtonEvent (fields_valid);
|
||||
}
|
||||
|
||||
|
||||
public void AddPageCompleted (string address, string path)
|
||||
{
|
||||
SyncingFolder = Path.GetFileNameWithoutExtension (path);
|
||||
PreviousAddress = address;
|
||||
PreviousPath = path;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
|
||||
// TODO: Remove events afterwards
|
||||
|
||||
Program.Controller.FolderFetched += delegate (string [] warnings) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Finished, warnings);
|
||||
|
||||
PreviousAddress = "";
|
||||
SyncingFolder = "";
|
||||
PreviousUrl = "";
|
||||
SelectedPlugin = Plugins [0];
|
||||
};
|
||||
|
||||
Program.Controller.FolderFetchError += delegate (string remote_url) {
|
||||
Thread.Sleep (1000);
|
||||
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 (address, path);
|
||||
}
|
||||
|
||||
|
||||
// TODO: trailing slash should work
|
||||
public SparkleInvite PendingInvite = new SparkleInvite ("ssh://git@github.com/",
|
||||
"/hbons/Stuff", "http://www.sparkleshare.org/");
|
||||
|
||||
public void InvitePageCompleted ()
|
||||
{
|
||||
SyncingFolder = Path.GetFileNameWithoutExtension (PendingInvite.RemotePath);
|
||||
PreviousAddress = PendingInvite.Address;
|
||||
PreviousPath = PendingInvite.RemotePath;
|
||||
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Syncing, null);
|
||||
|
||||
if (!PendingInvite.Accept ()) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (PageType.Error, null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Remove events afterwards
|
||||
|
||||
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) {
|
||||
Thread.Sleep (1000);
|
||||
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, PendingInvite.RemotePath);
|
||||
}
|
||||
|
||||
|
||||
public void SyncingCancelled ()
|
||||
{
|
||||
Program.Controller.StopFetcher ();
|
||||
|
||||
if (ChangePageEvent == null)
|
||||
return;
|
||||
|
||||
if (PendingInvite != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
else
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
}
|
||||
|
||||
|
||||
public void ErrorPageCompleted ()
|
||||
{
|
||||
if (ChangePageEvent == null)
|
||||
return;
|
||||
|
||||
if (PendingInvite != null)
|
||||
ChangePageEvent (PageType.Invite, null);
|
||||
else
|
||||
ChangePageEvent (PageType.Add, null);
|
||||
}
|
||||
|
||||
|
||||
public void FinishPageCompleted ()
|
||||
{
|
||||
PreviousAddress = "";
|
||||
PreviousPath = "";
|
||||
|
||||
Program.Controller.UpdateState ();
|
||||
|
||||
if (HideWindowEvent != null)
|
||||
HideWindowEvent ();
|
||||
}
|
||||
|
||||
|
||||
private bool IsValidEmail (string email)
|
||||
{
|
||||
Regex regex = new Regex (@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$",
|
||||
|
|
|
@ -129,5 +129,11 @@ namespace SparkleShare {
|
|||
UpdateMenuEvent (IconState.Error);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void AddHostedProjectClicked ()
|
||||
{
|
||||
Program.Controller.ShowSetupWindow (PageType.Add);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue