diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 90f6a925..faa4f31b 100755 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -75,7 +75,31 @@ namespace SparkleShare { public override void InstallProtocolHandler () { - // TODO + // sparkleshare-invite-opener.desktop launches the handler on newer + // systems (like GNOME 3) that implement the last freedesktop.org specs. + // For GNOME 2 however we need to tell gconf about the protocol manually + Console.WriteLine (); + try { + // Add the handler to gconf... + Process process = new Process (); + process.StartInfo.FileName = "gconftool-2"; + process.StartInfo.Arguments = + "-s /desktop/gnome/url-handlers/sparkleshare/command 'sparkleshare open %s' --type String"; + + process.Start (); + process.WaitForExit (); + + + // ...and enable it + process.StartInfo.Arguments = + "-s /desktop/gnome/url-handlers/sparkleshare/enabled --type Boolean true"; + + process.Start (); + process.WaitForExit (); + + } catch { + // Pity... + } } diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 9855f5bf..ec5bd2dd 100755 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -174,6 +174,17 @@ namespace SparkleShare { if (InviteReceived != null) { 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 (1 * 250); + invite = new SparkleInvite (args.FullPath); + tries++; + if (tries > 20) + break; + } + if (invite.IsValid) { InviteReceived (invite); diff --git a/SparkleShare/SparkleEventLog.cs b/SparkleShare/SparkleEventLog.cs index 833be1d4..b59040c1 100755 --- a/SparkleShare/SparkleEventLog.cs +++ b/SparkleShare/SparkleEventLog.cs @@ -248,8 +248,7 @@ namespace SparkleShare { new string [] {SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status", "document-moved.png"}.Combine ()); -Console.WriteLine (html); - + Application.Invoke (delegate { this.spinner.Stop (); this.web_view.LoadString (html, null, null, "file://"); diff --git a/SparkleShare/SparkleInvite.cs b/SparkleShare/SparkleInvite.cs index 2252c242..c5c81469 100644 --- a/SparkleShare/SparkleInvite.cs +++ b/SparkleShare/SparkleInvite.cs @@ -29,8 +29,8 @@ namespace SparkleShare { public string Address { get; private set; } public string RemotePath { get; private set; } - public Uri AcceptUrl { get; private set; } - public Uri AnnouncementsUrl { get; private set; } + public string AcceptUrl { get; private set; } + public string AnnouncementsUrl { get; private set; } public bool IsValid { @@ -68,6 +68,7 @@ namespace SparkleShare { try { xml_document.Load (xml_file_path); + node = xml_document.SelectSingleNode ("/sparkleshare/invite/address/text()"); if (node != null) { address = node.Value; } @@ -80,6 +81,7 @@ namespace SparkleShare { node = xml_document.SelectSingleNode ("/sparkleshare/invite/announcements_url/text()"); if (node != null) { announcements_url = node.Value; } + Initialize (address, remote_path, accept_url, announcements_url); } catch (XmlException e) { @@ -91,7 +93,7 @@ namespace SparkleShare { public bool Accept () { - if (AcceptUrl == null) + if (string.IsNullOrEmpty (AcceptUrl)) return true; try { @@ -133,8 +135,8 @@ namespace SparkleShare { { Address = address; RemotePath = remote_path; - AcceptUrl = new Uri (accept_url); - AnnouncementsUrl = new Uri (announcements_url); + AcceptUrl = accept_url; + AnnouncementsUrl = announcements_url; } } } diff --git a/SparkleShare/SparkleSetup.cs b/SparkleShare/SparkleSetup.cs index a463e52e..a8a072b9 100755 --- a/SparkleShare/SparkleSetup.cs +++ b/SparkleShare/SparkleSetup.cs @@ -330,7 +330,7 @@ namespace SparkleShare { case PageType.Invite: { - Header = _("You've reveived an invite!"); + Header = _("You've received an invite!"); Description = _("Do you want to add this project to SparkleShare?"); diff --git a/SparkleShare/SparkleSetupController.cs b/SparkleShare/SparkleSetupController.cs index c175a4ae..1e2be709 100755 --- a/SparkleShare/SparkleSetupController.cs +++ b/SparkleShare/SparkleSetupController.cs @@ -135,6 +135,8 @@ namespace SparkleShare { Program.Controller.InviteReceived += delegate (SparkleInvite invite) { + PendingInvite = invite; + if (ChangePageEvent != null) ChangePageEvent (PageType.Invite, null); diff --git a/SparkleShare/sparkleshare-invite-open.cs b/SparkleShare/sparkleshare-invite-open.cs deleted file mode 100644 index 7a8b812f..00000000 --- a/SparkleShare/sparkleshare-invite-open.cs +++ /dev/null @@ -1,66 +0,0 @@ -// SparkleShare, a collaboration and sharing tool. -// Copyright (C) 2010 Hylke Bons -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - - -using System; -using System.IO; -using System.Net; - -namespace SparkleShare { - - public class SparkleShare { - - public static void Main (string [] args) { - - new SparkleInviteOpen (args [0]); - } - } - - - public class SparkleInviteOpen { - - public SparkleInviteOpen (string url) - { - string safe_url = url.Replace ("sparkleshare://", "https://"); - string unsafe_url = url.Replace ("sparkleshare://", "http://"); - string xml = ""; - - WebClient web_client = new WebClient (); - - try { - xml = web_client.DownloadString (safe_url); - - } catch { - Console.WriteLine ("Failed downloading invite: " + safe_url); - - try { - xml = web_client.DownloadString (safe_url); - - } catch { - Console.WriteLine ("Failed downloading invite: " + unsafe_url); - } - } - - string home_path = Environment.GetFolderPath (Environment.SpecialFolder.Personal); - string target_path = Path.Combine (home_path, "SparkleShare"); - - if (xml.Contains ("")) { - File.WriteAllText (target_path, xml); - Console.WriteLine ("Downloaded invite: " + safe_url); - } - } - } -} diff --git a/SparkleShare/sparkleshare-invite-opener.desktop b/SparkleShare/sparkleshare-invite-opener.desktop index d0e993dc..b2cc168a 100644 --- a/SparkleShare/sparkleshare-invite-opener.desktop +++ b/SparkleShare/sparkleshare-invite-opener.desktop @@ -4,3 +4,4 @@ Name=SparkleShareInviteOpener Exec=sparkleshare open %U Terminal=false MimeType=application/x-sparkleshare;x-scheme-handler/sparkleshare; +NoDisplay=true diff --git a/SparkleShare/sparkleshare.in b/SparkleShare/sparkleshare.in index 7480b1fc..4fd7fe8f 100755 --- a/SparkleShare/sparkleshare.in +++ b/SparkleShare/sparkleshare.in @@ -62,7 +62,8 @@ case $1 in start ;; open|--open) - curl -o ~/SparkleShare/`date -u +%N`.xml `echo $2 | sed s/sparkleshare:/https:/` + invite=`date -u +%N` + curl -o ~/SparkleShare/$invite.xml `echo $2 | sed s/sparkleshare:/http:/` ;; help|--help|-h) mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" --help