Beispiel #1
0
        public void UIHasLoaded()
        {
            if (this.lost_folders_path)
            {
                Program.UI.Bubbles.Controller.ShowBubble("Where's your SparkleShare folder?",
                                                         "Did you put it on a detached drive?", null);

                Environment.Exit(-1);
            }

            if (FirstRun)
            {
                ShowSetupWindow(PageType.Setup);

                new Thread(() => {
                    string [] key_pair = CreateKeys();

                    SparkleKeys.ImportPrivateKey(key_pair [0]);
                    CurrentUser.PublicKey = File.ReadAllText(key_pair [1]);

                    FolderListChanged();  // FIXME: Hacky way to update status icon menu to show the key
                }).Start();
            }
            else
            {
                new Thread(() => {
                    StartupInviteScan();
                    CheckRepositories();
                    RepositoriesLoaded = true;
                    UpdateState();
                }).Start();
            }
        }
Beispiel #2
0
        private string [] CreateKeys()
        {
            string keys_path     = Path.GetDirectoryName(SparkleConfig.DefaultConfig.FullPath);
            string key_file_name = DateTime.Now.ToString("yyyy-MM-dd_HH\\hmm");

            return(SparkleKeys.GenerateKeyPair(keys_path, key_file_name));
        }
Beispiel #3
0
        public void UIHasLoaded()
        {
            if (this.lost_folders_path)
            {
                Program.UI.Bubbles.Controller.ShowBubble("Where's your SparkleShare folder?",
                                                         "Did you put it on a detached drive?", null);

                Environment.Exit(-1);
            }

            if (FirstRun)
            {
                ShowSetupWindow(PageType.Setup);

                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]);

                    CurrentUser.PublicKey = File.ReadAllText(key_pair [1]);
                    FolderListChanged();  // FIXME: Hacky way to update status icon menu to show the key
                }).Start();
            }
            else
            {
                new Thread(() => {
                    StartupInviteScan();
                    CheckRepositories();
                    RepositoriesLoaded = true;
                    UpdateState();
                }).Start();
            }
        }
Beispiel #4
0
        public void UIHasLoaded()
        {
            if (FirstRun)
            {
                ShowSetupWindow(PageType.Setup);

                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 link_code_file_path = Path.Combine(Program.Controller.FoldersPath, "Your 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();
            }
            else
            {
                new Thread(() => {
                    CheckRepositories();
                    RepositoriesLoaded = true;
                    FolderListChanged();
                }).Start();
            }
        }
        public void SetupPageCompleted(string full_name, string email)
        {
            Program.Controller.CurrentUser = new SparkleUser(full_name, 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 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();

            TutorialPageNumber = 1;
            ChangePageEvent(PageType.Tutorial, null);
        }
Beispiel #6
0
        public void UIHasLoaded()
        {
            if (this.lost_folders_path)
            {
                Program.UI.Bubbles.Controller.ShowBubble("Where's your SparkleShare folder?",
                                                         "Did you put it on a detached drive?", null);

                Environment.Exit(-1);
            }

            if (FirstRun)
            {
                ShowSetupWindow(PageType.Setup);

                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 link_code_file_path = Path.Combine(Program.Controller.FoldersPath, "Your 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();
            }
            else
            {
                new Thread(() => {
                    CheckRepositories();
                    RepositoriesLoaded = true;
                    FolderListChanged();
                    UpdateState();
                }).Start();
            }
        }
Beispiel #7
0
        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;
        }
Beispiel #8
0
        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;
        }
Beispiel #9
0
        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;
        }