line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ex:ts=4:sw=4:sts=4:et |
2
|
|
|
|
|
|
|
package Transmission::Utils; |
3
|
|
|
|
|
|
|
# See Transmission::Client for copyright statement. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Transmission::Utils - Utilies for modules that use Transmission::* |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
1980
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
60
|
|
12
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
81
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
11
|
use Sub::Exporter -setup => { |
15
|
|
|
|
|
|
|
exports => [qw/ from_numeric_status to_numeric_status /], |
16
|
2
|
|
|
2
|
|
1315
|
}; |
|
2
|
|
|
|
|
17177
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %numeric_status = qw/ |
19
|
|
|
|
|
|
|
1 queued |
20
|
|
|
|
|
|
|
2 checking |
21
|
|
|
|
|
|
|
4 downloading |
22
|
|
|
|
|
|
|
8 seeding |
23
|
|
|
|
|
|
|
16 stopped |
24
|
|
|
|
|
|
|
/; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 FUNCTIONS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 from_numeric_status |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$str = from_numeric_status($int); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Will translate a numeric status description from Transmission to something |
33
|
|
|
|
|
|
|
readable. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub from_numeric_status { |
38
|
2
|
|
100
|
2
|
1
|
1080
|
return $numeric_status{$_[0]} || q(); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 to_numeric_status |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$int = to_numeric_status($str); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Will translate a status description to a number used by Transmission. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub to_numeric_status { |
50
|
2
|
|
|
2
|
1
|
12
|
my %tmp = reverse %numeric_status; |
51
|
2
|
|
100
|
|
|
14
|
return $tmp{$_[0]} || -1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 LICENSE |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHOR |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
See L<Transmission::Client> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |