blib/lib/Net/OSCAR/Connection/Server.pm

filter: Statementstmt 44.2% 31 / 70 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 83.3% 10 / 12 Podpod 0.0% 0 / 2 totaltotal 35.0% 41 / 117 CC 14 SCAR 45.6
CC
14
Cov
32%
process_one
182.0
new
6.0
BEGIN
1.0
CRAP 95.5
« blib/lib/Net/OSCAR/Utility.pm ↑ Summary blib/lib/Net/OSCAR/Callbacks/1/migrate.pm »
1 =pod
2  
3 Net::OSCAR::Connection::Server -- Net::OSCAR server connection
4  
5 =cut
6  
7 package Net::OSCAR::Connection::Server;
8 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 $Net::OSCAR::Connection::Server::VERSION = '1.928';
10 }
11  
12 1 $REVISION = '$Revision$';
13 1 @ISA = qw(Net::OSCAR::Connection);
14  
15 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::OSCAR::Common qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::OSCAR::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::OSCAR::Connection;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::OSCAR::ServerCallbacks;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 0 ▶sub new($@) {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my $class = shift;
28 0 my $self = $class->SUPER::new(@_);
29 0 ▶ $self->listen($self->{session}->{port}) unless exists($self->{socket});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"socket"} 0 0 0
30  
31 0 $self->{oscar_state} = "listening";
32 0 $self->{signon_done} = 0;
33  
34 0 return $self;
35 }
36  
37 0 ▶sub process_one($;$$$) {
Subroutine process_one: not called CC=13 SCAR=52.0
Pod undocumented
38 0 my($self, $read, $write, $error) = @_;
39 0 my $snac;
40  
41 0 ▶ if($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
42 0 $self->{sockerr} = 1;
43 0 return $self->disconnect();
44 }
45  
46 0 ▶ if($write && $self->{outbuff}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($write and $self->{"outbuff"}) 0 0 0
Condition0%0/3
$write and $self->{"outbuff"}
!ll&&!rl&&r
000
MC/DC0%0/2
$write and $self->{"outbuff"}
$write $self->{"outbuff"}
Truth table0%0/3
A and B
A= $writeB= $self->{"outbuff"}
ABresult
0X0
100
111
47 0 $self->log_print(OSCAR_DBG_DEBUG, "Flushing output buffer.");
48 0 $self->flap_put();
49 }
50  
51 0 ▶ if($read && !$self->{connected}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($read and not $self->{'connected'}) { } 0 0 0
elsif ($write and $self->{'oscar_state'} eq 'new') { } 0 0 0
elsif ($read) { } 0 0 0
Condition0%0/3
$read and not $self->{"connected"}
!ll&&!rl&&r
000
MC/DC0%0/2
$read and not $self->{"connected"}
$read not $self->{"connected"}
Truth table0%0/3
A and not(B)
A= $readB= not $self->{"connected"}
ABresult
0X0
100
111
52 0 $self->log_print(OSCAR_DBG_NOTICE, "Incoming connection.");
53  
54 0 my $socket = gensym();
55 0 accept($socket, $self->{socket});
56 0 my $peer = $self->{session}->addconn(socket => $socket, conntype => CONNTYPE_SERVER, description => "new peer");
57  
58 0 $peer->set_blocking(0);
59 0 $peer->{connected} = 1;
60 0 $peer->{state} = "write";
61 0 $peer->{oscar_state} = "new";
62 0 $self->{session}->callback_connection_changed($peer, "write");
63 0 return 1;
64 ▶ } elsif($write and $self->{oscar_state} eq "new") {
Condition0%0/3
$write and $self->{"oscar_state"} eq "new"
!ll&&!rl&&r
000
MC/DC0%0/2
$write and $self->{"oscar_state"} eq "new"
$write $self->{"oscar_state"} eq "new"
Truth table0%0/3
A and B
A= $writeB= $self->{"oscar_state"} eq "new"
ABresult
0X0
100
111
65 0 $self->log_print(OSCAR_DBG_DEBUG, "Putting connack.");
66 0 $self->flap_put(pack("N", 1), FLAP_CHAN_NEWCONN);
67 0 $self->{state} = "readwrite";
68 0 $self->{session}->callback_connection_changed($self, "readwrite");
69 0 $self->{oscar_state} = "ready";
70  
71 0 $self->{families} = {};
72 0 $self->{families}->{$_} = 1 foreach (1..30);
73 } elsif($read) {
74 0 my $no_reread = 0;
75  
76 0 while(1) {
77 0 ▶ my $flap = $self->flap_get($no_reread) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $flap = $self->flap_get($no_reread) or return 0 0 0 0
78 0 ▶ next if length($flap) == 4;
Branch: 1 branch
BranchTrueFalseTotal
if length $flap == 4 0 0 0
79 0 ▶ my $snac = $self->snac_decode($flap) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $snac = $self->snac_decode($flap) or return 0 0 0 0
80 0 Net::OSCAR::ServerCallbacks::process_snac($self, $snac);
81 } continue {
82 0 $no_reread = 1;
83 }
84 }
85 }
86  
87 1 1;
« blib/lib/Net/OSCAR/Utility.pm ↑ Summary blib/lib/Net/OSCAR/Callbacks/1/migrate.pm »