Inheritance: StateManagerBase, Library.Configuration.ISettings, IThisLock
        public MulticastMessageEditWindow(Tag tag, string comment, AmoebaManager amoebaManager)
        {
            _tag = tag;
            _amoebaManager = amoebaManager;

            _digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatures.ToArray());

            InitializeComponent();

            this.Title = LanguagesManager.Instance.MulticastMessageEditWindow_Title + " - " + MessageConverter.ToTagString(tag);

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _signatureComboBox.ItemsSource = _digitalSignatureCollection;
            _signatureComboBox.SelectedIndex = 0;

            _commentTextBox.Text = comment;

            _watchTimer = new WatchTimer(this.WatchThread, 0, 1000);
            this.Closed += (sender, e) => _watchTimer.Dispose();

            _textEditor_Helper.Setup(_textEditor);
        }
        public DownloadControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewModelCollection;

            _showDownloadItemThread = new Thread(this.ShowDownloadItem);
            _showDownloadItemThread.Priority = ThreadPriority.Highest;
            _showDownloadItemThread.IsBackground = true;
            _showDownloadItemThread.Name = "DownloadControl_ShowDownloadItemThread";
            _showDownloadItemThread.Start();

            _watchThread = new Thread(this.Watch);
            _watchThread.Priority = ThreadPriority.Highest;
            _watchThread.IsBackground = true;
            _watchThread.Name = "DownloadControl_WatchThread";
            _watchThread.Start();

            _searchRowDefinition.Height = new GridLength(0);

            LanguagesManager.UsingLanguageChangedEvent += this.LanguagesManager_UsingLanguageChangedEvent;
        }
        public LinkControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            InitializeComponent();

            _trustSignatureListView.ItemsSource = _trustSignatureCollection;
            _untrustSignatureListView.ItemsSource = _untrustSignatureCollection;

            this.Sort();

            _watchThread = new Thread(this.WatchThread);
            _watchThread.Priority = ThreadPriority.Highest;
            _watchThread.IsBackground = true;
            _watchThread.Name = "LinkControl_WatchThread";
            _watchThread.Start();

            _mainWindow._tabControl.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
            {
                if (e.OriginalSource != _mainWindow._tabControl) return;

                if (_mainWindow.SelectedTab == MainWindowTabType.Link)
                {
                    this.Update();
                }
            };

            _searchRowDefinition.Height = new GridLength(0);
        }
        public LinkOptionsWindow(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            InitializeComponent();

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _downloadSignatureCollection.AddRange(Settings.Instance.Global_TrustSignatures);

            _downloadSignatureListView.ItemsSource = _downloadSignatureCollection;

            foreach (var item in Settings.Instance.Global_LinkItems)
            {
                var viewModel = new LinkViewModel();
                viewModel.Signature = item.Signature;
                viewModel.TrustSignatures.AddRange(item.TrustSignatures);
                viewModel.DeleteSignatures.AddRange(item.DeleteSignatures);

                _uploadLinkCollection.Add(viewModel);
            }

            _uploadLinkListView.ItemsSource = _uploadLinkCollection;

            this.Sort();
        }
        public OverlayNetworkManager(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            _settings = new Settings();

            _amoebaManager.CreateCapEvent = this.CreateCap;
            _amoebaManager.AcceptCapEvent = this.AcceptCap;
        }
        public SeedInformationWindow(Seed seed, AmoebaManager amoebaManager)
        {
            if (seed == null) throw new ArgumentNullException(nameof(seed));
            if (amoebaManager == null) throw new ArgumentNullException(nameof(amoebaManager));

            _seed = seed;
            _amoebaManager = amoebaManager;

            InitializeComponent();

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            lock (_seed.ThisLock)
            {
                _nameTextBox.Text = _seed.Name;
                _keywordsTextBox.Text = string.Join(", ", _seed.Keywords);
                _signatureTextBox.Text = seed.Certificate?.ToString();
                _creationTimeTextBox.Text = seed.CreationTime.ToLocalTime().ToString(LanguagesManager.Instance.DateTime_StringFormat, System.Globalization.DateTimeFormatInfo.InvariantInfo);
                _lengthTextBox.Text = string.Format("{0} ({1:#,0} Byte)", NetworkConverter.ToSizeString(_seed.Length), _seed.Length);
            }

            _storeSignatureListView.ItemsSource = _storeSignatureCollection;

            try
            {
                _storeTabItem.Cursor = Cursors.Wait;

                Task.Run(() =>
                {
                    return this.GetSignature(_seed);
                }).ContinueWith(task =>
                {
                    foreach (var signature in task.Result)
                    {
                        _storeSignatureCollection.Add(signature);
                    }

                    _storeTabItem.Cursor = null;
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception)
            {

            }
        }
        public UploadListWindow(IEnumerable<string> filePaths, bool isShare, AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            var list = filePaths.ToList();
            list.Sort();

            foreach (var item in list)
            {
                _filePaths.Add(new UploadListViewItem() { Path = item });
            }

            _isShare = isShare;

            var digitalSignatureCollection = new List<object>();
            digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
            digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());

            InitializeComponent();

            _keywordsComboBox1.MaxLength = KeywordCollection.MaxKeywordLength;
            _keywordsComboBox2.MaxLength = KeywordCollection.MaxKeywordLength;
            _keywordsComboBox3.MaxLength = KeywordCollection.MaxKeywordLength;

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            if (Settings.Instance.Global_UploadKeywords.Count >= 1) _keywordsComboBox1.Text = Settings.Instance.Global_UploadKeywords[0];
            if (Settings.Instance.Global_UploadKeywords.Count >= 2) _keywordsComboBox2.Text = Settings.Instance.Global_UploadKeywords[1];
            if (Settings.Instance.Global_UploadKeywords.Count >= 3) _keywordsComboBox3.Text = Settings.Instance.Global_UploadKeywords[2];

            _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = "" });
            _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = "" });
            _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = "" });

            foreach (var item in Settings.Instance.Global_SearchKeywords) _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = item });
            foreach (var item in Settings.Instance.Global_SearchKeywords) _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = item });
            foreach (var item in Settings.Instance.Global_SearchKeywords) _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = item });

            _listView.ItemsSource = _filePaths;

            _signatureComboBox.ItemsSource = digitalSignatureCollection;
            if (digitalSignatureCollection.Count > 0) _signatureComboBox.SelectedIndex = 1;
        }
        public ShareControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewItemCollection;

            _showShareItemThread = new Thread(ShowShareItem);
            _showShareItemThread.Priority = ThreadPriority.Highest;
            _showShareItemThread.IsBackground = true;
            _showShareItemThread.Name = "ShareControl_ShowShareItemThread";
            _showShareItemThread.Start();
        }
        public UploadWindow(string filePath, bool isShare, AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;
            _filePath = filePath;
            _isShare = isShare;

            var digitalSignatureCollection = new List<object>();
            digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
            digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());

            InitializeComponent();

            _nameTextBox.MaxLength = Seed.MaxNameLength;
            _keywordsComboBox1.MaxLength = KeywordCollection.MaxKeywordLength;
            _keywordsComboBox2.MaxLength = KeywordCollection.MaxKeywordLength;
            _keywordsComboBox3.MaxLength = KeywordCollection.MaxKeywordLength;
            _commentTextBox.MaxLength = Seed.MaxCommentLength;

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _nameTextBox.Text = System.IO.Path.GetFileName(_filePath);

            if (Settings.Instance.Global_UploadKeywords.Count >= 1) _keywordsComboBox1.Text = Settings.Instance.Global_UploadKeywords[0];
            if (Settings.Instance.Global_UploadKeywords.Count >= 2) _keywordsComboBox2.Text = Settings.Instance.Global_UploadKeywords[1];
            if (Settings.Instance.Global_UploadKeywords.Count >= 3) _keywordsComboBox3.Text = Settings.Instance.Global_UploadKeywords[2];

            _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = "" });
            _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = "" });
            _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = "" });

            foreach (var item in Settings.Instance.Global_SearchKeywords) _keywordsComboBox1.Items.Add(new ComboBoxItem() { Content = item });
            foreach (var item in Settings.Instance.Global_SearchKeywords) _keywordsComboBox2.Items.Add(new ComboBoxItem() { Content = item });
            foreach (var item in Settings.Instance.Global_SearchKeywords) _keywordsComboBox3.Items.Add(new ComboBoxItem() { Content = item });

            _signatureComboBox.ItemsSource = digitalSignatureCollection;
            if (digitalSignatureCollection.Count > 0) _signatureComboBox.SelectedIndex = 1;

            _nameTextBox_TextChanged(null, null);
        }
        public UploadControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewItemCollection;

            _showUploadItemThread = new Thread(this.ShowUploadItem);
            _showUploadItemThread.Priority = ThreadPriority.Highest;
            _showUploadItemThread.IsBackground = true;
            _showUploadItemThread.Name = "UploadControl_ShowUploadItemThread";
            _showUploadItemThread.Start();

            LanguagesManager.UsingLanguageChangedEvent += this.LanguagesManager_UsingLanguageChangedEvent;
        }
