public TorrentDirectoryItem(TorrentItem torrent, TorrentDirectoryItem parent, string name) { _torrent = torrent; _parent = parent; _name = name; _files = new List <Item>(); }
protected override PredefinedSpeed GetCurrentSpeedItem(TorrentItem torrent) { int currentSpeed = torrent.DownloadSpeedLimit; return(new PredefinedSpeed( currentSpeed, string.Format("Saved: {0}", Utils.FormatSpeed(currentSpeed)), "Use limit from torrent settings" )); }
public override IEnumerable <Item> DynamicModifierItemsForItem(Item item) { TorrentItem torrent = (TorrentItem)item; yield return(new PredefinedSpeed(0, "Unlimited", "Turn download speed limit off")); yield return(GetCurrentSpeedItem(torrent)); foreach (PredefinedSpeed speed in Utils.PredefinedSpeedItems) { yield return(speed); } }
public TorrentFileItem( TorrentItem torrent, int index, TorrentDirectoryItem parent, string name, TransmissionAPI.TorrentFileInfo info ) { _torrent = torrent; _index = index; _parent = parent; _name = name; _size = info.Length; _downloaded = info.BytesCompleted; _wanted = info.Wanted; _priority = info.Priority; }
public override void UpdateItems() { Log <TorrentItemSource> .Debug("Updating torrents list"); // Clear current torrents list. _torrents.Clear(); TransmissionAPI api = TransmissionPlugin.getTransmission(); foreach (TransmissionAPI.TorrentInfo t in api.GetAllTorrents()) { Log <TorrentItemSource> .Debug("Torrent: {0}", t.Name); TorrentItem torrent = new TorrentItem(t); // Transmission returns files as flat list with full names, this map // is used to organize files into hierarchy. // It maps directory path to directory item. Dictionary <string, TorrentDirectoryItem> dirs = new Dictionary <string, TorrentDirectoryItem>(); dirs.Add("", torrent.Root); int index = 0; // File index within list. foreach (TransmissionAPI.TorrentFileInfo f in t.Files) { // Split path and name. int sep_pos = f.Name.LastIndexOf('/'); string name = f.Name.Substring(sep_pos + 1); string path = f.Name.Substring(0, sep_pos == -1 ? 0 : sep_pos); Log <TorrentItemSource> .Debug("File {0} in dir {1}", name, path); TorrentDirectoryItem dir = FindOrCreateDirectory(path, dirs); dir.Files.Add(new TorrentFileItem(torrent, index, dir, name, f)); ++index; } _torrents.Add(torrent); } }
protected abstract PredefinedSpeed GetCurrentSpeedItem(TorrentItem torrent);