From e68a832aecf1e95f1383a615dbda7cf4c6f10c4a Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 19 Feb 2012 16:00:41 +0100 Subject: [PATCH] controller: add abstract method InstallProtocolHandler () --- SparkleShare/Mac/SparkleController.cs | 6 +++ SparkleShare/Mac/SparkleStatusIcon.cs | 4 +- SparkleShare/SparkleController.cs | 34 ------------- SparkleShare/SparkleControllerBase.cs | 55 ++++++++++++--------- SparkleShare/SparkleStatusIcon.cs | 4 +- SparkleShare/SparkleStatusIconController.cs | 20 ++++++-- 6 files changed, 57 insertions(+), 66 deletions(-) diff --git a/SparkleShare/Mac/SparkleController.cs b/SparkleShare/Mac/SparkleController.cs index d0fb3cb2..1f4daa3b 100755 --- a/SparkleShare/Mac/SparkleController.cs +++ b/SparkleShare/Mac/SparkleController.cs @@ -113,6 +113,12 @@ namespace SparkleShare { // N/A } + + public override void InstallProtocolHandler () + { + // We ship SparkleShareInviteHandler.app in the bundle + } + // Adds the SparkleShare folder to the user's // list of bookmarked places diff --git a/SparkleShare/Mac/SparkleStatusIcon.cs b/SparkleShare/Mac/SparkleStatusIcon.cs index c539859e..d370ac3b 100755 --- a/SparkleShare/Mac/SparkleStatusIcon.cs +++ b/SparkleShare/Mac/SparkleStatusIcon.cs @@ -180,7 +180,7 @@ namespace SparkleShare { }; FolderMenuItem.Activated += delegate { - Program.Controller.OpenSparkleShareFolder (); + Controller.SparkleShareClicked (); }; FolderMenuItem.Image = SparkleShareImage; @@ -314,7 +314,7 @@ namespace SparkleShare { private EventHandler OpenFolderDelegate (string name) { return delegate { - Program.Controller.OpenSparkleShareFolder (name); + Controller.SubfolderClicked (name); }; } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 3016430d..24354f5e 100755 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -74,40 +74,6 @@ namespace SparkleShare { SparkleHelpers.DebugInfo ("Controller", "Enabled autostart on login"); } } - - - // Installs a launcher so the user can launch SparkleShare - // from the Internet category if needed - public override void InstallLauncher () - { - string apps_path = - new string [] {SparkleConfig.DefaultConfig.HomePath, - ".local", "share", "applications"}.Combine (); - - string desktopfile_path = Path.Combine (apps_path, "sparkleshare.desktop"); - - if (!File.Exists (desktopfile_path)) { - if (!Directory.Exists (apps_path)) - Directory.CreateDirectory (apps_path); - - TextWriter writer = new StreamWriter (desktopfile_path); - writer.WriteLine ("[Desktop Entry]\n" + - "Type=Application\n" + - "Name=SparkleShare\n" + - "Comment=Share documents\n" + - "Exec=sparkleshare start\n" + - "Icon=folder-sparkleshare\n" + - "Terminal=false\n" + - "Categories=Network;"); - writer.Close (); - - // Give the launcher the right permissions so it can be launched by the user - UnixFileInfo file_info = new UnixFileInfo (desktopfile_path); - file_info.FileAccessPermissions = FileAccessPermissions.UserReadWriteExecute; - - SparkleHelpers.DebugInfo ("Controller", "Created '" + desktopfile_path + "'"); - } - } // Adds the SparkleShare folder to the user's diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 5e2507e8..37c5dcfc 100755 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -87,8 +87,34 @@ namespace SparkleShare { public event NoteNotificationRaisedEventHandler NoteNotificationRaised; public delegate void NoteNotificationRaisedEventHandler (SparkleUser user, string folder_name); + + // Path where the plugins are kept public abstract string PluginsPath { get; } + // Enables SparkleShare to start automatically at login + public abstract void EnableSystemAutostart (); + + // Installs a launcher so the user can launch SparkleShare + // from the Internet category if needed + public abstract void InstallLauncher (); + + // Installs the sparkleshare:// protocol handler + public abstract void InstallProtocolHandler (); + + // Adds the SparkleShare folder to the user's + // list of bookmarked places + public abstract void AddToBookmarks (); + + // Creates the SparkleShare folder in the user's home folder + public abstract bool CreateSparkleShareFolder (); + + // Opens the SparkleShare folder or an (optional) subfolder + public abstract void OpenSparkleShareFolder (string subfolder); + + // Opens a file with the appropriate application + public abstract void OpenFile (string url); + + private SparkleFetcherBase fetcher; private List failed_avatars = new List (); @@ -117,10 +143,13 @@ namespace SparkleShare { if (CreateSparkleShareFolder ()) AddToBookmarks (); - if (FirstRun) + if (FirstRun) { SparkleConfig.DefaultConfig.SetConfigOption ("notifications", bool.TrueString); - else + InstallProtocolHandler (); + + } else { ImportPrivateKey (); + } // Watch the SparkleShare folder FileSystemWatcher watcher = new FileSystemWatcher (SparkleConfig.DefaultConfig.FoldersPath) { @@ -534,28 +563,6 @@ namespace SparkleShare { } - // Creates a .desktop entry in autostart folder to - // start SparkleShare automatically at login - public abstract void EnableSystemAutostart (); - - // Installs a launcher so the user can launch SparkleShare - // from the Internet category if needed - public abstract void InstallLauncher (); - - // Adds the SparkleShare folder to the user's - // list of bookmarked places - public abstract void AddToBookmarks (); - - // Creates the SparkleShare folder in the user's home folder - public abstract bool CreateSparkleShareFolder (); - - // Opens the SparkleShare folder or an (optional) subfolder - public abstract void OpenSparkleShareFolder (string subfolder); - - // Opens a file with the appropriate application - public abstract void OpenFile (string url); - - // Fires events for the current syncing state public void UpdateState () { diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 559d9d20..5998fbfe 100755 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -209,7 +209,7 @@ namespace SparkleShare { }; folder_item.Activated += delegate { - Program.Controller.OpenSparkleShareFolder (); + Controller.SparkleShareClicked (); }; this.menu.Add (folder_item); @@ -318,7 +318,7 @@ namespace SparkleShare { private EventHandler OpenFolderDelegate (string name) { return delegate { - Program.Controller.OpenSparkleShareFolder (name); + Controller.SubfolderClicked (name); }; } diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/SparkleStatusIconController.cs index dcf383a2..05671aec 100755 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/SparkleStatusIconController.cs @@ -131,15 +131,21 @@ namespace SparkleShare { } - public void AddHostedProjectClicked () + public void SparkleShareClicked () { - Program.Controller.ShowSetupWindow (PageType.Add); + Program.Controller.OpenSparkleShareFolder (); } - public void AboutClicked () + public void SubfolderClicked (string subfolder) { - Program.Controller.ShowAboutWindow (); + Program.Controller.OpenSparkleShareFolder (subfolder); + } + + + public void AddHostedProjectClicked () + { + Program.Controller.ShowSetupWindow (PageType.Add); } @@ -147,5 +153,11 @@ namespace SparkleShare { { Program.Controller.ShowEventLogWindow (); } + + + public void AboutClicked () + { + Program.Controller.ShowAboutWindow (); + } } }