| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::DBus::Skype::API; |
|
2
|
1
|
|
|
1
|
|
23478
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
44
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
856
|
use parent qw/Net::DBus::Object/; |
|
|
1
|
|
|
|
|
354
|
|
|
|
1
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
|
|
use 5.008001; |
|
6
|
|
|
|
|
|
|
use Carp (); |
|
7
|
|
|
|
|
|
|
use Net::DBus; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
|
|
|
|
|
|
my $class = shift; |
|
13
|
|
|
|
|
|
|
my %args = @_ == 1 ? %{$_[0]} : @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $name = $args{name} |
|
16
|
|
|
|
|
|
|
|| __PACKAGE__ . '/' . $Net::DBus::Skype::API::VERSION; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $bus = Net::DBus->session; |
|
19
|
|
|
|
|
|
|
my $service = $bus->export_service('com.Skype.API'); |
|
20
|
|
|
|
|
|
|
my $self = $class->SUPER::new($service, '/com/Skype/Client'); |
|
21
|
|
|
|
|
|
|
$self->{name} = $name; |
|
22
|
|
|
|
|
|
|
$self->{protocol} = $args{protocol} || 8; |
|
23
|
|
|
|
|
|
|
$self->{notify} = $args{notify} || sub {}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Carp::croak("Skype is not running.") unless $self->is_running; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$self; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub attach { |
|
31
|
|
|
|
|
|
|
my $self = shift; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $bus = Net::DBus->session; |
|
34
|
|
|
|
|
|
|
my $service = $bus->get_service('com.Skype.API'); |
|
35
|
|
|
|
|
|
|
my $object = $service->get_object('/com/Skype'); |
|
36
|
|
|
|
|
|
|
$self->{out} = $object; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$self->send_command("NAME $self->{name}"); |
|
39
|
|
|
|
|
|
|
$self->send_command("PROTOCOL $self->{protocol}"); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_running { |
|
43
|
|
|
|
|
|
|
my $self = shift; |
|
44
|
|
|
|
|
|
|
eval { |
|
45
|
|
|
|
|
|
|
my $bus = Net::DBus->session; |
|
46
|
|
|
|
|
|
|
$bus->get_service('com.Skype.API')->get_object('/com/Skype'); |
|
47
|
|
|
|
|
|
|
}; |
|
48
|
|
|
|
|
|
|
return 0 if $@; |
|
49
|
|
|
|
|
|
|
return 1; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub send_command { |
|
53
|
|
|
|
|
|
|
my ($self, $command) = @_; |
|
54
|
|
|
|
|
|
|
unless ($self->{out}) { |
|
55
|
|
|
|
|
|
|
$self->attach; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
$self->{out}->Invoke($command); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub Notify { |
|
61
|
|
|
|
|
|
|
my ($self, $notification) = @_; |
|
62
|
|
|
|
|
|
|
$self->{notify}->($notification); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
__END__ |