~do-plugins/do-plugins/trunk

« back to all changes in this revision

Viewing changes to Transmission/src/TorrentItem.cs

  • Committer: Christopher James Halse Rogers
  • Date: 2013-05-02 07:23:58 UTC
  • mfrom: (684.1.9 do-plugins)
  • Revision ID: chris@ed-20130502072358-ddn5oxyjngeearme
Merge long-awaited Transmission control plugin

Ported to Json.NET, as this has packages in the Debian and Ubuntu archives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using System;
 
3
using System.Collections.Generic;
 
4
 
 
5
using Do.Universe;
 
6
 
 
7
namespace Transmission {
 
8
 
 
9
        public class TorrentItem: Item {
 
10
 
 
11
                private string _name;
 
12
                private string _comment;
 
13
                private string _hash_string;
 
14
                private ulong _size;
 
15
                private TransmissionAPI.TorrentStatus _status;
 
16
                private int _download_speed_limit, _upload_speed_limit;
 
17
                private TorrentDirectoryItem _root;
 
18
 
 
19
                public TorrentItem(TransmissionAPI.TorrentInfo info) {
 
20
                        _hash_string = info.HashString;
 
21
                        _name = info.Name;
 
22
                        _comment = info.Comment;
 
23
                        _status = info.Status;
 
24
                        _size = info.TotalSize;
 
25
                        _download_speed_limit = info.DownloadLimit;
 
26
                        _upload_speed_limit = info.UploadLimit;
 
27
                        _root = new TorrentDirectoryItem(this, null, info.DownloadDir);
 
28
                }
 
29
 
 
30
                public override string Name {
 
31
                        get { return _name; }
 
32
                }
 
33
 
 
34
                public override string Description {
 
35
                        get {
 
36
                                string status_text = "";
 
37
                                switch (_status) {
 
38
                                case TransmissionAPI.TorrentStatus.CheckWait: status_text = "Waiting for check"; break;
 
39
                                case TransmissionAPI.TorrentStatus.Check:     status_text = "Checking"; break;
 
40
                                case TransmissionAPI.TorrentStatus.Download:  status_text = "Downloading"; break;
 
41
                                case TransmissionAPI.TorrentStatus.Seed:      status_text = "Seeding"; break;
 
42
                                case TransmissionAPI.TorrentStatus.Stopped:   status_text = "Stopped"; break;
 
43
                                }
 
44
 
 
45
                                return string.Format("{0}, {1}", Utils.FormatSize(_size), status_text);
 
46
                        }
 
47
                }
 
48
 
 
49
                public override string Icon {
 
50
                        get { return "transmission"; }
 
51
                }
 
52
 
 
53
                public string HashString {
 
54
                        get { return _hash_string; }
 
55
                }
 
56
 
 
57
                public TorrentDirectoryItem Root {
 
58
                        get { return _root; }
 
59
                }
 
60
 
 
61
                public int DownloadSpeedLimit {
 
62
                        get { return _download_speed_limit; }
 
63
                        set { _download_speed_limit = value; }
 
64
                }
 
65
 
 
66
                public int UploadSpeedLimit {
 
67
                        get { return _upload_speed_limit; }
 
68
                        set { _upload_speed_limit = value; }
 
69
                }
 
70
        }
 
71
 
 
72
}