line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Skype::Any; |
2
|
1
|
|
|
1
|
|
36547
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
27
|
use 5.008001; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1077
|
use Module::Runtime qw/use_module/; |
|
1
|
|
|
|
|
2063
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %OBJECT = ( |
11
|
|
|
|
|
|
|
USER => 'User', |
12
|
|
|
|
|
|
|
CALL => 'Call', |
13
|
|
|
|
|
|
|
MESSAGE => 'Message', |
14
|
|
|
|
|
|
|
CHAT => 'Chat', |
15
|
|
|
|
|
|
|
CHATMEMBER => 'ChatMember', |
16
|
|
|
|
|
|
|
CHATMESSAGE => 'ChatMessage', |
17
|
|
|
|
|
|
|
VOICEMAIL => 'VoiceMail', |
18
|
|
|
|
|
|
|
SMS => 'SMS', |
19
|
|
|
|
|
|
|
APPLICATION => 'Application', |
20
|
|
|
|
|
|
|
GROUP => 'Group', |
21
|
|
|
|
|
|
|
FILETRANSFER => 'FileTransfer', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
0
|
|
|
0
|
1
|
|
my ($class, %args) = @_; |
26
|
0
|
|
|
|
|
|
return bless { |
27
|
|
|
|
|
|
|
name => __PACKAGE__, |
28
|
|
|
|
|
|
|
protocol => 8, |
29
|
|
|
|
|
|
|
api_class => "Skype::Any::API::$^O", |
30
|
|
|
|
|
|
|
%args, |
31
|
|
|
|
|
|
|
}, $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub api { |
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
36
|
0
|
0
|
|
|
|
|
unless (defined $self->{api}) { |
37
|
0
|
|
|
|
|
|
my $api = use_module($self->{api_class})->new(skype => $self); |
38
|
0
|
|
|
|
|
|
$self->{api} = $api; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
return $self->{api}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub handler { |
44
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
45
|
0
|
0
|
|
|
|
|
unless (defined $self->{handler}) { |
46
|
0
|
|
|
|
|
|
require Skype::Any::Handler; |
47
|
0
|
|
|
|
|
|
$self->{handler} = Skype::Any::Handler->new(); |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
return $self->{handler}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
sub attach { $_[0]->api->attach } |
53
|
0
|
|
|
0
|
1
|
|
sub run { $_[0]->api->run } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub object { |
56
|
0
|
|
|
0
|
0
|
|
my ($self, $object, $args) = @_; |
57
|
0
|
|
|
|
|
|
$object = uc $object; |
58
|
0
|
0
|
|
|
|
|
if (exists $OBJECT{$object}) { |
59
|
0
|
|
|
|
|
|
return $self->_create_object($OBJECT{$object}, $args); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _object { |
64
|
0
|
|
|
0
|
|
|
my ($self, $object, @args) = @_; |
65
|
0
|
0
|
|
|
|
|
if (@args <= 1) { |
66
|
0
|
0
|
|
|
|
|
if (ref $args[0] eq 'CODE') { |
67
|
|
|
|
|
|
|
# Register default (_) handler |
68
|
0
|
|
|
|
|
|
$self->_register_handler($object, $args[0]); |
69
|
|
|
|
|
|
|
} else { |
70
|
0
|
|
|
|
|
|
$self->_create_object($object, $args[0]); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} else { |
73
|
0
|
|
|
|
|
|
$self->_register_handler($object, {@args}); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _register_handler { |
78
|
0
|
|
|
0
|
|
|
my ($self, $object, $args) = @_; |
79
|
0
|
|
|
|
|
|
$self->handler->register(uc $object, $args); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _create_object { |
83
|
0
|
|
|
0
|
|
|
my ($self, $object, $args) = @_; |
84
|
0
|
0
|
|
|
|
|
return use_module("Skype::Any::Object::$object")->new( |
85
|
|
|
|
|
|
|
skype => $self, |
86
|
|
|
|
|
|
|
(defined $args ? (id => $args) : ()), |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
0
|
1
|
|
sub user { shift->_object('User', @_) } |
91
|
0
|
|
|
0
|
1
|
|
sub profile { shift->_object('Profile', @_) } |
92
|
0
|
|
|
0
|
1
|
|
sub call { shift->_object('Call', @_) } |
93
|
0
|
|
|
0
|
1
|
|
sub message { shift->_object('Message', @_) } |
94
|
0
|
|
|
0
|
1
|
|
sub chat { shift->_object('Chat', @_) } |
95
|
0
|
|
|
0
|
1
|
|
sub chatmember { shift->_object('ChatMember', @_) } |
96
|
0
|
|
|
0
|
1
|
|
sub chatmessage { shift->_object('ChatMessage', @_) } |
97
|
0
|
|
|
0
|
1
|
|
sub voicemail { shift->_object('VoiceMail', @_) } |
98
|
0
|
|
|
0
|
1
|
|
sub sms { shift->_object('SMS', @_) } |
99
|
0
|
|
|
0
|
1
|
|
sub application { shift->_object('Application', @_) } |
100
|
0
|
|
|
0
|
1
|
|
sub group { shift->_object('Group', @_) } |
101
|
0
|
|
|
0
|
1
|
|
sub filetransfer { shift->_object('FileTransfer', @_) } |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub message_received { |
104
|
0
|
|
|
0
|
1
|
|
my ($self, $code) = @_; |
105
|
|
|
|
|
|
|
my $wrapped_code = sub { |
106
|
0
|
|
|
0
|
|
|
my ($chatmessage, $status) = @_; |
107
|
0
|
0
|
|
|
|
|
if ($status eq 'RECEIVED') { |
108
|
0
|
|
|
|
|
|
$code->($chatmessage); |
109
|
|
|
|
|
|
|
} |
110
|
0
|
|
|
|
|
|
}; |
111
|
0
|
|
|
|
|
|
$self->handler->register(CHATMESSAGE => { |
112
|
|
|
|
|
|
|
STATUS => $wrapped_code, |
113
|
|
|
|
|
|
|
}); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub create_chat_with { |
117
|
0
|
|
|
0
|
1
|
|
my ($self, $username, $message) = @_; |
118
|
0
|
|
|
|
|
|
return $self->user($username)->chat->send_message($message); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
__END__ |