blib/lib/Fax/Hylafax/Client.pm

filter: Statementstmt 15.8% 50 / 315 Branchbran 1.1% 2 / 170 Conditioncond 8.8% 21 / 237 MC/DCmcdc 0.0% 0 / 110 Subroutinesub 27.2% 6 / 22 Podpod 100% 5 / 5 totaltotal 9.7% 84 / 859 CC 188 SCAR 74.2
CC
188
Cov
10%
sendfax
2648.8
faxstat
2256.0
sendpage
1260.0
CRAP 1669.8
↑ Summary
1 ######################################################################
2 # Description: Hylafax client that connects directly to the server #
3 # via Hylafax's proprietory FTP protocol #
4 # Author: Alex Rak (arak@cpan.org) #
5 # Copyright: See COPYRIGHT section in POD text below for usage and #
6 # distribution rights #
7 ######################################################################
8  
9 package Fax::Hylafax::Client;
10  
11 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Net::FTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 require Exporter;
18  
19 1 our @ISA = qw(Exporter);
20 1 our @EXPORT_OK = qw(faxinfo faxrm faxstat sendfax sendpage);
21  
22 1 our $VERSION = "1.02";
23  
24 1 our $Host;
25 1 our $Port;
26 1 our $User;
27 1 our $Password;
28 1 our $Passive;
29 1 our $Debug;
30 1 our $NotifyAddr;
31  
32  
33 sub faxinfo
34 0 ▶{
Subroutine faxinfo: not called CC=18 SCAR=58.3
Pod documented
35 0 ▶ shift if $_[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq __PACKAGE__ 0 0 0
36 0 ▶ my %param = scalar @_ == 1 ? ('jobid', shift) : @_;
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ == 1 ? : 0 0 0
37 0 my $self = {
38 TRACE => '',
39 SUCCESS => '',
40 CONTENT => '',
41 };
42  
43 ## Set defaults
44 0 ▶ $param{host} ||= $Host || 'localhost';
Condition0%0/5
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Host || 'localhost'
l!l
00
MC/DC0%0/2
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
$param{"host"} $Fax::Hylafax::Client::Host
Truth table0%0/3
A ||= B
A= $param{"host"}B= $Fax::Hylafax::Client::Host
ABresult
1X1
011
000
45 0 ▶ $param{port} ||= $Port || '4559';
Condition0%0/5
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Port || '4559'
l!l
00
MC/DC0%0/2
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
$param{"port"} $Fax::Hylafax::Client::Port
Truth table0%0/3
A ||= B
A= $param{"port"}B= $Fax::Hylafax::Client::Port
ABresult
1X1
011
000
46 0 ▶ $param{user} ||= $User || 'anonymous';
Condition0%0/5
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::User || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
$param{"user"} $Fax::Hylafax::Client::User
Truth table0%0/3
A ||= B
A= $param{"user"}B= $Fax::Hylafax::Client::User
ABresult
1X1
011
000
47 0 ▶ $param{password} ||= $Password || 'anonymous';
Condition0%0/5
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Password || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
$param{"password"} $Fax::Hylafax::Client::Password
Truth table0%0/3
A ||= B
A= $param{"password"}B= $Fax::Hylafax::Client::Password
ABresult
1X1
011
000
48 0 ▶ $param{passive} ||= $Passive || '0';
Condition0%0/5
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Passive || '0'
l!l
00
MC/DC0%0/2
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
$param{"passive"} $Fax::Hylafax::Client::Passive
Truth table0%0/3
A ||= B
A= $param{"passive"}B= $Fax::Hylafax::Client::Passive
ABresult
1X1
011
000
49  
50 ## Basic error checking
51 0 ▶ croak __PACKAGE__ . ": *jobid* parameter is missing" unless $param{jobid};
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"jobid"} 0 0 0
52  
53 ## Try to connect
54 0 ▶ my $client = Net::FTP->new($param{host}, Port => $param{port}, Passive => $param{passive}) || croak __PACKAGE__ . ": " . $@;
Condition0%0/2
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
l!l
00
MC/DC0%0/1
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Truth table0%0/2
A
A= 'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Aresult
11
00
55 0 ▶ $client->login($param{user}, $param{password}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->login($param{"user"}, $param{"password"}) or _com_error($client) 0 0 0
56 0 $self->{TRACE} .= $client->message;
57  
58 ## Process the task
59 0 ▶ $client->quot("job", $param{jobid}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("job", $param{"jobid"}) or _com_error($client) 0 0 0
60 0 $self->{TRACE} .= $client->message;
61  
62 0 ▶ $client->quot("jparm state") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm state") or _com_error($client) 0 0 0
63 0 $self->{TRACE} .= $client->message;
64 0 $self->{CONTENT} = $client->message;
65  
66 ## Disconnect
67 0 $client->quit;
68 0 $self->{TRACE} .= $client->message;
69  
70 0 return bless $self, __PACKAGE__ . "::Instant";
71 }
72  
73  
74 sub faxrm
75 0 ▶{
Subroutine faxrm: not called CC=19 SCAR=59.4
Pod documented
76 0 ▶ shift if $_[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq __PACKAGE__ 0 0 0
77 0 ▶ my %param = scalar @_ == 1 ? ('jobid', shift) : @_;
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ == 1 ? : 0 0 0
78 0 my $self = {
79 TRACE => '',
80 SUCCESS => '',
81 };
82  
83 ## Set defaults
84 0 ▶ $param{host} ||= $Host || 'localhost';
Condition0%0/5
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Host || 'localhost'
l!l
00
MC/DC0%0/2
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
$param{"host"} $Fax::Hylafax::Client::Host
Truth table0%0/3
A ||= B
A= $param{"host"}B= $Fax::Hylafax::Client::Host
ABresult
1X1
011
000
85 0 ▶ $param{port} ||= $Port || '4559';
Condition0%0/5
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Port || '4559'
l!l
00
MC/DC0%0/2
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
$param{"port"} $Fax::Hylafax::Client::Port
Truth table0%0/3
A ||= B
A= $param{"port"}B= $Fax::Hylafax::Client::Port
ABresult
1X1
011
000
86 0 ▶ $param{user} ||= $User || 'anonymous';
Condition0%0/5
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::User || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
$param{"user"} $Fax::Hylafax::Client::User
Truth table0%0/3
A ||= B
A= $param{"user"}B= $Fax::Hylafax::Client::User
ABresult
1X1
011
000
87 0 ▶ $param{password} ||= $Password || 'anonymous';
Condition0%0/5
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Password || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
$param{"password"} $Fax::Hylafax::Client::Password
Truth table0%0/3
A ||= B
A= $param{"password"}B= $Fax::Hylafax::Client::Password
ABresult
1X1
011
000
88 0 ▶ $param{passive} ||= $Passive || '0';
Condition0%0/5
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Passive || '0'
l!l
00
MC/DC0%0/2
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
$param{"passive"} $Fax::Hylafax::Client::Passive
Truth table0%0/3
A ||= B
A= $param{"passive"}B= $Fax::Hylafax::Client::Passive
ABresult
1X1
011
000
89  
90 ## Basic error checking
91 0 ▶ croak __PACKAGE__ . ": *jobid* parameter is missing" unless $param{jobid};
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"jobid"} 0 0 0
92  
93 ## Try to connect
94 0 ▶ my $client = Net::FTP->new($param{host}, Port => $param{port}, Passive => $param{passive}) || croak __PACKAGE__ . ": " . $@;
Condition0%0/2
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
l!l
00
MC/DC0%0/1
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Truth table0%0/2
A
A= 'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Aresult
11
00
95 0 ▶ $client->login($param{user}, $param{password}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->login($param{"user"}, $param{"password"}) or _com_error($client) 0 0 0
96 0 $self->{TRACE} .= $client->message;
97  
98 ## Process the task
99 0 ▶ $client->quot("jkill", $param{jobid}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jkill", $param{"jobid"}) or _com_error($client) 0 0 0
100 0 $self->{TRACE} .= $client->message;
101 0 ▶ $self->{SUCCESS} = $client->message =~ /failed/i || $client->message =~ /cannot/i ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$client->message =~ /failed/i || $client->message =~ /cannot/i ? : 0 0 0
Condition0%0/3
$client->message =~ /failed/i or $client->message =~ /cannot/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->message =~ /failed/i or $client->message =~ /cannot/i
$client->message =~ /failed/i $client->message =~ /cannot/i
Truth table0%0/3
A or B
A= $client->message =~ /failed/iB= $client->message =~ /cannot/i
ABresult
1X1
011
000
102  
103 ## Disconnect
104 0 $client->quit;
105 0 $self->{TRACE} .= $client->message;
106  
107 0 return bless $self, __PACKAGE__ . "::Instant";
108 }
109  
110  
111 sub faxstat
112 0 ▶{
Subroutine faxstat: not called CC=47 SCAR=77.2
Pod documented
113 0 ▶ shift if $_[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq __PACKAGE__ 0 0 0
114 0 my %param = @_;
115 0 my $self = {
116 TRACE => '',
117 SUCCESS => '',
118 CONTENT => '',
119 };
120  
121 ## Set defaults
122 0 ▶ $param{host} ||= $Host || 'localhost';
Condition0%0/5
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Host || 'localhost'
l!l
00
MC/DC0%0/2
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
$param{"host"} $Fax::Hylafax::Client::Host
Truth table0%0/3
A ||= B
A= $param{"host"}B= $Fax::Hylafax::Client::Host
ABresult
1X1
011
000
123 0 ▶ $param{port} ||= $Port || '4559';
Condition0%0/5
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Port || '4559'
l!l
00
MC/DC0%0/2
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
$param{"port"} $Fax::Hylafax::Client::Port
Truth table0%0/3
A ||= B
A= $param{"port"}B= $Fax::Hylafax::Client::Port
ABresult
1X1
011
000
124 0 ▶ $param{user} ||= $User || 'anonymous';
Condition0%0/5
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::User || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
$param{"user"} $Fax::Hylafax::Client::User
Truth table0%0/3
A ||= B
A= $param{"user"}B= $Fax::Hylafax::Client::User
ABresult
1X1
011
000
125 0 ▶ $param{password} ||= $Password || 'anonymous';
Condition0%0/5
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Password || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
$param{"password"} $Fax::Hylafax::Client::Password
Truth table0%0/3
A ||= B
A= $param{"password"}B= $Fax::Hylafax::Client::Password
ABresult
1X1
011
000
126 0 ▶ $param{passive} ||= $Passive || '0';
Condition0%0/5
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Passive || '0'
l!l
00
MC/DC0%0/2
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
$param{"passive"} $Fax::Hylafax::Client::Passive
Truth table0%0/3
A ||= B
A= $param{"passive"}B= $Fax::Hylafax::Client::Passive
ABresult
1X1
011
000
127 0 ▶ $param{filefmt} ||= '';
Condition0%0/2
$param{"filefmt"} ||= ""
l!l
00
MC/DC0%0/1
$param{"filefmt"} ||= ""
$param{"filefmt"}
Truth table0%0/2
A
A= $param{"filefmt"}
Aresult
11
00
128 0 ▶ $param{jobfmt} ||= '%-4j %3i %1a %6.6o %-12.12e %5P %5D %7z %.25s';
Condition0%0/2
$param{"jobfmt"} ||= "%-4j %3i %1a %6.6o %-12.12e %5P %5D %7z %.25s"
l!l
00
MC/DC0%0/1
$param{"jobfmt"} ||= "%-4j %3i %1a %6.6o %-12.12e %5P %5D %7z %.25s"
$param{"jobfmt"}
Truth table0%0/2
A
A= $param{"jobfmt"}
Aresult
11
00
129 0 ▶ $param{rcvfmt} ||= '%-7m %4p%1z %-8.8o %14.14s %7t %f';
Condition0%0/2
$param{"rcvfmt"} ||= "%-7m %4p%1z %-8.8o %14.14s %7t %f"
l!l
00
MC/DC0%0/1
$param{"rcvfmt"} ||= "%-7m %4p%1z %-8.8o %14.14s %7t %f"
$param{"rcvfmt"}
Truth table0%0/2
A
A= $param{"rcvfmt"}
Aresult
11
00
130 0 ▶ $param{info} ||= '0'; # -i flag
Condition0%0/2
$param{"info"} ||= 0
l!l
00
MC/DC0%0/1
$param{"info"} ||= 0
$param{"info"}
Truth table0%0/2
A
A= $param{"info"}
Aresult
11
00
131 0 ▶ $param{files} ||= '0'; # -f flag
Condition0%0/2
$param{"files"} ||= 0
l!l
00
MC/DC0%0/1
$param{"files"} ||= 0
$param{"files"}
Truth table0%0/2
A
A= $param{"files"}
Aresult
11
00
132 0 ▶ $param{queue} ||= '0'; # -s flag
Condition0%0/2
$param{"queue"} ||= 0
l!l
00
MC/DC0%0/1
$param{"queue"} ||= 0
$param{"queue"}
Truth table0%0/2
A
A= $param{"queue"}
Aresult
11
00
133 0 ▶ $param{done} ||= '0'; # -d flag
Condition0%0/2
$param{"done"} ||= 0
l!l
00
MC/DC0%0/1
$param{"done"} ||= 0
$param{"done"}
Truth table0%0/2
A
A= $param{"done"}
Aresult
11
00
134 0 ▶ $param{received} ||= '0'; # -r flag
Condition0%0/2
$param{"received"} ||= 0
l!l
00
MC/DC0%0/1
$param{"received"} ||= 0
$param{"received"}
Truth table0%0/2
A
A= $param{"received"}
Aresult
11
00
135  
136 ## Try to connect
137 0 ▶ my $client = Net::FTP->new($param{host}, Port => $param{port}, Passive => $param{passive}) || croak __PACKAGE__ . ": " . $@;
Condition0%0/2
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
l!l
00
MC/DC0%0/1
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Truth table0%0/2
A
A= 'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Aresult
11
00
138 0 ▶ $client->login($param{user}, $param{password}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->login($param{"user"}, $param{"password"}) or _com_error($client) 0 0 0
139 0 $self->{TRACE} .= $client->message;
140  
141 ## Process the task
142 0 ▶ if ($param{info})
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"info"}) 0 0 0
143 {
144 0 ▶ my $dataconn = $client->retr("status/any.info") || _com_error($client);
Condition0%0/3
$client->retr('status/any.info') || _com_error($client)
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->retr('status/any.info') || _com_error($client)
$client->retr('status/any.info') _com_error($client)
Truth table0%0/3
A || B
A= $client->retr('status/any.info')B= _com_error($client)
ABresult
1X1
011
000
145 0 ▶ while ($dataconn->read(my $buffer, 1024))
Branch: 1 branch
BranchTrueFalseTotal
if ($dataconn->read(my $buffer, 1024)) 0 0 0
146 {
147 0 $self->{CONTENT} .= $buffer;
148 }
149 0 $dataconn->close;
150 0 $self->{TRACE} .= $client->message;
151 }
152  
153 0 ▶ my $dataconn = $client->list("status") || _com_error($client);
Condition0%0/3
$client->list('status') || _com_error($client)
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->list('status') || _com_error($client)
$client->list('status') _com_error($client)
Truth table0%0/3
A || B
A= $client->list('status')B= _com_error($client)
ABresult
1X1
011
000
154 0 ▶ while ($dataconn->read(my $buffer, 1024))
Branch: 1 branch
BranchTrueFalseTotal
if ($dataconn->read(my $buffer, 1024)) 0 0 0
155 {
156 0 $self->{CONTENT} .= $buffer;
157 }
158 0 $dataconn->close;
159 0 $self->{TRACE} .= $client->message;
160  
161 0 ▶ if ($param{files})
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"files"}) 0 0 0
162 {
163 0 ▶ $client->quot("filefmt", $param{filefmt}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("filefmt", $param{"filefmt"}) or _com_error($client) 0 0 0
164 0 ▶ my $dataconn = $client->list("docq") || _com_error($client);
Condition0%0/3
$client->list('docq') || _com_error($client)
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->list('docq') || _com_error($client)
$client->list('docq') _com_error($client)
Truth table0%0/3
A || B
A= $client->list('docq')B= _com_error($client)
ABresult
1X1
011
000
165 0 my $content;
166 0 ▶ while ($dataconn->read(my $buffer, 1024))
Branch: 1 branch
BranchTrueFalseTotal
if ($dataconn->read(my $buffer, 1024)) 0 0 0
167 {
168 0 $content .= $buffer;
169 }
170 0 $dataconn->close;
171 0 ▶ $self->{CONTENT} .= "\n$content" if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
172 0 $self->{TRACE} .= $client->message;
173 }
174  
175 0 ▶ if ($param{queue})
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"queue"}) 0 0 0
176 {
177 0 ▶ $client->quot("jobfmt", $param{jobfmt}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jobfmt", $param{"jobfmt"}) or _com_error($client) 0 0 0
178 0 ▶ my $dataconn = $client->list("sendq") || _com_error($client);
Condition0%0/3
$client->list('sendq') || _com_error($client)
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->list('sendq') || _com_error($client)
$client->list('sendq') _com_error($client)
Truth table0%0/3
A || B
A= $client->list('sendq')B= _com_error($client)
ABresult
1X1
011
000
179 0 my $content;
180 0 ▶ while ($dataconn->read(my $buffer, 1024))
Branch: 1 branch
BranchTrueFalseTotal
if ($dataconn->read(my $buffer, 1024)) 0 0 0
181 {
182 0 $content .= $buffer;
183 }
184 0 $dataconn->close;
185 0 ▶ $self->{CONTENT} .= "\n$content" if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
186 0 $self->{TRACE} .= $client->message;
187 }
188  
189 0 ▶ if ($param{done})
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"done"}) 0 0 0
190 {
191 0 ▶ $client->quot("jobfmt", $param{jobfmt}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jobfmt", $param{"jobfmt"}) or _com_error($client) 0 0 0
192 0 ▶ my $dataconn = $client->list("doneq") || _com_error($client);
Condition0%0/3
$client->list('doneq') || _com_error($client)
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->list('doneq') || _com_error($client)
$client->list('doneq') _com_error($client)
Truth table0%0/3
A || B
A= $client->list('doneq')B= _com_error($client)
ABresult
1X1
011
000
193 0 my $content;
194 0 ▶ while ($dataconn->read(my $buffer, 1024))
Branch: 1 branch
BranchTrueFalseTotal
if ($dataconn->read(my $buffer, 1024)) 0 0 0
195 {
196 0 $content .= $buffer;
197 }
198 0 $dataconn->close;
199 0 ▶ $self->{CONTENT} .= "\n$content" if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
200 0 $self->{TRACE} .= $client->message;
201 }
202  
203 0 ▶ if ($param{received})
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"received"}) 0 0 0
204 {
205 0 ▶ $client->quot("rcvfmt", $param{rcvfmt}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("rcvfmt", $param{"rcvfmt"}) or _com_error($client) 0 0 0
206 0 ▶ my $dataconn = $client->list("recvq") || _com_error($client);
Condition0%0/3
$client->list('recvq') || _com_error($client)
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->list('recvq') || _com_error($client)
$client->list('recvq') _com_error($client)
Truth table0%0/3
A || B
A= $client->list('recvq')B= _com_error($client)
ABresult
1X1
011
000
207 0 my $content;
208 0 ▶ while ($dataconn->read(my $buffer, 1024))
Branch: 1 branch
BranchTrueFalseTotal
if ($dataconn->read(my $buffer, 1024)) 0 0 0
209 {
210 0 $content .= $buffer;
211 }
212 0 $dataconn->close;
213 0 ▶ $self->{CONTENT} .= "\n$content" if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
214 0 $self->{TRACE} .= $client->message;
215 }
216  
217 ## Disconnect
218 0 $client->quit;
219 0 $self->{TRACE} .= $client->message;
220  
221 0 return bless $self, __PACKAGE__ . "::Instant";
222 }
223  
224  
225 sub sendfax
226 1 ▶{
Subroutine sendfax: called CC=70 SCAR=78.8
Pod documented
227 1 ▶ shift if $_[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq __PACKAGE__ 1 0 1
228 1 my %param = @_;
229 1 my $hostname = `hostname`; chomp $hostname;
230 1 my $self = {
231 JOB_ID => '',
232 TRACE => '',
233 SUCCESS => '',
234 };
235  
236 ## Set defaults
237 1 ▶ $param{host} ||= $Host || 'localhost';
Condition20%1/5
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
l!l&&r!l&&!r
100
$Fax::Hylafax::Client::Host || 'localhost'
l!l
00
MC/DC0%0/2
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
$param{"host"} $Fax::Hylafax::Client::Host
Truth table33%1/3
A ||= B
A= $param{"host"}B= $Fax::Hylafax::Client::Host
ABresult
1X1
011
000
238 1 ▶ $param{port} ||= $Port || '4559';
Condition40%2/5
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
l!l&&r!l&&!r
010
$Fax::Hylafax::Client::Port || '4559'
l!l
01
MC/DC0%0/2
$param{"port"} ||= $Fax::Hylafax::Client::Port || 4559
$param{"port"} $Fax::Hylafax::Client::Port
Truth table0%0/3
A ||= B
A= $param{"port"}B= $Fax::Hylafax::Client::Port
ABresult
1X1
011
000
239 1 ▶ $param{user} ||= $User || 'anonymous';
Condition20%1/5
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
l!l&&r!l&&!r
100
$Fax::Hylafax::Client::User || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
$param{"user"} $Fax::Hylafax::Client::User
Truth table33%1/3
A ||= B
A= $param{"user"}B= $Fax::Hylafax::Client::User
ABresult
1X1
011
000
240 1 ▶ $param{password} ||= $Password || 'anonymous';
Condition20%1/5
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
l!l&&r!l&&!r
100
$Fax::Hylafax::Client::Password || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
$param{"password"} $Fax::Hylafax::Client::Password
Truth table33%1/3
A ||= B
A= $param{"password"}B= $Fax::Hylafax::Client::Password
ABresult
1X1
011
000
241 1 ▶ $param{passive} ||= $Passive || '0';
Condition40%2/5
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
l!l&&r!l&&!r
001
$Fax::Hylafax::Client::Passive || '0'
l!l
01
MC/DC0%0/2
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
$param{"passive"} $Fax::Hylafax::Client::Passive
Truth table33%1/3
A ||= B
A= $param{"passive"}B= $Fax::Hylafax::Client::Passive
ABresult
1X1
011
000
242 1 ▶ $param{debug} ||= $Debug || '0';
Condition40%2/5
$param{"debug"} ||= $Fax::Hylafax::Client::Debug || 0
l!l&&r!l&&!r
001
$Fax::Hylafax::Client::Debug || '0'
l!l
01
MC/DC0%0/2
$param{"debug"} ||= $Fax::Hylafax::Client::Debug || 0
$param{"debug"} $Fax::Hylafax::Client::Debug
Truth table33%1/3
A ||= B
A= $param{"debug"}B= $Fax::Hylafax::Client::Debug
ABresult
1X1
011
000
243 1 ▶ $param{lasttime} ||= '000259';
Condition50%1/2
$param{"lasttime"} ||= "000259"
l!l
01
MC/DC0%0/1
$param{"lasttime"} ||= "000259"
$param{"lasttime"}
Truth table50%1/2
A
A= $param{"lasttime"}
Aresult
11
00
244 1 ▶ $param{maxdials} ||= '12';
Condition50%1/2
$param{"maxdials"} ||= 12
l!l
01
MC/DC0%0/1
$param{"maxdials"} ||= 12
$param{"maxdials"}
Truth table50%1/2
A
A= $param{"maxdials"}
Aresult
11
00
245 1 ▶ $param{maxtries} ||= '3';
Condition50%1/2
$param{"maxtries"} ||= 3
l!l
01
MC/DC0%0/1
$param{"maxtries"} ||= 3
$param{"maxtries"}
Truth table50%1/2
A
A= $param{"maxtries"}
Aresult
11
00
246 1 ▶ $param{pagewidth} ||= '216';
Condition50%1/2
$param{"pagewidth"} ||= 216
l!l
01
MC/DC0%0/1
$param{"pagewidth"} ||= 216
$param{"pagewidth"}
Truth table50%1/2
A
A= $param{"pagewidth"}
Aresult
11
00
247 1 ▶ $param{pagelength} ||= '279';
Condition50%1/2
$param{"pagelength"} ||= 279
l!l
01
MC/DC0%0/1
$param{"pagelength"} ||= 279
$param{"pagelength"}
Truth table50%1/2
A
A= $param{"pagelength"}
Aresult
11
00
248 1 ▶ $param{vres} ||= '196';
Condition50%1/2
$param{"vres"} ||= 196
l!l
01
MC/DC0%0/1
$param{"vres"} ||= 196
$param{"vres"}
Truth table50%1/2
A
A= $param{"vres"}
Aresult
11
00
249 1 ▶ $param{schedpri} ||= '127';
Condition50%1/2
$param{"schedpri"} ||= 127
l!l
01
MC/DC0%0/1
$param{"schedpri"} ||= 127
$param{"schedpri"}
Truth table50%1/2
A
A= $param{"schedpri"}
Aresult
11
00
250 1 ▶ $param{chopthreshold} ||= '3';
Condition50%1/2
$param{"chopthreshold"} ||= 3
l!l
01
MC/DC0%0/1
$param{"chopthreshold"} ||= 3
$param{"chopthreshold"}
Truth table50%1/2
A
A= $param{"chopthreshold"}
Aresult
11
00
251 1 ▶ $param{notify} ||= 'none';
Condition50%1/2
$param{"notify"} ||= "none"
l!l
10
MC/DC0%0/1
$param{"notify"} ||= "none"
$param{"notify"}
Truth table50%1/2
A
A= $param{"notify"}
Aresult
11
00
252 1 ▶ $param{notifyaddr} ||= $NotifyAddr || $param{'user'} . '@' . $hostname;
Condition40%2/5
$param{"notifyaddr"} ||= $Fax::Hylafax::Client::NotifyAddr || $param{"user"} . '@' . $hostname
l!l&&r!l&&!r
010
$Fax::Hylafax::Client::NotifyAddr || $param{'user'} . '@' . $hostname
l!l
01
MC/DC0%0/2
$param{"notifyaddr"} ||= $Fax::Hylafax::Client::NotifyAddr || $param{"user"} . '@' . $hostname
$param{"notifyaddr"} $Fax::Hylafax::Client::NotifyAddr
Truth table0%0/3
A ||= B
A= $param{"notifyaddr"}B= $Fax::Hylafax::Client::NotifyAddr
ABresult
1X1
011
000
253 1 ▶ $param{sendtime} ||= 'now';
Condition50%1/2
$param{"sendtime"} ||= "now"
l!l
01
MC/DC0%0/1
$param{"sendtime"} ||= "now"
$param{"sendtime"}
Truth table50%1/2
A
A= $param{"sendtime"}
Aresult
11
00
254  
255 1 $self->{PARAM} = \%param;
256  
257 ## Basic error checking
258 1 ▶ croak __PACKAGE__ . ": *dialstring* parameter is missing" unless $param{dialstring};
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"dialstring"} 1 0 1
259 0 ▶ croak __PACKAGE__ . ": *docfile* parameter is missing" if (! $param{docfile} && ! $param{poll});
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"docfile"} or $param{"poll"} 0 0 0
Condition0%0/3
$param{"docfile"} or $param{"poll"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$param{"docfile"} or $param{"poll"}
$param{"docfile"} $param{"poll"}
Truth table0%0/3
A or B
A= $param{"docfile"}B= $param{"poll"}
ABresult
1X1
011
000
260 0 ▶ croak __PACKAGE__ . ": $param{coverfile} does not exist" if ($param{coverfile} && ! -e $param{coverfile});
Branch: 1 branch
BranchTrueFalseTotal
if $param{"coverfile"} and not -e $param{"coverfile"} 0 0 0
Condition0%0/3
$param{"coverfile"} and not -e $param{"coverfile"}
!ll&&!rl&&r
000
MC/DC0%0/2
$param{"coverfile"} and not -e $param{"coverfile"}
$param{"coverfile"} not -e $param{"coverfile"}
Truth table0%0/3
A and not(B)
A= $param{"coverfile"}B= not -e $param{"coverfile"}
ABresult
0X0
100
111
261  
262 0 ▶ if (ref(\$param{docfile}) eq 'SCALAR')
Branch: 2 branches
BranchTrueFalseTotal
if (ref \$param{'docfile'} eq 'SCALAR') { } 0 0 0
elsif (ref $param{'docfile'} eq 'ARRAY') { } 0 0 0
263 {
264 0 $param{docfiles} = [ $param{docfile} ];
265 }
266 elsif (ref($param{docfile}) eq 'ARRAY')
267 {
268 0 $param{docfiles} = $param{docfile};
269 }
270 else
271 {
272 0 croak __PACKAGE__ . ": *docfile* parameter must be a SCALAR or an ARRAY REFERENCE";
273 }
274  
275 0 foreach my $docfile (@{$param{docfiles}})
276 {
277 0 ▶ croak __PACKAGE__ . ": $docfile does not exist" if (! -e $docfile);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $docfile 0 0 0
278 }
279  
280 0 delete $param{docfile};
281  
282 ## Try to connect
283 0 ▶ my $client = Net::FTP->new($param{'host'}, Port => $param{'port'}, Passive => $param{'passive'}, Debug => $param{'debug'}) || croak __PACKAGE__ . ": " . $@;
Condition0%0/2
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}, 'Debug', $param{'debug'}) || croak('Fax::Hylafax::Client: ' . $@)
l!l
00
MC/DC0%0/1
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}, 'Debug', $param{'debug'}) || croak('Fax::Hylafax::Client: ' . $@)
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}, 'Debug', $param{'debug'})
Truth table0%0/2
A
A= 'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}, 'Debug', $param{'debug'})
Aresult
11
00
284 0 ▶ $client->login($param{'user'}, $param{'password'}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->login($param{"user"}, $param{"password"}) or _com_error($client) 0 0 0
285 0 $self->{TRACE} .= $client->message;
286 0 ▶ $client->binary || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->binary or _com_error($client) 0 0 0
287 0 $self->{TRACE} .= $client->message;
288  
289 ## Process the job
290 0 my @tempfiles = ();
291  
292 0 ▶ if ($param{coverfile})
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"coverfile"}) 0 0 0
293 {
294 0 my $unique = time . sprintf('%05d', $$) . sprintf('%04d', int(rand 10000));
295 0 my $remote = '/tmp/cover.' . $hostname . '.' . $unique;
296  
297 0 ▶ $client->put($param{coverfile}, $remote) || _com_error($client); # (STOT would be nice, but Net::FTP doesn`t support it and STOU is broken)
Branch: 1 branch
BranchTrueFalseTotal
$client->put($param{"coverfile"}, $remote) or _com_error($client) 0 0 0
298 0 $self->{TRACE} .= $client->message;
299  
300 0 push (@tempfiles, $remote);
301 }
302  
303 0 foreach my $docfile (@{$param{docfiles}})
304 {
305 0 my $unique = time . sprintf('%05d', $$) . sprintf('%04d', int(rand 10000));
306 0 my $remote = '/tmp/doc.' . $hostname . '.' . $unique;
307  
308 0 ▶ $client->put($docfile, $remote) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->put($docfile, $remote) or _com_error($client) 0 0 0
309 0 $self->{TRACE} .= $client->message;
310  
311 0 push (@tempfiles, $remote);
312 }
313  
314 0 ▶ $client->quot("jnew") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jnew") or _com_error($client) 0 0 0
315 0 $self->{TRACE} .= $client->message;
316 0 $client->message =~ /jobid: (\d+)/i;
317 0 ▶ $self->{JOB_ID} = $1 if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 0 0 0
318 0 $self->{PARAM}->{jobid} = $self->{JOB_ID};
319  
320 0 ▶ $client->quot("jparm fromuser", $param{'user'}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm fromuser", $param{"user"}) or _com_error($client) 0 0 0
321 0 $self->{TRACE} .= $client->message;
322  
323 0 ▶ $client->quot("jparm lasttime", $param{lasttime}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm lasttime", $param{"lasttime"}) or _com_error($client) 0 0 0
324 0 $self->{TRACE} .= $client->message;
325  
326 0 ▶ $client->quot("jparm maxdials", $param{maxdials}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm maxdials", $param{"maxdials"}) or _com_error($client) 0 0 0
327 0 $self->{TRACE} .= $client->message;
328  
329 0 ▶ $client->quot("jparm maxtries", $param{maxtries}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm maxtries", $param{"maxtries"}) or _com_error($client) 0 0 0
330 0 $self->{TRACE} .= $client->message;
331  
332 0 ▶ $client->quot("jparm schedpri", $param{schedpri}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm schedpri", $param{"schedpri"}) or _com_error($client) 0 0 0
333 0 $self->{TRACE} .= $client->message;
334  
335 0 ▶ $client->quot("jparm dialstring", $param{dialstring}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm dialstring", $param{"dialstring"}) or _com_error($client) 0 0 0
336 0 $self->{TRACE} .= $client->message;
337  
338 0 ▶ $client->quot("jparm sendtime", $param{sendtime}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm sendtime", $param{"sendtime"}) or _com_error($client) 0 0 0
339 0 $self->{TRACE} .= $client->message;
340  
341 0 ▶ $client->quot("jparm notifyaddr", $param{notifyaddr}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm notifyaddr", $param{"notifyaddr"}) or _com_error($client) 0 0 0
342 0 $self->{TRACE} .= $client->message;
343  
344 0 ▶ $client->quot("jparm vres", $param{vres}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm vres", $param{"vres"}) or _com_error($client) 0 0 0
345 0 $self->{TRACE} .= $client->message;
346  
347 0 ▶ $client->quot("jparm pagewidth", $param{pagewidth}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm pagewidth", $param{"pagewidth"}) or _com_error($client) 0 0 0
348 0 $self->{TRACE} .= $client->message;
349  
350 0 ▶ $client->quot("jparm pagelength", $param{pagelength}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm pagelength", $param{"pagelength"}) or _com_error($client) 0 0 0
351 0 $self->{TRACE} .= $client->message;
352  
353 0 ▶ $client->quot("jparm notify", $param{notify}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm notify", $param{"notify"}) or _com_error($client) 0 0 0
354 0 $self->{TRACE} .= $client->message;
355  
356 0 ▶ $client->quot("jparm pagechop", "default") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm pagechop", "default") or _com_error($client) 0 0 0
357 0 $self->{TRACE} .= $client->message;
358  
359 0 ▶ $client->quot("jparm chopthreshold", $param{chopthreshold}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm chopthreshold", $param{"chopthreshold"}) or _com_error($client) 0 0 0
360 0 $self->{TRACE} .= $client->message;
361  
362 0 foreach my $docfile (@tempfiles)
363 {
364 0 ▶ if ($param{coverfile} && $docfile eq $tempfiles[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($param{'coverfile'} and $docfile eq $tempfiles[0]) { } 0 0 0
Condition0%0/3
$param{"coverfile"} and $docfile eq $tempfiles[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$param{"coverfile"} and $docfile eq $tempfiles[0]
$param{"coverfile"} $docfile eq $tempfiles[0]
Truth table0%0/3
A and B
A= $param{"coverfile"}B= $docfile eq $tempfiles[0]
ABresult
0X0
100
111
365 {
366 0 ▶ $client->quot("jparm cover", $docfile) or _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm cover", $docfile) or _com_error($client) 0 0 0
367 }
368 else
369 {
370 0 ▶ $client->quot("jparm document", $docfile) or _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm document", $docfile) or _com_error($client) 0 0 0
371 }
372  
373 0 $self->{TRACE} .= $client->message;
374 }
375  
376 0 ▶ if (defined $param{poll})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $param{"poll"}) 0 0 0
377 {
378 0 my ($selector, $passwd) = split(" ", $param{poll});
379 0 ▶ $client->quot("jparm poll", $selector || "", $passwd || "") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jparm poll", $selector || "", $passwd || "") or _com_error($client) 0 0 0
Condition0%0/4
$selector || ''
l!l
00
$passwd || ''
l!l
00
MC/DC0%0/1
$selector || ''
$selector
MC/DC0%0/1
$passwd || ''
$passwd
Truth table0%0/2
A
A= $selector
Aresult
11
00
Truth table0%0/2
A
A= $passwd
Aresult
11
00
380 0 $self->{TRACE} .= $client->message;
381 }
382  
383 0 ▶ $client->quot("jsubm") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("jsubm") or _com_error($client) 0 0 0
384 0 $self->{TRACE} .= $client->message;
385 0 ▶ $self->{SUCCESS} = $client->message =~ /failed/i || $client->message =~ /failed/i? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$client->message =~ /failed/i || $client->message =~ /failed/i ? : 0 0 0
Condition0%0/3
$client->message =~ /failed/i or $client->message =~ /failed/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$client->message =~ /failed/i or $client->message =~ /failed/i
$client->message =~ /failed/i $client->message =~ /failed/i
Truth table0%0/3
A or B
A= $client->message =~ /failed/iB= $client->message =~ /failed/i
ABresult
1X1
011
000
386  
387 ## Disconnect
388 0 $client->quit;
389 0 $self->{TRACE} .= $client->message;
390  
391 0 return bless $self, __PACKAGE__ . "::Queued";
392 }
393  
394  
395 sub sendpage
396 0 ▶{
Subroutine sendpage: not called CC=35 SCAR=71.4
Pod documented
397 0 ▶ shift if $_[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq __PACKAGE__ 0 0 0
398 0 my %param = @_;
399 0 my $hostname = `hostname`; chomp $hostname;
400 0 my $unique = time . $$ . int(rand 10000);
401 0 my $self = {
402 JOB_ID => '',
403 TRACE => '',
404 SUCCESS => '',
405 };
406  
407 ## Set defaults
408 0 ▶ $param{host} ||= $Host || 'localhost';
Condition0%0/5
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Host || 'localhost'
l!l
00
MC/DC0%0/2
$param{"host"} ||= $Fax::Hylafax::Client::Host || "localhost"
$param{"host"} $Fax::Hylafax::Client::Host
Truth table0%0/3
A ||= B
A= $param{"host"}B= $Fax::Hylafax::Client::Host
ABresult
1X1
011
000
409 0 ▶ $param{port} ||= $Port || '444';
Condition0%0/5
$param{"port"} ||= $Fax::Hylafax::Client::Port || 444
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Port || '444'
l!l
00
MC/DC0%0/2
$param{"port"} ||= $Fax::Hylafax::Client::Port || 444
$param{"port"} $Fax::Hylafax::Client::Port
Truth table0%0/3
A ||= B
A= $param{"port"}B= $Fax::Hylafax::Client::Port
ABresult
1X1
011
000
410 0 ▶ $param{user} ||= $User || 'anonymous';
Condition0%0/5
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::User || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"user"} ||= $Fax::Hylafax::Client::User || "anonymous"
$param{"user"} $Fax::Hylafax::Client::User
Truth table0%0/3
A ||= B
A= $param{"user"}B= $Fax::Hylafax::Client::User
ABresult
1X1
011
000
411 0 ▶ $param{password} ||= $Password || 'anonymous';
Condition0%0/5
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Password || 'anonymous'
l!l
00
MC/DC0%0/2
$param{"password"} ||= $Fax::Hylafax::Client::Password || "anonymous"
$param{"password"} $Fax::Hylafax::Client::Password
Truth table0%0/3
A ||= B
A= $param{"password"}B= $Fax::Hylafax::Client::Password
ABresult
1X1
011
000
412 0 ▶ $param{passive} ||= $Passive || '0';
Condition0%0/5
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::Passive || '0'
l!l
00
MC/DC0%0/2
$param{"passive"} ||= $Fax::Hylafax::Client::Passive || 0
$param{"passive"} $Fax::Hylafax::Client::Passive
Truth table0%0/3
A ||= B
A= $param{"passive"}B= $Fax::Hylafax::Client::Passive
ABresult
1X1
011
000
413 0 ▶ $param{maxdials} ||= '12';
Condition0%0/2
$param{"maxdials"} ||= 12
l!l
00
MC/DC0%0/1
$param{"maxdials"} ||= 12
$param{"maxdials"}
Truth table0%0/2
A
A= $param{"maxdials"}
Aresult
11
00
414 0 ▶ $param{maxtries} ||= '3';
Condition0%0/2
$param{"maxtries"} ||= 3
l!l
00
MC/DC0%0/1
$param{"maxtries"} ||= 3
$param{"maxtries"}
Truth table0%0/2
A
A= $param{"maxtries"}
Aresult
11
00
415 0 ▶ $param{notify} ||= 'none';
Condition0%0/2
$param{"notify"} ||= "none"
l!l
00
MC/DC0%0/1
$param{"notify"} ||= "none"
$param{"notify"}
Truth table0%0/2
A
A= $param{"notify"}
Aresult
11
00
416 0 ▶ $param{notifyaddr} ||= $NotifyAddr || $param{'user'} . '@' . $hostname;
Condition0%0/5
$param{"notifyaddr"} ||= $Fax::Hylafax::Client::NotifyAddr || $param{"user"} . '@' . $hostname
l!l&&r!l&&!r
000
$Fax::Hylafax::Client::NotifyAddr || $param{'user'} . '@' . $hostname
l!l
00
MC/DC0%0/2
$param{"notifyaddr"} ||= $Fax::Hylafax::Client::NotifyAddr || $param{"user"} . '@' . $hostname
$param{"notifyaddr"} $Fax::Hylafax::Client::NotifyAddr
Truth table0%0/3
A ||= B
A= $param{"notifyaddr"}B= $Fax::Hylafax::Client::NotifyAddr
ABresult
1X1
011
000
417 0 ▶ $param{level} ||= '1';
Condition0%0/2
$param{"level"} ||= 1
l!l
00
MC/DC0%0/1
$param{"level"} ||= 1
$param{"level"}
Truth table0%0/2
A
A= $param{"level"}
Aresult
11
00
418  
419 0 $self->{PARAM} = \%param;
420  
421 ## Basic error checking
422 0 ▶ croak __PACKAGE__ . ": *pin* parameter is missing" unless $param{pin};
Branch: 1 branch
BranchTrueFalseTotal
unless $param{"pin"} 0 0 0
423  
424 ## Try to connect
425 0 ▶ my $client = Net::FTP->new($param{'host'}, Port => $param{'port'}, Passive => $param{'passive'}) || croak __PACKAGE__ . ": " . $@;
Condition0%0/2
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
l!l
00
MC/DC0%0/1
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'}) || croak('Fax::Hylafax::Client: ' . $@)
'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Truth table0%0/2
A
A= 'Net::FTP'->new($param{'host'}, 'Port', $param{'port'}, 'Passive', $param{'passive'})
Aresult
11
00
426 0 ▶ $client->quot("logi", $param{user}, $param{password}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("logi", $param{"user"}, $param{"password"}) or _com_error($client) 0 0 0
427 0 $self->{TRACE} .= $client->message;
428  
429 ## Process the job
430 0 ▶ $client->quot("site help", "notify") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("site help", "notify") or _com_error($client) 0 0 0
431 0 $self->{TRACE} .= $client->message;
432  
433 0 ▶ $client->quot("leve", $param{level}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("leve", $param{"level"}) or _com_error($client) 0 0 0
434 0 $self->{TRACE} .= $client->message;
435  
436 0 ▶ $client->quot("site fromuser", $param{'user'}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("site fromuser", $param{"user"}) or _com_error($client) 0 0 0
437 0 $self->{TRACE} .= $client->message;
438  
439 0 ▶ $client->quot("site maxdials", $param{maxdials}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("site maxdials", $param{"maxdials"}) or _com_error($client) 0 0 0
440 0 $self->{TRACE} .= $client->message;
441  
442 0 ▶ $client->quot("site maxtries", $param{maxtries}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("site maxtries", $param{"maxtries"}) or _com_error($client) 0 0 0
443 0 $self->{TRACE} .= $client->message;
444  
445 0 ▶ $client->quot("site mailaddr", $param{notifyaddr}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("site mailaddr", $param{"notifyaddr"}) or _com_error($client) 0 0 0
446 0 $self->{TRACE} .= $client->message;
447  
448 0 ▶ $client->quot("site notify", $param{notify}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("site notify", $param{"notify"}) or _com_error($client) 0 0 0
449 0 $self->{TRACE} .= $client->message;
450  
451 0 ▶ $client->quot("site jqueue", "yes") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("site jqueue", "yes") or _com_error($client) 0 0 0
452 0 $self->{TRACE} .= $client->message;
453  
454 0 ▶ $client->quot("page", $param{pin}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("page", $param{"pin"}) or _com_error($client) 0 0 0
455 0 $self->{TRACE} .= $client->message;
456 0 $client->message =~ /jobid: (\d+)\./i;
457 0 ▶ $self->{JOB_ID} = $1 if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 0 0 0
458 0 $self->{PARAM}->{jobid} = $self->{JOB_ID};
459  
460 0 ▶ if ($param{message})
Branch: 1 branch
BranchTrueFalseTotal
if ($param{"message"}) 0 0 0
461 {
462 0 ▶ $client->quot("mess", $param{message}) || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("mess", $param{"message"}) or _com_error($client) 0 0 0
463 0 $self->{TRACE} .= $client->message;
464 }
465  
466 0 ▶ $client->quot("send") || _com_error($client);
Branch: 1 branch
BranchTrueFalseTotal
$client->quot("send") or _com_error($client) 0 0 0
467 0 $self->{TRACE} .= $client->message;
468 0 ▶ $self->{SUCCESS} = $client->message =~ /success/i ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$client->message =~ /success/i ? : 0 0 0
469  
470 ## Disconnect
471 0 $client->quit;
472 0 $self->{TRACE} .= $client->message;
473  
474 0 return bless $self, __PACKAGE__ . "::Queued";
475 }
476  
477 ######################################################################
478  
479 sub _com_error
480 0 ▶{
Subroutine _com_error: not called CC=1 SCAR=6.9
481 0 my $client = shift;
482 0 croak __PACKAGE__ . ": Communication error: " . $client->message;
483 }
484  
485  
486 sub _content
487 0 ▶{
Subroutine _content: not called CC=2 SCAR=17.9
488 0 my $class = shift;
489 0 my $self = shift;
490 0 ▶ return $self->{CONTENT} || undef;
Condition0%0/2
$self->{'CONTENT'} || undef
l!l
00
MC/DC0%0/1
$self->{'CONTENT'} || undef
$self->{'CONTENT'}
Truth table0%0/2
A
A= $self->{'CONTENT'}
Aresult
11
00
491 }
492  
493  
494 sub _success
495 0 ▶{
Subroutine _success: not called CC=2 SCAR=17.9
496 0 my $class = shift;
497 0 my $self = shift;
498 0 ▶ return $self->{SUCCESS} || undef;
Condition0%0/2
$self->{'SUCCESS'} || undef
l!l
00
MC/DC0%0/1
$self->{'SUCCESS'} || undef
$self->{'SUCCESS'}
Truth table0%0/2
A
A= $self->{'SUCCESS'}
Aresult
11
00
499 }
500  
501  
502 sub _trace
503 0 ▶{
Subroutine _trace: not called CC=2 SCAR=17.9
504 0 my $class = shift;
505 0 my $self = shift;
506 0 ▶ return $self->{TRACE} || undef;
Condition0%0/2
$self->{'TRACE'} || undef
l!l
00
MC/DC0%0/1
$self->{'TRACE'} || undef
$self->{'TRACE'}
Truth table0%0/2
A
A= $self->{'TRACE'}
Aresult
11
00
507 }
508  
509 ######################################################################
510  
511 package Fax::Hylafax::Client::Queued;
512  
513  
514 sub faxinfo
515 0 ▶{
Subroutine faxinfo: not called CC=1 SCAR=6.9
516 0 my $self = shift;
517 0 my $conn = Fax::Hylafax::Client->faxinfo(%{$self->{PARAM}});
518 0 $self->{TRACE} = $conn->trace;
519 0 $self->{SUCCESS} = $conn->success;
520 0 return $conn->content;
521 }
522  
523  
524 sub faxrm
525 0 ▶{
Subroutine faxrm: not called CC=1 SCAR=6.9
526 0 my $self = shift;
527 0 my $conn = Fax::Hylafax::Client->faxrm(%{$self->{PARAM}});
528 0 $self->{TRACE} = $conn->trace;
529 0 $self->{SUCCESS} = $conn->success;
530 0 return $conn->success;
531 }
532  
533  
534 sub jobid
535 0 ▶{
Subroutine jobid: not called CC=1 SCAR=6.9
536 0 my $self = shift;
537 0 return $self->{JOB_ID};
538 }
539  
540  
541 sub success
542 0 ▶{
Subroutine success: not called CC=1 SCAR=6.9
543 0 return Fax::Hylafax::Client->_success(shift);
544 }
545  
546  
547 sub trace
548 0 ▶{
Subroutine trace: not called CC=1 SCAR=6.9
549 0 return Fax::Hylafax::Client->_trace(shift);
550 }
551  
552 ######################################################################
553  
554 package Fax::Hylafax::Client::Instant;
555  
556  
557 sub content
558 0 ▶{
Subroutine content: not called CC=1 SCAR=6.9
559 0 return Fax::Hylafax::Client->_content(shift);
560 }
561  
562  
563 sub success
564 0 ▶{
Subroutine success: not called CC=1 SCAR=6.9
565 0 return Fax::Hylafax::Client->_success(shift);
566 }
567  
568  
569 sub trace
570 0 ▶{
Subroutine trace: not called CC=1 SCAR=6.9
571 0 return Fax::Hylafax::Client->_trace(shift);
572 }
573  
574 ######################################################################
575  
576 1 1;
577  
578 __END__
↑ Summary