示例#11
0
        public StoreControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            InitializeComponent();

            StoreDownloadControl storeDownloadControl = new StoreDownloadControl(this, _amoebaManager, _bufferManager);
            storeDownloadControl.Height = Double.NaN;
            storeDownloadControl.Width = Double.NaN;
            _storeDownloadTabItem.Content = storeDownloadControl;

            StoreUploadControl storeUploadControl = new StoreUploadControl(this, _amoebaManager, _bufferManager);
            storeUploadControl.Height = Double.NaN;
            storeUploadControl.Width = Double.NaN;
            _storeUploadTabItem.Content = storeUploadControl;

            LibraryControl libraryControl = new LibraryControl(this, _amoebaManager, _bufferManager);
            libraryControl.Height = Double.NaN;
            libraryControl.Width = Double.NaN;
            _libraryTabItem.Content = libraryControl;
        }
        public LinkOptionsWindow(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            InitializeComponent();

            try
            {
                foreach (var item in Settings.Instance.LinkOptionsWindow_DownloadLinkItems)
                {
                    var viewModel = new LinkViewModel();
                    viewModel.Signature = item.Signature;
                    viewModel.TrustSignatures.AddRange(item.TrustSignatures);

                    _downloadCollection.Add(viewModel);
                }

                foreach (var item in Settings.Instance.LinkOptionsWindow_UploadLinkItems)
                {
                    var viewModel = new LinkViewModel();
                    viewModel.Signature = item.Signature;
                    viewModel.TrustSignatures.AddRange(item.TrustSignatures);

                    _uploadCollection.Add(viewModel);
                }
            }
            catch (Exception)
            {
                throw;
            }

            _downloadLinkListView.ItemsSource = _downloadCollection;
            _uploadLinkListView.ItemsSource = _uploadCollection;

            this.Sort();
        }
        public AutoBaseNodeSettingManager(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            _settings = new Settings(this.ThisLock);
        }
