Example #1
0
        private void CheckConnection(object sender, RoutedEventArgs e)
        {
            try
            {
                var model = ((SettingsWindowModel)FindResource("model"));

                var client = new UTorrentWebClient(model.UTorrentAddress, model.UTorrentUserName, model.UTorrentPassword);
                var test = client.Settings.Count;
                Trace.WriteLine(string.Format("Check connection: success - loaded {0} settings",test));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #2
0
        public void Start(string address, string userName, string password)
        {
            Stop();
            try
            {
                this.knownTorrents = new HashSet<string>();
                this.client = new UTorrentWebClient(address, userName, password, true, this.dispatcher);

                this.client.MinimumTimeBetweenUpdates = TimeSpan.FromSeconds(30);
                this.client.TorrentsUpdated += OnTorrentsUpdated;
                this.client.TorrentFinishedDownloading += OnTorrentFinishedDownloading;
                ReportReadyTorrents();

            }
            catch (Exception ex)
            {
                this.Error = ex;
                Stop();
            }
        }
Example #3
0
        private void connect(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (!config.ContainsKey("server") || e.Argument.ToString() == "force")
                {
                    InputBox requestServer = new InputBox();
                    requestServer.ShowDialog();
                    if (requestServer.server == null)
                        throw new Exception("No server specified");
                    IPAddress address;
                    string host = requestServer.server.Split(':')[0];

                    if (!IPAddress.TryParse(host, out address))
                    {
                        string hostIP = Dns.GetHostAddresses(host)[0].ToString();
                        config["server"] = hostIP + ":" + requestServer.server.ToString().Split(':')[1];
                    }
                    else
                    {
                        config["server"] = requestServer.server;
                    }
                    config["username"] = requestServer.user;
                    config["password"] = requestServer.pass;
                }

                webClient = new UTorrentWebClient(config["server"], config["username"], config["password"]);
                if (webClient == null)
                    throw new Exception("Not Connected");
                online = true;
            }
            catch(Exception ex)
            {
                Console.WriteLine( ex.StackTrace);
                Console.WriteLine( ex.Message);
                e.Result = "Connection Error";
                online = false;
            }
        }
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            using (UTorrentWebClient webClient = new UTorrentWebClient(Properties.Settings.Default.ServerAddress,
                Properties.Settings.Default.UserName,
                Properties.Settings.Default.Password))
            {
                webClient.TorrentAdded += new TorrentEventHandler(webClient_TorrentAdded);
                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                if (this.IsMagnetLink)
                {
                    webClient.AddTorrentFromUrl(this.TorrentURI);
                }
                else
                {
                    webClient.AddTorrent(this.TorrentURI);
                }

                if (backgroundWorker.CancellationPending)
                {
                    lock (this.storedTorrentLock)
                    {
                        if (this.storedTorrent != null)
                        {
                            webClient.TorrentRemove(this.storedTorrent, true);
                        }
                    }

                    e.Cancel = true;
                    return;
                }
            }
        }
Example #5
0
 internal TorrentLabelCollection(UTorrentWebClient ParentClient)
 {
     this.ParentClient = ParentClient;
     _torrentLabelCollectionInternal = new List <TorrentLabel>();
 }
Example #6
0
        public void Stop()
        {
            if (this.client != null)
            {
                this.client.TorrentsUpdated -= OnTorrentsUpdated;
                this.client.TorrentFinishedDownloading -= OnTorrentFinishedDownloading;
                this.client.Dispose();
                this.client = null;
            }

            this.knownTorrents = null;
        }
Example #7
0
 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     goOnline(false);
     webClient.Dispose();
     webClient = null;
     remoteTorrents.Clear();
 }