public virtual void Initialize() { SparklePlugin.PluginsPath = PluginsPath; InstallProtocolHandler(); // Create the SparkleShare folder and add it to the bookmarks if (CreateSparkleShareFolder()) { AddToBookmarks(); } if (FirstRun) { this.config.SetConfigOption("notifications", bool.TrueString); } else { string keys_path = Path.GetDirectoryName(this.config.FullPath); string key_file_path = ""; 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); break; } } if (!string.IsNullOrEmpty(key_file_path)) { string public_key_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(public_key_file_path) && !File.Exists(link_code_file_path)) { File.Copy(public_key_file_path, link_code_file_path, true); } CurrentUser.PublicKey = File.ReadAllText(public_key_file_path); } SparkleKeys.ListPrivateKeys(); } // Watch the SparkleShare folder this.watcher = new FileSystemWatcher() { Filter = "*", IncludeSubdirectories = false, Path = FoldersPath }; watcher.Deleted += OnFolderActivity; watcher.Created += OnFolderActivity; watcher.Renamed += OnFolderActivity; watcher.EnableRaisingEvents = true; }
public virtual void Initialize() { SparkleLogger.LogInfo("Environment", "SparkleShare version: " + SparkleLib.SparkleBackend.Version + ", Operating system: " + SparkleLib.SparkleBackend.Platform + " (" + Environment.OSVersion + ")"); SparklePlugin.PluginsPath = PluginsPath; InstallProtocolHandler(); try { if (CreateSparkleShareFolder()) { AddToBookmarks(); } } catch (DirectoryNotFoundException) { this.lost_folders_path = true; } bool keys_imported = false; if (FirstRun) { Config.SetConfigOption("notifications", bool.TrueString); } else { string keys_path = Path.GetDirectoryName(Config.FullPath); string key_file_path = ""; foreach (string file_path in Directory.GetFiles(keys_path)) { string file_name = Path.GetFileName(file_path); if (file_name.EndsWith(".key")) { key_file_path = Path.Combine(keys_path, file_name); // Replace spaces with underscores in old keys if (file_name.Contains(" ")) { string new_file_name = file_name.Replace(" ", "_"); File.Move(key_file_path, Path.Combine(keys_path, new_file_name)); File.Move(key_file_path + ".pub", Path.Combine(keys_path, new_file_name + ".pub")); key_file_path = Path.Combine(keys_path, new_file_name); } SparkleKeys.ImportPrivateKey(key_file_path); keys_imported = true; break; } } if (keys_imported) { CurrentUser.PublicKey = File.ReadAllText(key_file_path + ".pub"); } else { string [] key_pair = CreateKeys(); SparkleKeys.ImportPrivateKey(key_pair [0]); CurrentUser.PublicKey = File.ReadAllText(key_pair [1]); } SparkleKeys.ListPrivateKeys(); FolderListChanged(); // FIXME: Hacky way to update status icon menu to show the key } // Watch the SparkleShare folder this.watcher = new FileSystemWatcher() { Filter = "*", IncludeSubdirectories = false, Path = FoldersPath }; watcher.Created += OnFolderActivity; // FIXME watcher.Deleted += OnFolderActivity; // FIXME watcher.Renamed += OnFolderActivity; watcher.EnableRaisingEvents = true; }
public virtual void Initialize() { SparklePlugin.PluginsPath = PluginsPath; InstallProtocolHandler(); try { // Create the SparkleShare folder and add it to the bookmarks if (CreateSparkleShareFolder()) { AddToBookmarks(); } } catch (DirectoryNotFoundException) { this.lost_folders_path = true; } if (FirstRun) { this.config.SetConfigOption("notifications", bool.TrueString); } else { string keys_path = Path.GetDirectoryName(this.config.FullPath); string key_file_path = ""; foreach (string file_path in Directory.GetFiles(keys_path)) { string file_name = Path.GetFileName(file_path); if (file_name.EndsWith(".key")) { key_file_path = Path.Combine(keys_path, file_name); // Replace spaces with underscores in old keys if (file_name.Contains(" ")) { string new_file_name = file_name.Replace(" ", "_"); File.Move(key_file_path, Path.Combine(keys_path, new_file_name)); File.Move(key_file_path + ".pub", Path.Combine(keys_path, new_file_name + ".pub")); key_file_path = Path.Combine(keys_path, new_file_name); } SparkleKeys.ImportPrivateKey(key_file_path); break; } } CurrentUser.PublicKey = File.ReadAllText(key_file_path + ".pub"); SparkleKeys.ListPrivateKeys(); } // Watch the SparkleShare folder this.watcher = new FileSystemWatcher() { Filter = "*", IncludeSubdirectories = false, Path = FoldersPath }; watcher.Created += OnFolderActivity; // FIXME watcher.Deleted += OnFolderActivity; // FIXME watcher.Renamed += OnFolderActivity; watcher.EnableRaisingEvents = true; }