From 480af047e42a73a46045d9710c4557ee611ab247 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 18 Feb 2012 18:30:31 +0100 Subject: [PATCH] mac: Add SparkleShareInviteOpener.app to the bundle --- SparkleShare/Mac/SparkleShare.csproj | 4 +- SparkleShare/sparkleshare-invite-open.cs | 66 ++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 SparkleShare/sparkleshare-invite-open.cs diff --git a/SparkleShare/Mac/SparkleShare.csproj b/SparkleShare/Mac/SparkleShare.csproj index 23783cbb..9afb571a 100755 --- a/SparkleShare/Mac/SparkleShare.csproj +++ b/SparkleShare/Mac/SparkleShare.csproj @@ -24,7 +24,7 @@ false - + @@ -59,7 +59,7 @@ False - + False ..\..\bin\SparkleLib.dll diff --git a/SparkleShare/sparkleshare-invite-open.cs b/SparkleShare/sparkleshare-invite-open.cs new file mode 100644 index 00000000..7a8b812f --- /dev/null +++ b/SparkleShare/sparkleshare-invite-open.cs @@ -0,0 +1,66 @@ +// 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); + } + } + } +}