示例#14
0
        private void Setting_Init()
        {
            NativeMethods.SetThreadExecutionState(ExecutionState.SystemRequired | ExecutionState.Continuous);

            {
                bool initFlag = false;

                _amoebaManager = new AmoebaManager(_serviceManager.Config.Cache.Path, _bufferManager);
                _amoebaManager.Load(_configrationDirectoryPaths["AmoebaManager"]);

                if (!File.Exists(Path.Combine(_serviceManager.Paths["Configuration"], "Amoeba.version")))
                {
                    initFlag = true;

                    {
                        var p = new System.Diagnostics.ProcessStartInfo();
                        p.UseShellExecute = true;
                        p.FileName = Path.GetFullPath(Path.Combine(_serviceManager.Paths["Core"], "Amoeba.exe"));
                        p.Arguments = "Relate on";

                        OperatingSystem osInfo = Environment.OSVersion;

                        // Windows Vista以上。
                        if (osInfo.Platform == PlatformID.Win32NT && osInfo.Version >= new Version(6, 0))
                        {
                            p.Verb = "runas";
                        }

                        try
                        {
                            System.Diagnostics.Process.Start(p);
                        }
                        catch (System.ComponentModel.Win32Exception)
                        {

                        }
                    }

                    {
                        // Amoeba
                        Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(AmoebaConverter.FromTagString("Tag:AAAABkFtb2ViYQEgyeOUT6BPIlq8Nfe1kndaS0ETNlmJY90wt-Osb-l2mZqamJsU")));
                        // Test
                        Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(AmoebaConverter.FromTagString("Tag:AAAABFRlc3QBIMEj2xDMP6_RAoVbePTEZwHz8Fcd29tqB9MY0JZyn6eS5iXI_A")));
                    }

                    {
                        Settings.Instance.Global_SearchKeywords.Clear();
                        Settings.Instance.Global_SearchKeywords.Add("Box");
                        Settings.Instance.Global_SearchKeywords.Add("Picture");
                        Settings.Instance.Global_SearchKeywords.Add("Movie");
                        Settings.Instance.Global_SearchKeywords.Add("Music");
                        Settings.Instance.Global_SearchKeywords.Add("Archive");
                        Settings.Instance.Global_SearchKeywords.Add("Document");
                        Settings.Instance.Global_SearchKeywords.Add("Executable");

                        Settings.Instance.Global_UploadKeywords.Clear();
                        Settings.Instance.Global_UploadKeywords.Add("Document");

                        var pictureSearchItem = new SearchItem() { Name = "Type - \"Picture\"" };
                        pictureSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(jpeg|jpg|jfif|gif|png|bmp)$", true)));

                        var movieSearchItem = new SearchItem() { Name = "Type - \"Movie\"" };
                        movieSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(mpeg|mpg|avi|divx|asf|wmv|rm|ogm|mov|flv|vob)$", true)));

                        var musicSearchItem = new SearchItem() { Name = "Type - \"Music\"" };
                        musicSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(mp3|wma|m4a|ogg|wav|mid|mod|flac|sid)$", true)));

                        var archiveSearchItem = new SearchItem() { Name = "Type - \"Archive\"" };
                        archiveSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(zip|rar|7z|lzh|iso|gz|bz|xz|tar|tgz|tbz|txz)$", true)));

                        var documentSearchItem = new SearchItem() { Name = "Type - \"Document\"" };
                        documentSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(doc|txt|pdf|odt|rtf)$", true)));

                        var executableSearchItem = new SearchItem() { Name = "Type - \"Executable\"" };
                        executableSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(exe|jar|sh|bat)$", true)));

                        Settings.Instance.SearchControl_SearchTreeItem.Children.Clear();
                        Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(pictureSearchItem));
                        Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(movieSearchItem));
                        Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(musicSearchItem));
                        Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(archiveSearchItem));
                        Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(documentSearchItem));
                        Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(executableSearchItem));
                    }

                    {
                        var tempBox = new Box();
                        tempBox.Name = "Temp";

                        var box = new Box();
                        box.Name = "Box";
                        box.Boxes.Add(tempBox);

                        var route = new Route();
                        route.Add(box.Name);

                        Settings.Instance.LibraryControl_Box = box;
                        Settings.Instance.LibraryControl_ExpandedPaths.Add(route);
                    }

                    _amoebaManager.ConnectionCountLimit = 32;

                    _amoebaManager.ListenUris.Clear();
                    _amoebaManager.ListenUris.Add(string.Format("tcp:{0}:{1}", IPAddress.Any.ToString(), _random.Next(1024, ushort.MaxValue + 1)));
                    _amoebaManager.ListenUris.Add(string.Format("tcp:[{0}]:{1}", IPAddress.IPv6Any.ToString(), _random.Next(1024, ushort.MaxValue + 1)));

                    var ipv4ConnectionFilter = new ConnectionFilter(ConnectionType.Tcp, null, new UriCondition(@"tcp:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3}).*"), null);
                    var ipv6ConnectionFilter = new ConnectionFilter(ConnectionType.Tcp, null, new UriCondition(@"tcp:\[(\d|:)*\].*"), null);
                    var tcpConnectionFilter = new ConnectionFilter(ConnectionType.Tcp, null, new UriCondition(@"tcp:.*"), null);
                    var torConnectionFilter = new ConnectionFilter(ConnectionType.Socks5Proxy, "tcp:127.0.0.1:19050", new UriCondition(@"tor:.*"), null);
                    var i2pConnectionFilter = new ConnectionFilter(ConnectionType.None, null, new UriCondition(@"i2p:.*"), null);

                    _amoebaManager.Filters.Clear();
                    _amoebaManager.Filters.Add(ipv4ConnectionFilter);
                    _amoebaManager.Filters.Add(ipv6ConnectionFilter);
                    _amoebaManager.Filters.Add(tcpConnectionFilter);
                    _amoebaManager.Filters.Add(torConnectionFilter);
                    _amoebaManager.Filters.Add(i2pConnectionFilter);

                    Directory.CreateDirectory(@"../Download");
                    _amoebaManager.DownloadDirectory = @"../Download";

                    if (CultureInfo.CurrentUICulture.Name == "ja-JP")
                    {
                        Settings.Instance.Global_UseLanguage = "Japanese";
                    }
                    else
                    {
                        Settings.Instance.Global_UseLanguage = "English";
                    }

                    // Trust.txtにあるノード情報を追加する。
                    if (File.Exists(Path.Combine(_serviceManager.Paths["Settings"], "Trust.txt")))
                    {
                        var list = new List<string>();

                        using (StreamReader reader = new StreamReader(Path.Combine(_serviceManager.Paths["Settings"], "Trust.txt"), new UTF8Encoding(false)))
                        {
                            string line;

                            while ((line = reader.ReadLine()) != null)
                            {
                                list.Add(line);
                            }
                        }

                        Settings.Instance.Global_TrustSignatures.AddRange(list);
                    }

                    // Nodes.txtにあるノード情報を追加する。
                    if (File.Exists(Path.Combine(_serviceManager.Paths["Settings"], "Nodes.txt")))
                    {
                        var list = new List<Node>();

                        using (StreamReader reader = new StreamReader(Path.Combine(_serviceManager.Paths["Settings"], "Nodes.txt"), new UTF8Encoding(false)))
                        {
                            string line;

                            while ((line = reader.ReadLine()) != null)
                            {
                                list.Add(AmoebaConverter.FromNodeString(line));
                            }
                        }

                        _amoebaManager.SetOtherNodes(list);
                    }
                }
                else
                {
                    Version version;

                    using (StreamReader reader = new StreamReader(Path.Combine(_serviceManager.Paths["Configuration"], "Amoeba.version"), new UTF8Encoding(false)))
                    {
                        version = new Version(reader.ReadLine());
                    }

                    if (version <= new Version(4, 0, 18))
                    {
                        // Covenant
                        Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(AmoebaConverter.FromTagString("Tag:AAAACENvdmVuYW50ASBJDZp3I-Ng-iWJwmq2Us-q45iWCQQpekfoZExA5Zom9EZtMqE")));
                    }
                }

                using (StreamWriter writer = new StreamWriter(Path.Combine(_serviceManager.Paths["Configuration"], "Amoeba.version"), false, new UTF8Encoding(false)))
                {
                    writer.WriteLine(_serviceManager.AmoebaVersion.ToString());
                }

                _connectionSettingManager = new ConnectionSettingManager(_amoebaManager);
                _connectionSettingManager.Load(_configrationDirectoryPaths["ConnectionSettingManager"]);

                _overlayNetworkManager = new OverlayNetworkManager(_amoebaManager, _bufferManager);
                _overlayNetworkManager.Load(_configrationDirectoryPaths["OverlayNetworkManager"]);

                _transferLimitManager = new TransfarLimitManager(_amoebaManager);
                _transferLimitManager.Load(_configrationDirectoryPaths["TransfarLimitManager"]);
                _transferLimitManager.Start();

                _catharsisManager = new CatharsisManager(_amoebaManager, _bufferManager, _serviceManager);
                _catharsisManager.Load(_configrationDirectoryPaths["CatharsisManager"]);

                if (initFlag)
                {
                    _catharsisManager.Save(_configrationDirectoryPaths["CatharsisManager"]);
                    _transferLimitManager.Save(_configrationDirectoryPaths["TransfarLimitManager"]);
                    _overlayNetworkManager.Save(_configrationDirectoryPaths["OverlayNetworkManager"]);
                    _connectionSettingManager.Save(_configrationDirectoryPaths["ConnectionSettingManager"]);
                    _amoebaManager.Save(_configrationDirectoryPaths["AmoebaManager"]);
                    Settings.Instance.Save(_configrationDirectoryPaths["Settings"]);
                }
            }
        }
