diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 4a30d5a2..7d5cb02e 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -200,31 +200,27 @@ namespace SparkleShare { this.config.SetConfigOption ("notifications", bool.TrueString); } else { - string keys_path = Path.GetDirectoryName (this.config.FullPath); - string key_file_name = "sparkleshare." + CurrentUser.Email + ".key"; - string key_file_path = Path.Combine (keys_path, key_file_name); + string keys_path = Path.GetDirectoryName (this.config.FullPath); + string key_file_path = ""; - // Be forgiving about the key's file name - if (!File.Exists (key_file_path)) { - foreach (string file_name in Directory.GetFiles (keys_path)) { - if (file_name.StartsWith ("sparkleshare") && - file_name.EndsWith (".key")) { - - key_file_path = Path.Combine (keys_path, file_name); - break; - } + foreach (string file_name in Directory.GetFiles (keys_path)) { + if (file_name.EndsWith (".key")) { + key_file_path = Path.Combine (keys_path, file_name); + SparkleKeys.ImportPrivateKey (key_file_path); } } - string pubkey_file_path = key_file_path + ".pub"; - string link_code_file_path = Path.Combine (FoldersPath, CurrentUser.Name + "'s link code.txt"); + if (!string.IsNullOrEmpty (key_file_path)) { + string pubkey_file_path = key_file_path + ".pub"; + string link_code_file_path = Path.Combine (FoldersPath, CurrentUser.Name + "'s link code.txt"); - // Create an easily accessible copy of the public - // key in the user's SparkleShare folder - if (File.Exists (pubkey_file_path) && !File.Exists (link_code_file_path)) - File.Copy (pubkey_file_path, link_code_file_path, true /* Overwriting allowed */ ); + // Create an easily accessible copy of the public + // key in the user's SparkleShare folder + if (File.Exists (pubkey_file_path) && !File.Exists (link_code_file_path)) + File.Copy (pubkey_file_path, link_code_file_path, true /* Overwriting allowed */ ); + + } - SparkleKeys.ImportPrivateKey (key_file_path); SparkleKeys.ListPrivateKeys (); } diff --git a/SparkleShare/SparkleSetupController.cs b/SparkleShare/SparkleSetupController.cs index d46a9e7a..7f89a0dc 100755 --- a/SparkleShare/SparkleSetupController.cs +++ b/SparkleShare/SparkleSetupController.cs @@ -281,22 +281,21 @@ namespace SparkleShare { { Program.Controller.CurrentUser = new SparkleUser (full_name, email); - new Thread ( - new ThreadStart (delegate { - string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath); - string key_file_name = "sparkleshare." + Program.Controller.CurrentUser.Email; + new Thread (() => { + string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath); + string key_file_name = DateTime.Now.ToString ("YYYY-MM-dd HH\\hmm"); - string [] key_pair = SparkleKeys.GenerateKeyPair (keys_path, key_file_name); - SparkleKeys.ImportPrivateKey (key_pair [0]); + string [] key_pair = SparkleKeys.GenerateKeyPair (keys_path, key_file_name); + SparkleKeys.ImportPrivateKey (key_pair [0]); - string link_code_file_path = Path.Combine (Program.Controller.FoldersPath, - Program.Controller.CurrentUser.Name + "'s link code.txt"); + string link_code_file_path = Path.Combine (Program.Controller.FoldersPath, + Program.Controller.CurrentUser.Name + "'s link code.txt"); - // Create an easily accessible copy of the public - // key in the user's SparkleShare folder - File.Copy (key_pair [1], link_code_file_path, true); - }) - ).Start (); + // Create an easily accessible copy of the public + // key in the user's SparkleShare folder + File.Copy (key_pair [1], link_code_file_path, true); + + }).Start (); TutorialPageNumber = 1; @@ -421,12 +420,11 @@ namespace SparkleShare { Program.Controller.FolderFetchError += AddPageFetchErrorDelegate; Program.Controller.FolderFetching += SyncingPageFetchingDelegate; - new Thread ( - new ThreadStart (delegate { - Program.Controller.StartFetcher (address, SelectedPlugin.Fingerprint, remote_path, - SelectedPlugin.AnnouncementsUrl, this.fetch_prior_history); - }) - ).Start (); + new Thread (() => { + Program.Controller.StartFetcher (address, SelectedPlugin.Fingerprint, remote_path, + SelectedPlugin.AnnouncementsUrl, this.fetch_prior_history); + + }).Start (); } // The following private methods are @@ -602,12 +600,11 @@ namespace SparkleShare { if (ChangePageEvent != null) ChangePageEvent (PageType.Syncing, null); - new Thread ( - new ThreadStart (delegate { - Thread.Sleep (1000); - Program.Controller.FinishFetcher (password); - }) - ).Start (); + new Thread (() => { + Thread.Sleep (1000); + Program.Controller.FinishFetcher (password); + + }).Start (); } diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/SparkleStatusIconController.cs index 91d56050..7e7f4259 100755 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/SparkleStatusIconController.cs @@ -254,11 +254,10 @@ namespace SparkleShare { public void OpenRecentEventsClicked () { - new Threading.Thread ( - new Threading.ThreadStart (delegate { - Program.Controller.ShowEventLogWindow (); - }) - ).Start (); + new Threading.Thread (() => { + Program.Controller.ShowEventLogWindow (); + + }).Start (); }