| 1 | package Net::OSCAR::Callbacks; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | $Net::OSCAR::Callbacks::VERSION = '1.928'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use vars qw($connection $snac $conntype $family $subtype $data $reqid $reqdata $session $protobit %data); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Socket qw(inet_ntoa); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=30 SCAR=68.4
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | my $sender = Net::OSCAR::Screenname->new(\$data{screenname}); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | my $sender_info = $session->{userinfo}->{$sender} ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Net::OSCAR::Callbacks::session->{"userinfo"}{$sender} ||= {}
MC/DC0%0/1
$Net::OSCAR::Callbacks::session->{"userinfo"}{$sender} ||= {}
$Net::OSCAR::Callbacks::session->{"userinfo"}{$sender}
Truth table0%0/2
A
A= $Net::OSCAR::Callbacks::session->{"userinfo"}{$sender}
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | if($data{channel} == 1) { # Regular IM | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | %data = protoparse($session, "standard_IM_footer")->unpack($data{message_body}); | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # Typing status | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $typing_status = 0; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if(exists($data{supports_typing_status})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $sender_info->{typing_status} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 21 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | delete $sender_info->{typing_status}; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | # Buddy icon | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $new_icon = 0; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if(exists($data{icon_data}->{icon_length}) and $session->{capabilities}->{buddy_icons}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_length"} and $Net::OSCAR::Callbacks::session->{"capabilities"}{"buddy_icons"}
MC/DC0%0/2
exists $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_length"} and $Net::OSCAR::Callbacks::session->{"capabilities"}{"buddy_icons"}
exists $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_length"}
$Net::OSCAR::Callbacks::session->{"capabilities"}{"buddy_icons"}
Truth table0%0/3
A and B
A= exists $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_length"}B= $Net::OSCAR::Callbacks::session->{"capabilities"}{"buddy_icons"}
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if(!exists($sender_info->{icon_timestamp}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not exists $sender_info->{"icon_timestamp"} or $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_timestamp"} > $sender_info->{"icon_timestamp"} or $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_checksum"} != $sender_info->{"icon_checksum"}
not exists $sender_info->{"icon_timestamp"} or $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_timestamp"} > $sender_info->{"icon_timestamp"}
MC/DC0%0/3
not exists $sender_info->{"icon_timestamp"} or $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_timestamp"} > $sender_info->{"icon_timestamp"} or $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_checksum"} != $sender_info->{"icon_checksum"}
not exists $sender_info->{"icon_timestamp"}
$Net::OSCAR::Callbacks::data{"icon_data"}{"icon_timestamp"} > $sender_info->{"icon_timestamp"}
$Net::OSCAR::Callbacks::data{"icon_data"}{"icon_checksum"} != $sender_info->{"icon_checksum"}
Truth table0%0/4
not(A) or B or C
A= not exists $sender_info->{"icon_timestamp"}B= $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_timestamp"} > $sender_info->{"icon_timestamp"}C= $Net::OSCAR::Callbacks::data{"icon_data"}{"icon_checksum"} != $sender_info->{"icon_checksum"}
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | or $data{icon_data}->{icon_timestamp} > $sender_info->{icon_timestamp} | ||||||||||||||||||||||||||||||||||||||||||
| 31 | or $data{icon_data}->{icon_checksum} != $sender_info->{icon_checksum} | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $new_icon = 1; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $sender_info->{$_} = $data{icon_data}->{$_} foreach keys %{$data{icon_data}}; | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | $session->callback_new_buddy_icon($sender, $sender_info) if $new_icon; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # Okay, finally we're done with silly processing of embedded flags | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $session->callback_im_in($sender, $data{message}, exists($data{is_automatic}) ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | } elsif($data{channel} == 2) { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | %data = protoparse($session, "rendezvous_IM")->unpack($data{message_body}); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $type = OSCAR_CAPS_INVERSE()->{$data{capability}}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $session->{rv_proposals}->{$data{cookie}} ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Net::OSCAR::Callbacks::session->{"rv_proposals"}{$Net::OSCAR::Callbacks::data{"cookie"}} ||= {}
MC/DC0%0/1
$Net::OSCAR::Callbacks::session->{"rv_proposals"}{$Net::OSCAR::Callbacks::data{"cookie"}} ||= {}
$Net::OSCAR::Callbacks::session->{"rv_proposals"}{$Net::OSCAR::Callbacks::data{"cookie"}}
Truth table0%0/2
A
A= $Net::OSCAR::Callbacks::session->{"rv_proposals"}{$Net::OSCAR::Callbacks::data{"cookie"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $rv = $session->{rv_proposals}->{$data{cookie}}; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if($data{status} eq "cancel") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $connection->log_print(OSCAR_DBG_DEBUG, "Peer rejected proposal."); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $session->callback_rendezvous_reject($data{cookie}); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $session->delconn($rv->{connection}) if $rv->{connection}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | delete $session->{rv_proposals}->{$data{cookie}}; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } elsif($data{status} eq "accept") { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $connection->log_print(OSCAR_DBG_DEBUG, "Peer accepted proposal."); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $rv->{accepted} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | delete $session->{rv_proposals}->{$data{cookie}}; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $session->callback_rendezvous_accept($data{cookie}); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if(!$type) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $connection->log_print_cond(OSCAR_DBG_INFO, sub { "Unknown rendezvous type: ", hexdump($data{capability}) }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $session->rendezvous_reject($data{cookie}); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if(!$rv->{cookie}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $rv->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $rv->{sender} = $sender; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $rv->{recipient} = $session->{screenname}; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $rv->{cookie} = $data{cookie}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } elsif($rv->{peer} ne $sender) { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $connection->log_printf(OSCAR_DBG_WARN, "$sender tried to send a rendezvous which was previously sent by %s; discarding.", $rv->{peer}); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if($type eq "chat") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my %svcdata = protoparse($session, "chat_invite_rendezvous_data")->unpack($data{svcdata}); | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | # Ignore invites for chats that we're already in | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if(not grep { $_->{url} eq $svcdata{url} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | grep { $_->{conntype} == CONNTYPE_CHAT } | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | @{$session->{connections}} | |||||||||||||||||||||||||||||||||||||||||
| 89 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # Extract chat ID from char URL | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $rv->{chat_url} = $svcdata{url}; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $svcdata{url} =~ /-.*?-(.*?)(\0*)$/; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $chat = $1; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $chat =~ s/%([0-9A-Z]{1,2})/chr(hex($1))/eig; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $rv->{name} = $chat; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $rv->{exchange} = $svcdata{exchange}; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $session->callback_chat_invite($sender, $data{invitation_msg}, $chat, $svcdata{url}); | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | } elsif($type eq "filexfer") { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | # If proposal is being revised, no svcdata will be present. | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my %svcdata; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if($data{svcdata}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | %svcdata = protoparse($session, "file_transfer_rendezvous_data")->unpack($data{svcdata}); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $rv->{direction} = "receive"; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $rv->{accepted} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $rv->{filenames} = $svcdata{files}; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $rv->{total_size} = $svcdata{size}; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $rv->{file_count} = $svcdata{file_count}; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $rv->{using_proxy} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $rv->{tried_proxy} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $rv->{tried_listen} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $rv->{tried_connect} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } elsif($rv->{connection}) { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $session->delconn($rv->{connection}); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | delete $rv->{connection}; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $rv->{port} = $data{port}; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $rv->{external_ip} = $data{client_external_ip} ? inet_ntoa(pack("N", $data{client_external_ip})) : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $rv->{ip} = $data{client_1_ip} ? inet_ntoa(pack("N", $data{client_1_ip})) : $rv->{external_ip}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $rv->{ft_state} = "unconnected"; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $connection->log_printf(OSCAR_DBG_DEBUG, "Got proposal %s for %s:%d (external %s)", hexdump($rv->{cookie}), $rv->{ip}, $rv->{port}, $rv->{external_ip}); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } elsif($type eq "sendlist") { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my %svcdata = protoparse($session, "buddy_list_transfer_rendezvous_data")->unpack($data{svcdata}); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | delete $session->{rv_proposals}->{$data{cookie}}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $list = bltie(); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | foreach my $group (@{$svcdata{group}}) { | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $list->{$group->{name}} = []; | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $grouplist = $list->{$group->{name}}; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | foreach my $buddy (@{$group->{buddies}}) { | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | push @$grouplist, Net::OSCAR::Screenname->new(\$buddy->{name}); | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $session->callback_buddylist_in($sender, $list); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $connection->log_print(OSCAR_DBG_INFO, "Unsupported rendezvous type '$type'"); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $session->rendezvous_reject($data{cookie}); | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||