From 481b6ff6fe9a4434a8339a20b4750aa258206bc1 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 May 2011 01:02:48 +0100 Subject: [PATCH] controller: add back user email guessing from key file name --- SparkleShare/SparkleController.cs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 281cdadf..d61bcd47 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -776,14 +776,28 @@ namespace SparkleShare { get { string global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config.xml"); - if (!File.Exists (global_config_file_path)) + if (File.Exists (global_config_file_path)) { + XmlDocument xml = new XmlDocument(); + xml.Load (global_config_file_path); + + XmlNode node = xml.SelectSingleNode("//user/email/text()"); + return node.Value; + } else { + string keys_path = SparklePaths.SparkleKeysPath; + + if (!Directory.Exists (keys_path)) + return ""; + + foreach (string file_path in Directory.GetFiles (keys_path)) { + Regex regex = new Regex (@"sparkleshare\.(.+)\.key"); + Match match = regex.Match (Path.GetFileName (file_path)); + + if (match.Success) + return match.Groups [1].Value; + } + return ""; - - XmlDocument xml = new XmlDocument(); - xml.Load (global_config_file_path); - - XmlNode node = xml.SelectSingleNode("//user/email/text()"); - return node.Value; + } } set {