~do-plugins/do-plugins/trunk

« back to all changes in this revision

Viewing changes to Transmission/src/TorrentVerifyAction.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.Linq;
 
4
using System.Collections.Generic;
 
5
 
 
6
using Mono.Addins;
 
7
 
 
8
using Do.Universe;
 
9
 
 
10
namespace Transmission {
 
11
 
 
12
        public class TorrentVerifyAction: Act {
 
13
 
 
14
                public TorrentVerifyAction() {
 
15
                }
 
16
 
 
17
            public override string Name {
 
18
                        get { return AddinManager.CurrentLocalizer.GetString ("Verify"); }
 
19
            }
 
20
 
 
21
                public override string Description {
 
22
                        get { return AddinManager.CurrentLocalizer.GetString ("Verify torrent"); }
 
23
                }
 
24
 
 
25
                public override string Icon {
 
26
                        get { return "dialog-question"; }
 
27
                }
 
28
 
 
29
                public override IEnumerable<Type> SupportedItemTypes {
 
30
                        get { yield return typeof (TorrentItem); }
 
31
                }
 
32
 
 
33
                public override IEnumerable<Item> Perform(IEnumerable<Item> items, IEnumerable<Item> modItems) {
 
34
                        TransmissionAPI api = TransmissionPlugin.getTransmission();
 
35
 
 
36
                        var hashes = items.Cast<TorrentItem>().Select(t => t.HashString);
 
37
                        api.VerifyTorrents(hashes);
 
38
 
 
39
                        return null;
 
40
                }
 
41
        }
 
42
}