示例#15
0
        public SeedStateCache(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            _watchTimer = new Timer(this.WatchTimer, null, 0, 1000 * 60);
        }
        public TransfarLimitManager(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            _settings = new Settings();
        }
        public OptionsWindow(AmoebaManager amoebaManager, ConnectionSettingManager connectionSettingManager, OverlayNetworkManager overlayNetworkManager, TransfarLimitManager transfarLimitManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;
            _connectionSettingManager = connectionSettingManager;
            _overlayNetworkManager = overlayNetworkManager;
            _transferLimitManager = transfarLimitManager;

            InitializeComponent();

            _baseNodeTextBox.MaxLength = UriCollection.MaxUriLength;

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            {
                foreach (var item in Enum.GetValues(typeof(ConnectionType)).Cast<ConnectionType>())
                {
                    _clientFiltersConnectionTypeComboBox.Items.Add(item);
                }

                foreach (var item in Enum.GetValues(typeof(TransferLimitType)).Cast<TransferLimitType>())
                {
                    _transferLimitTypeComboBox.Items.Add(item);
                }

                foreach (var u in new string[] { "Byte", "KB", "MB", "GB", "TB" })
                {
                    _dataCacheSizeComboBox.Items.Add(u);
                }

                _dataCacheSizeComboBox.SelectedItem = Settings.Instance.OptionsWindow_DataCacheSize_Unit;

                foreach (var u in new string[] { "Byte", "KB", "MB", "GB", })
                {
                    _bandwidthLimitComboBox.Items.Add(u);
                }

                _bandwidthLimitComboBox.SelectedItem = Settings.Instance.OptionsWindow_BandwidthLimit_Unit;

                foreach (var u in new string[] { "Byte", "KB", "MB", "GB", })
                {
                    _transferLimitSizeComboBox.Items.Add(u);
                }

                _transferLimitSizeComboBox.SelectedItem = Settings.Instance.OptionsWindow_TransferLimit_Unit;
            }

            {
                lock (_amoebaManager.ThisLock)
                {
                    var baseNode = _amoebaManager.BaseNode;

                    _baseNode_Id = baseNode.Id;
                    _baseNode_Uris.AddRange(baseNode.Uris);
                    _otherNodes.AddRange(_amoebaManager.OtherNodes);
                    _clientFilters.AddRange(_amoebaManager.Filters);
                    _serverListenUris.AddRange(_amoebaManager.ListenUris);

                    try
                    {
                        _dataCacheSizeTextBox.Text = NetworkConverter.ToSizeString(_amoebaManager.Size, Settings.Instance.OptionsWindow_DataCacheSize_Unit);
                    }
                    catch (Exception)
                    {
                        _dataCacheSizeTextBox.Text = "";
                    }

                    _dataDownloadDirectoryTextBox.Text = _amoebaManager.DownloadDirectory;

                    _bandwidthConnectionCountTextBox.Text = _amoebaManager.ConnectionCountLimit.ToString();

                    try
                    {
                        _bandwidthLimitTextBox.Text = NetworkConverter.ToSizeString(_amoebaManager.BandwidthLimit, Settings.Instance.OptionsWindow_BandwidthLimit_Unit);
                    }
                    catch (Exception)
                    {
                        _bandwidthLimitTextBox.Text = "";
                    }
                }

                _baseNodeUrisListView.ItemsSource = _baseNode_Uris;
                _baseNodeUpdate();

                _otherNodesListView.ItemsSource = _otherNodes;
                _otherNodesUpdate();

                _clientFiltersListView.ItemsSource = _clientFilters;
                _clientFiltersListViewUpdate();

                _serverListenUrisListView.ItemsSource = _serverListenUris;
                _serverListenUrisUpdate();
            }

            {
                lock (_transferLimitManager.TransferLimit.ThisLock)
                {
                    _transferLimitTypeComboBox.SelectedItem = _transferLimitManager.TransferLimit.Type;
                    _transferLimitSpanTextBox.Text = _transferLimitManager.TransferLimit.Span.ToString();

                    try
                    {
                        _transferLimitSizeTextBox.Text = NetworkConverter.ToSizeString(_transferLimitManager.TransferLimit.Size, Settings.Instance.OptionsWindow_TransferLimit_Unit);
                    }
                    catch (Exception)
                    {
                        _transferLimitSizeTextBox.Text = "";
                    }
                }

                {
                    var uploadSize = _transferLimitManager.TotalUploadSize;
                    var downloadSize = _transferLimitManager.TotalDownloadSize;

                    _transferInfoUploadedLabel.Content = NetworkConverter.ToSizeString(uploadSize);
                    _transferInfoDownloadedLabel.Content = NetworkConverter.ToSizeString(downloadSize);
                    _transferInfoTotalLabel.Content = NetworkConverter.ToSizeString(uploadSize + downloadSize);
                }
            }

            {
                _eventOpenPortAndGetIpAddressCheckBox.IsChecked = Settings.Instance.Global_ConnectionSetting_IsEnabled;
                _eventUseI2pCheckBox.IsChecked = Settings.Instance.Global_I2p_SamBridge_IsEnabled;

                {
                    _eventSamBridgeUriTextBox.Text = _overlayNetworkManager.SamBridgeUri;
                }
            }

            {
                _updateUrlTextBox.Text = Settings.Instance.Global_Update_Url;
                _updateProxyUriTextBox.Text = Settings.Instance.Global_Update_ProxyUri;
                _updateSignatureTextBox.Text = Settings.Instance.Global_Update_Signature;

                if (Settings.Instance.Global_Update_Option == UpdateOption.None)
                {
                    _updateOptionNoneRadioButton.IsChecked = true;
                }
                else if (Settings.Instance.Global_Update_Option == UpdateOption.Check)
                {
                    _updateOptionAutoCheckRadioButton.IsChecked = true;
                }
                else if (Settings.Instance.Global_Update_Option == UpdateOption.Update)
                {
                    _updateOptionAutoUpdateRadioButton.IsChecked = true;
                }
            }

            {
                _signatureListViewItemCollection.AddRange(Settings.Instance.Global_DigitalSignatures.Select(n => new SignatureListViewItem(n)));
                _signatureListView.ItemsSource = _signatureListViewItemCollection;
                _signatureListViewUpdate();
            }

            {
                _keywordCollection.AddRange(Settings.Instance.Global_SearchKeywords);
                _keywordListView.ItemsSource = _keywordCollection;
                _keywordListViewUpdate();
            }

            {
                try
                {
                    string extension = ".box";
                    string commandline = "\"" + Path.GetFullPath(Path.Combine(_serviceManager.Paths["Core"], "Amoeba.exe")) + "\" \"%1\"";
                    string fileType = "Amoeba";
                    string verb = "open";

                    using (var regkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(extension))
                    {
                        if (fileType != (string)regkey.GetValue("")) throw new Exception();
                    }

                    using (var shellkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(fileType))
                    {
                        using (var shellkey2 = shellkey.OpenSubKey("shell\\" + verb))
                        {
                            using (var shellkey3 = shellkey2.OpenSubKey("command"))
                            {
                                if (commandline != (string)shellkey3.GetValue("")) throw new Exception();
                            }
                        }
                    }

                    Settings.Instance.Global_RelateBoxFile_IsEnabled = true;
                    _boxRelateFileCheckBox.IsChecked = true;
                }
                catch
                {
                    Settings.Instance.Global_RelateBoxFile_IsEnabled = false;
                    _boxRelateFileCheckBox.IsChecked = false;
                }

                _boxOpenCheckBox.IsChecked = Settings.Instance.Global_OpenBox_IsEnabled;
                _boxExtractToTextBox.Text = Settings.Instance.Global_BoxExtractTo_Path;
            }

            {
                _MiningTimeTextBox.Text = Settings.Instance.Global_MiningTime.TotalMinutes.ToString();
            }

            {
                _fontMessageFontFamilyComboBoxItemCollection.AddRange(Fonts.SystemFontFamilies.Select(n => n.ToString()));
                _fontMessageFontFamilyComboBoxItemCollection.Sort();
                _fontMessageFontFamilyComboBox.ItemsSource = _fontMessageFontFamilyComboBoxItemCollection;
                _fontMessageFontFamilyComboBox.SelectedItem = Settings.Instance.Global_Fonts_Message_FontFamily;

                _fontMessageFontSizeTextBox.Text = Settings.Instance.Global_Fonts_Message_FontSize.ToString();
            }
        }
        public ConnectionSettingManager(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            _settings = new Settings();
        }
        public InformationControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewItemCollection;

            #if DEBUG
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_BufferManagerSize" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());
            #endif

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_SentByteCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_ReceivedByteCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_CreateConnectionCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_AcceptConnectionCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_BlockedConnectionCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_SurroundingNodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_RelayBlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_LockSpace" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_FreeSpace" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_UsingSpace" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_NodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_SeedCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_BlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_DownloadCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_UploadCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_ShareCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushNodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushBlockLinkCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushBlockRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushBlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushSeedRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushSeedCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullNodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullBlockLinkCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullBlockRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullBlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullSeedRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullSeedCount" });

            _infomationListView.ItemsSource = _infomationListViewItemCollection;

            _showAmoebaInfomationThread = new Thread(this.ShowAmoebaInfomation);
            _showAmoebaInfomationThread.Priority = ThreadPriority.Highest;
            _showAmoebaInfomationThread.IsBackground = true;
            _showAmoebaInfomationThread.Name = "InformationControl_ShowAmoebaInfomationThread";
            _showAmoebaInfomationThread.Start();

            _showConnectionInfomationwThread = new Thread(this.ShowConnectionInfomation);
            _showConnectionInfomationwThread.Priority = ThreadPriority.Highest;
            _showConnectionInfomationwThread.IsBackground = true;
            _showConnectionInfomationwThread.Name = "InformationControl_ShowConnectionInfomationThread";
            _showConnectionInfomationwThread.Start();
        }
        public TransfarLimitManager(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            _settings = new Settings(this.ThisLock);
        }