diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index a8bcec9f..a68cb9ab 100755 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -626,12 +626,11 @@ namespace SparkleLib { if (match.Success) { SparkleChangeSet change_set = new SparkleChangeSet (); - change_set.Folder = Name; - change_set.Revision = match.Groups [1].Value; - change_set.User.Name = match.Groups [2].Value; - change_set.User.Email = match.Groups [3].Value; - change_set.IsMagical = is_merge_commit; - change_set.Url = Url; + change_set.Folder = Name; + change_set.Revision = match.Groups [1].Value; + change_set.User = new SparkleUser (match.Groups [2].Value, match.Groups [3].Value); + change_set.IsMagical = is_merge_commit; + change_set.Url = Url; change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value), int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value), diff --git a/SparkleLib/Makefile.am b/SparkleLib/Makefile.am index 30484fe1..ddd7498c 100755 --- a/SparkleLib/Makefile.am +++ b/SparkleLib/Makefile.am @@ -17,6 +17,7 @@ SOURCES = \ SparkleListenerFactory.cs \ SparkleListenerTcp.cs \ SparkleRepoBase.cs \ + SparkleUser.cs \ SparkleWatcher.cs diff --git a/SparkleLib/SparkleChangeSet.cs b/SparkleLib/SparkleChangeSet.cs index bc173ac3..ef29d56f 100755 --- a/SparkleLib/SparkleChangeSet.cs +++ b/SparkleLib/SparkleChangeSet.cs @@ -84,22 +84,6 @@ namespace SparkleLib { } - public class SparkleUser { - - public string Name; - public string Email; - - public string PublicKey; - - - public SparkleUser (string name, string email) - { - Name = name; - Email = email; - } - } - - public class SparkleFolder { public string Name; diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index 405f05c4..ca01f402 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -145,7 +145,16 @@ namespace SparkleLib { XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()"); string email = email_node.Value; - return new SparkleUser (name, email); + string pubkey_file_path = Path.Combine ( + Path.GetDirectoryName (FullPath), + "sparkleshare." + email + ".key.pub" + ); + + SparkleUser user = new SparkleUser (name, email) { + PublicKey = File.ReadAllText (pubkey_file_path) + }; + + return user; } set { diff --git a/SparkleLib/SparkleUser.cs b/SparkleLib/SparkleUser.cs new file mode 100644 index 00000000..ef44bc41 --- /dev/null +++ b/SparkleLib/SparkleUser.cs @@ -0,0 +1,36 @@ +// 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; + +namespace SparkleLib { + + public class SparkleUser { + + public readonly string Name; + public readonly string Email; + + public string PublicKey; + + + public SparkleUser (string name, string email) + { + Name = name; + Email = email; + } + } +} diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index ac5cac40..f9279baf 100755 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -106,7 +106,7 @@ namespace SparkleShare { { } - + public virtual void Initialize () { InstallLauncher (); diff --git a/SparkleShare/SparkleInvite.cs b/SparkleShare/SparkleInvite.cs index 0b56ef56..2a219f78 100644 --- a/SparkleShare/SparkleInvite.cs +++ b/SparkleShare/SparkleInvite.cs @@ -16,7 +16,9 @@ using System; +using System.IO; using System.Net; +using System.Text; using System.Xml; using SparkleLib; @@ -77,17 +79,34 @@ namespace SparkleShare { public bool Accept () { - WebClient web_client = new WebClient (); - try { - web_client.DownloadData (AcceptUrl); - SparkleHelpers.DebugInfo ("Invite", "Uploaded public key"); + WebRequest request = WebRequest.Create (AcceptUrl); - return true; + request.Method = "POST"; + request.ContentType = "application/x-www-form-urlencoded"; + string post_data = "pubkey=" + SparkleConfig.DefaultConfig.User.PublicKey; + byte [] post_bytes = Encoding.UTF8.GetBytes (post_data); + request.ContentLength = post_bytes.Length; + + Stream data_stream = request.GetRequestStream (); + data_stream.Write (post_bytes, 0, post_bytes.Length); + data_stream.Close (); + + WebResponse response = request.GetResponse (); + response.Close (); + + + if ((response as HttpWebResponse).StatusCode == HttpStatusCode.OK) { + SparkleHelpers.DebugInfo ("Invite", "Uploaded public key to " + AcceptUrl); + return true; + + } else { + SparkleHelpers.DebugInfo ("Invite", "Failed uploading public key to " + AcceptUrl); + return false; + } } catch (WebException e) { - SparkleHelpers.DebugInfo ("Invite", - "Failed uploading public key: " + e.Message); + SparkleHelpers.DebugInfo ("Invite", "Failed uploading public key to " + AcceptUrl + ": " + e.Message); return false; }