internal void UpdateTorrentFiles(Torrent TorrentToUpdate) { UpdateTorrentFiles(TorrentToUpdate, false); }
internal void CallEvent(EventType Type, Torrent Torrent, bool FromDispatcher) { if (!FromDispatcher && _dispatcher != null) { _dispatcher.BeginInvoke(new CallEventDelegate(CallEvent), DispatcherPriority.Loaded, new object[] { Type, Torrent, true }); } else { switch (Type) { case EventType.Started: if (TorrentStarted != null) { TorrentStarted(this, new TorrentEventArgs(Torrent)); } break; case EventType.Stopped: if (TorrentStopped != null) { TorrentStopped(this, new TorrentEventArgs(Torrent)); } break; case EventType.Paused: if (TorrentPaused != null) { TorrentPaused(this, new TorrentEventArgs(Torrent)); } break; case EventType.UnPaused: if (TorrentUnPaused != null) { TorrentUnPaused(this, new TorrentEventArgs(Torrent)); } break; case EventType.FinishedDownloading: if (TorrentFinishedDownloading != null) { TorrentFinishedDownloading(this, new TorrentEventArgs(Torrent)); } break; case EventType.Added: if (TorrentAdded != null) { TorrentAdded(this, new TorrentEventArgs(Torrent)); } break; case EventType.Updated: if (TorrentsUpdated != null) { TorrentsUpdated(this, new EventArgs()); } break; default: break; } } }
internal void UpdateTorrentFiles(Torrent TorrentToUpdate, bool ForceUpdate) { if (TorrentToUpdate.FilesLastUpdated == null || TorrentToUpdate.FilesLastUpdated.Add(MinimumTimeBetweenUpdates) < DateTime.Now || ForceUpdate) { if (TorrentToUpdate.FileList == null) { TorrentToUpdate.FileList = new TorrentFileCollection(TorrentToUpdate); } TorrentToUpdate.FileList.ParseFiles(ServiceClient.GetFiles(TorrentToUpdate.Hash, _token).Files, TorrentToUpdate); TorrentToUpdate.FilesLastUpdated = DateTime.Now; } }
/// <summary> /// Removes a torrent from uTorrent and keeps the data /// </summary> /// <param name="Torrent">The torrent to remove</param> public void TorrentRemove(Torrent Torrent) { TorrentRemove(Torrent, false); }
internal void CallEvent(EventType Type, Torrent Torrent) { CallEvent(Type, Torrent, false); }
internal void SetTorrentProperty(Torrent TorrentToUpdate, string PropertyName, string PropertyValue) { ServiceClient.SetStringProperty(TorrentToUpdate.Hash, PropertyName, PropertyValue, _token); }
private void webClient_TorrentAdded(object sender, TorrentEventArgs e) { lock (storedTorrentLock) { this.storedTorrent = e.Torrent; } }
/// <summary> /// Un-pauses a torrent /// </summary> /// <param name="Torrent">The torrent to un-pause</param> public void TorrentUnPause(Torrent Torrent) { ServiceClient.UnPauseTorrent(Torrent.Hash, _token); GetTorrentsAndLabels(true); }
/// <summary> /// Force starts a torrent /// </summary> /// <param name="Torrent">The torrent to force start</param> public void TorrentForceStart(Torrent Torrent) { ServiceClient.ForceStartTorrent(Torrent.Hash, _token); GetTorrentsAndLabels(true); }
public TorrentFileInfo(UTorrentMonitor monitor, Torrent torrent, TorrentFile torrentFile) { this.Monitor = monitor; this.Torrent = torrent; this.TorrentFile = torrentFile; this.LocalFileInfo = new FileInfo(Path.Combine(torrent.TargetDirectory, torrentFile.Name)); }
/// <summary> /// Stops a torrent /// </summary> /// <param name="Torrent">The torrent to stop</param> public void TorrentStop(Torrent Torrent) { ServiceClient.StopTorrent(Torrent.Hash, _token); GetTorrentsAndLabels(true); }
public void RemoveTorrent(Torrent torrent) { try { if (this.client != null) { this.knownTorrents.Remove(torrent.Hash); this.client.TorrentRemove(torrent); } } catch{} }
/// <summary> /// Removes a torrent from uTorrent /// </summary> /// <param name="Torrent">The torrent to remove</param> /// <param name="RemoveData">Whether or not the data is removed</param> public void TorrentRemove(Torrent Torrent, bool RemoveData) { if(_token == null) return; try { if(RemoveData) { ServiceClient.RemoveTorrentAndData(Torrent.Hash, _token); } else { ServiceClient.RemoveTorrent(Torrent.Hash, _token); } GetTorrentsAndLabels(true); } catch(System.ServiceModel.ProtocolException e) { // Token possibly expired, get new token. Trace.TraceError(e.Message + e.StackTrace); GetToken(); } }
/// <summary> /// Re-checks a torrent /// </summary> /// <param name="Torrent">The torrent to re-check</param> public void TorrentReCheck(Torrent Torrent) { if(_token == null) return; try { ServiceClient.RecheckTorrent(Torrent.Hash, _token); GetTorrentsAndLabels(true); } catch(System.ServiceModel.ProtocolException e) { // Token possibly expired, get new token. Trace.TraceError(e.Message + e.StackTrace); GetToken(); } }
internal void UpdateTorrentProperties(Torrent TorrentToUpdate, bool ForceUpdate) { if (TorrentToUpdate.PropertiesLastUpdated == null || TorrentToUpdate.PropertiesLastUpdated.Add(MinimumTimeBetweenUpdates) < DateTime.Now || ForceUpdate) { TorrentPropertiesList[] CurrentProperties = ServiceClient.GetProperties(TorrentToUpdate.Hash, _token).Properties; if (CurrentProperties.Length != 1) { throw new FormatException("The array of torrent properties was not in the expected format."); } TorrentToUpdate.ParseProperties(CurrentProperties[0]); TorrentToUpdate.PropertiesLastUpdated = DateTime.Now; } }
/// <summary> /// Re-checks a torrent /// </summary> /// <param name="Torrent">The torrent to re-check</param> public void TorrentReCheck(Torrent Torrent) { ServiceClient.RecheckTorrent(Torrent.Hash, _token); GetTorrentsAndLabels(true); }
internal void UpdateTorrentProperties(Torrent TorrentToUpdate) { UpdateTorrentProperties(TorrentToUpdate, false); }
/// <summary> /// Removes a torrent from uTorrent /// </summary> /// <param name="Torrent">The torrent to remove</param> /// <param name="RemoveData">Whether or not the data is removed</param> public void TorrentRemove(Torrent Torrent, bool RemoveData) { if (RemoveData) { ServiceClient.RemoveTorrentAndData(Torrent.Hash, _token); } else { ServiceClient.RemoveTorrent(Torrent.Hash, _token); } GetTorrentsAndLabels(true); }
internal TorrentEventArgs(Torrent Torrent) : base() { _torrent = Torrent; }
internal TorrentFileCollection(Torrent ParentTorrent) { this.ParentTorrent = ParentTorrent; _torrentFileCollectionInternal = new List <TorrentFile>(); }