Ejemplo n.º 1
0
 public TorrentDirectoryItem(TorrentItem torrent, TorrentDirectoryItem parent, string name)
 {
     _torrent = torrent;
     _parent  = parent;
     _name    = name;
     _files   = new List <Item>();
 }
Ejemplo n.º 2
0
        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"
                       ));
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 protected abstract PredefinedSpeed GetCurrentSpeedItem(TorrentItem torrent);