blib/lib/Net/XMPP/Connection.pm

filter: Statementstmt 36.0% 66 / 183 Branchbran 15.5% 14 / 90 Conditioncond 12.1% 4 / 33 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 61.9% 13 / 21 Podpod 12.5% 1 / 8 totaltotal 27.4% 98 / 357 SCAR 71.7
CC
57
Cov
27%
Execute
930.0
Connect
86.3
Process
36.8
CRAP 1297.6
« blib/lib/Net/XMPP/Protocol.pm ↑ Summary blib/lib/Net/XMPP/Stanza.pm »
1 ##############################################################################
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Library General Public
5 # License as published by the Free Software Foundation; either
6 # version 2 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Library General Public License for more details.
12 #
13 # You should have received a copy of the GNU Library General Public
14 # License along with this library; if not, write to the
15 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 # Boston, MA 02111-1307, USA.
17 #
18 # Copyright (C) 1998-2004 Jabber Software Foundation http://jabber.org/
19 #
20 ##############################################################################
21  
22 package Net::XMPP::Connection;
23  
24 =head1 NAME
25  
26 Net::XMPP::Connection - XMPP Connection Module
27  
28 =head1 SYNOPSIS
29  
30 Net::XMPP::Connection is a private package that serves as a basis
31 for anything wanting to open a socket connection to a server.
32  
33 =head1 DESCRIPTION
34  
35 This module is not meant to be used directly. You should be using
36 either Net::XMPP::Client, or another package that inherits from
37 Net::XMPP::Connection.
38  
39 =head1 AUTHOR
40  
41 Originally authored by Ryan Eatmon.
42  
43 Previously maintained by Eric Hacker.
44  
45 Currently maintained by Darian Anthony Patrick.
46  
47 =head1 COPYRIGHT
48  
49 This module is free software, you can redistribute it and/or modify it
50 under the LGPL 2.1.
51  
52 =cut
53  
54 15 require 5.008;
55 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 15 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 15 ▶use XML::Stream;
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 15 ▶use Net::XMPP::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 15 ▶use Net::XMPP::Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 15 ▶use base qw( Net::XMPP::Protocol );
Subroutine BEGIN: called CC=1 SCAR=0.0
67  
68 sub new
69 {
70 0 ▶ my $proto = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my $self = { };
72  
73 0 bless($self, $proto);
74  
75 0 $self->init(@_);
76  
77 0 $self->{SERVER}->{namespace} = "unknown";
78  
79 0 return $self;
80 }
81  
82  
83 ##############################################################################
84 #
85 # init - do all of the heavy lifting for a generic connection.
86 #
87 ##############################################################################
88 sub init
89 {
90 4 ▶ my $self = shift;
Subroutine init: called CC=3 SCAR=11.1
Pod undocumented
91  
92 4 $self->{ARGS} = {};
93 4 ▶ while($#_ >= 0) { $self->{ARGS}->{ lc(pop(@_)) } = pop(@_); }
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 4 4
94  
95 $self->{DEBUG} =
96 4 Net::XMPP::Debug->new(level => $self->_arg("debuglevel",-1),
97 file => $self->_arg("debugfile","stdout"),
98 time => $self->_arg("debugtime",0),
99 setdefault => 1,
100 header => "XMPP::Conn"
101 );
102  
103 4 $self->{SERVER} = {};
104 4 $self->{SERVER}->{hostname} = "localhost";
105 4 $self->{SERVER}->{tls} = $self->_arg("tls",0);
106 4 $self->{SERVER}->{ssl} = $self->_arg("ssl",0);
107 4 $self->{SERVER}->{connectiontype} = $self->_arg("connectiontype","tcpip");
108  
109 4 $self->{CONNECTED} = 0;
110 4 $self->{DISCONNECTED} = 0;
111  
112 $self->{STREAM} =
113 XML::Stream->new(style => "node",
114 debugfh => $self->{DEBUG}->GetHandle(),
115 #debugfh => weaken $self->{DEBUG}->GetHandle(),
116 debuglevel => $self->{DEBUG}->GetLevel(),
117 4 debugtime => $self->{DEBUG}->GetTime(),
118 );
119  
120 4 $self->{RCVDB}->{currentID} = 0;
121  
122 4 $self->InitCallbacks();
123  
124 # weaken $self->{STREAM};
125 4 ▶ weaken $self->{CB} if $self->{CB};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CB"} 4 0 4
126  
127 4 return $self;
128 }
129  
130  
131 ##############################################################################
132 #
133 # Connect - Takes a has and opens the connection to the specified server.
134 # Registers CallBack as the main callback for all packets from
135 # the server.
136 #
137 # NOTE: Need to add some error handling if the connection is
138 # not made because the server hostname is wrong or whatnot.
139 #
140 ##############################################################################
141 sub Connect
142 {
143 2 ▶ my $self = shift;
Subroutine Connect: called CC=16 SCAR=44.6
Pod undocumented
144  
145 2 ▶ while($#_ >= 0) { $self->{SERVER}{ lc pop(@_) } = pop(@_); }
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 12 2 14
146  
147 2 ▶ $self->{SERVER}->{timeout} = 10 unless exists($self->{SERVER}->{timeout});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"SERVER"}{"timeout"} 2 0 2
148  
149 2 $self->{DEBUG}->Log1("Connect: host($self->{SERVER}->{hostname}:$self->{SERVER}->{port}) namespace($self->{SERVER}->{namespace})");
150 2 $self->{DEBUG}->Log1("Connect: timeout($self->{SERVER}->{timeout})");
151  
152 2 delete($self->{SESSION});
153 $self->{SESSION} =
154 $self->{STREAM}->
155 Connect(hostname => $self->{SERVER}->{hostname},
156 port => $self->{SERVER}->{port},
157 namespace => $self->{SERVER}->{namespace},
158 connectiontype => $self->{SERVER}->{connectiontype},
159 timeout => $self->{SERVER}->{timeout},
160 ( defined $self->{SERVER}->{ssl_ca_path}
161 && '' ne $self->{SERVER}->{ssl_ca_path}
162 ? (ssl_ca_path => $self->{SERVER}->{ssl_ca_path})
163 : ()
164 ),
165 ( defined $self->{SERVER}->{ssl_verify}
166 && '' ne $self->{SERVER}->{ssl_verify}
167 ? (ssl_verify => $self->{SERVER}->{ssl_verify})
168 : ()
169 ),
170 ssl => $self->{SERVER}->{ssl}, #LEGACY
171 _tls => $self->{SERVER}->{tls},
172 ( defined $self->{SERVER}->{componentname}
173 ? (to => $self->{SERVER}->{componentname})
174 : ()
175 ),
176 ( defined $self->{SERVER}->{srv}
177 2 ▶ ? (srv => '_xmpp-client._tcp')
Branch: 4 branches
BranchTrueFalseTotal
defined $self->{'SERVER'}{'ssl_ca_path'} && '' ne $self->{'SERVER'}{'ssl_ca_path'} ? : 0 2 2
defined $self->{'SERVER'}{'ssl_verify'} && '' ne $self->{'SERVER'}{'ssl_verify'} ? : 2 0 2
defined $self->{'SERVER'}{'componentname'} ? : 2 0 2
defined $self->{'SERVER'}{'srv'} ? : 0 2 2
Condition33%2/6
defined $self->{"SERVER"}{"ssl_ca_path"} and "" ne $self->{"SERVER"}{"ssl_ca_path"}
!ll&&!rl&&r
200
defined $self->{"SERVER"}{"ssl_verify"} and "" ne $self->{"SERVER"}{"ssl_verify"}
!ll&&!rl&&r
002
MC/DC0%0/2
defined $self->{"SERVER"}{"ssl_ca_path"} and "" ne $self->{"SERVER"}{"ssl_ca_path"}
defined $self->{"SERVER"}{"ssl_ca_path"} "" ne $self->{"SERVER"}{"ssl_ca_path"}
MC/DC0%0/2
defined $self->{"SERVER"}{"ssl_verify"} and "" ne $self->{"SERVER"}{"ssl_verify"}
defined $self->{"SERVER"}{"ssl_verify"} "" ne $self->{"SERVER"}{"ssl_verify"}
Truth table33%1/3
A and B
A= defined $self->{"SERVER"}{"ssl_ca_path"}B= "" ne $self->{"SERVER"}{"ssl_ca_path"}
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= defined $self->{"SERVER"}{"ssl_verify"}B= "" ne $self->{"SERVER"}{"ssl_verify"}
ABresult
0X0
100
111
178 : ()
179 ),
180 );
181  
182 2 ▶ if ($self->{SESSION})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'SESSION'}) { } 0 2 2
183 {
184 0 $self->{DEBUG}->Log1("Connect: connection made");
185  
186 0 my $weak = $self;
187 0 weaken $weak;
188 0 ▶ $self->{STREAM}->SetCallBacks(node=>sub{ $weak->CallBack(@_) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
189 0 $self->{CONNECTED} = 1;
190 0 $self->{RECONNECTING} = 0;
191  
192 0 ▶ if (exists($self->{SESSION}->{version}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"SESSION"}{"version"} and $self->{"SESSION"}{"version"} ne "") 0 0 0
Condition0%0/3
exists $self->{"SESSION"}{"version"} and $self->{"SESSION"}{"version"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"SESSION"}{"version"} and $self->{"SESSION"}{"version"} ne ""
exists $self->{"SESSION"}{"version"} $self->{"SESSION"}{"version"} ne ""
Truth table0%0/3
A and B
A= exists $self->{"SESSION"}{"version"}B= $self->{"SESSION"}{"version"} ne ""
ABresult
0X0
100
111
193 ($self->{SESSION}->{version} ne ""))
194 {
195 0 my $tls = $self->GetStreamFeature("xmpp-tls");
196 0 ▶ if (defined($tls) && $self->{SERVER}->{tls})
Branch: 2 branches
BranchTrueFalseTotal
if (defined $tls and $self->{'SERVER'}{'tls'}) { } 0 0 0
elsif (defined $tls and $tls eq 'required') { } 0 0 0
Condition0%0/3
defined $tls and $self->{"SERVER"}{"tls"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tls and $self->{"SERVER"}{"tls"}
defined $tls $self->{"SERVER"}{"tls"}
Truth table0%0/3
A and B
A= defined $tlsB= $self->{"SERVER"}{"tls"}
ABresult
0X0
100
111
197 {
198 $self->{SESSION} =
199 $self->{STREAM}->StartTLS(
200 $self->{SESSION}->{id},
201 $self->{SERVER}->{timeout},
202 0 );
203 }
204 ▶ elsif (defined($tls) && ($tls eq "required"))
Condition0%0/3
defined $tls and $tls eq "required"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tls and $tls eq "required"
defined $tls $tls eq "required"
Truth table0%0/3
A and B
A= defined $tlsB= $tls eq "required"
ABresult
0X0
100
111
205 {
206 0 $self->SetErrorCode("The server requires us to use TLS, but you did not specify that\nTLS was an option.");
207 0 return;
208 }
209 }
210  
211 0 return 1;
212 }
213 else
214 {
215 2 $self->SetErrorCode($self->{STREAM}->GetErrorCode());
216 2 return;
217 }
218 }
219  
220  
221 ##############################################################################
222 #
223 # Connected - returns 1 if the Transport is connected to the server, 0
224 # otherwise.
225 #
226 ##############################################################################
227 sub Connected
228 {
229 0 ▶ my $self = shift;
Subroutine Connected: not called CC=1 SCAR=6.9
Pod undocumented
230  
231 0 $self->{DEBUG}->Log1("Connected: ($self->{CONNECTED})");
232 0 return $self->{CONNECTED};
233 }
234  
235  
236 ##############################################################################
237 #
238 # Disconnect - Sends the string to close the connection cleanly.
239 #
240 ##############################################################################
241 sub Disconnect
242 {
243 0 ▶ my $self = shift;
Subroutine Disconnect: not called CC=2 SCAR=17.9
Pod undocumented
244  
245 $self->{STREAM}->Disconnect($self->{SESSION}->{id})
246 0 ▶ if ($self->{CONNECTED} == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CONNECTED"} == 1 0 0 0
247 0 $self->{STREAM}->SetCallBacks(node=>undef);
248 0 $self->{CONNECTED} = 0;
249 0 $self->{DISCONNECTED} = 1;
250 0 $self->{RECONNECTING} = 0;
251 0 $self->{DEBUG}->Log1("Disconnect: bye bye");
252 }
253  
254  
255 ##############################################################################
256 #
257 # Execute - generic inner loop to listen for incoming messages, stay
258 # connected to the server, and do all the right things. It
259 # calls a couple of callbacks for the user to put hooks into
260 # place if they choose to.
261 #
262 ##############################################################################
263 sub Execute
264 {
265 0 ▶ my $self = shift;
Subroutine Execute: not called CC=30 SCAR=68.4
Pod undocumented
266 0 my %args;
267 0 ▶ while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
268  
269 0 ▶ $args{connectiontype} = "tcpip" unless exists($args{connectiontype});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"connectiontype"} 0 0 0
270 0 ▶ $args{connectattempts} = -1 unless exists($args{connectattempts});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"connectattempts"} 0 0 0
271 0 ▶ $args{connectsleep} = 5 unless exists($args{connectsleep});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"connectsleep"} 0 0 0
272 0 ▶ $args{register} = 0 unless exists($args{register});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"register"} 0 0 0
273  
274 0 my %connect = $self->_connect_args(%args);
275  
276 0 $self->{DEBUG}->Log1("Execute: begin");
277  
278 0 my $connectAttempt = $args{connectattempts};
279  
280 0 ▶ while(($connectAttempt == -1) || ($connectAttempt > 0))
Branch: 1 branch
BranchTrueFalseTotal
if ($connectAttempt == -1 or $connectAttempt > 0) 0 0 0
Condition0%0/3
$connectAttempt == -1 or $connectAttempt > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$connectAttempt == -1 or $connectAttempt > 0
$connectAttempt == -1 $connectAttempt > 0
Truth table0%0/3
A or B
A= $connectAttempt == -1B= $connectAttempt > 0
ABresult
1X1
011
000
281 {
282  
283 0 $self->{DEBUG}->Log1("Execute: Attempt to connect ($connectAttempt)");
284  
285 0 my $status = $self->Connect(%connect);
286  
287 0 ▶ if (!(defined($status)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $status) 0 0 0
288 {
289 0 $self->{DEBUG}->Log1("Execute: Server is not answering. (".$self->GetErrorCode().")");
290 0 $self->{CONNECTED} = 0;
291  
292 0 ▶ $connectAttempt-- unless ($connectAttempt == -1);
Branch: 1 branch
BranchTrueFalseTotal
unless $connectAttempt == -1 0 0 0
293 0 sleep($args{connectsleep});
294 0 next;
295 }
296  
297 0 $self->{DEBUG}->Log1("Execute: Connected...");
298 0 ▶ &{$self->{CB}->{onconnect}}() if exists($self->{CB}->{onconnect});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"onconnect"} 0 0 0
299  
300 0 my @result = $self->_auth(%args);
301  
302 0 ▶ if (@result && $result[0] ne "ok")
Branch: 1 branch
BranchTrueFalseTotal
if (@result and $result[0] ne 'ok') { } 0 0 0
Condition0%0/3
@result and $result[0] ne "ok"
!ll&&!rl&&r
000
MC/DC0%0/2
@result and $result[0] ne "ok"
@result $result[0] ne "ok"
Truth table0%0/3
A and B
A= @resultB= $result[0] ne "ok"
ABresult
0X0
100
111
303 {
304 0 $self->{DEBUG}->Log1("Execute: Could not auth with server: ($result[0]: $result[1])");
305 0 &{$self->{CB}->{onauthfail}}()
306 0 ▶ if exists($self->{CB}->{onauthfail});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"onauthfail"} 0 0 0
307  
308 0 ▶ if (!$self->{SERVER}->{allow_register} || $args{register} == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'SERVER'}{'allow_register'} or $args{'register'} == 0) { } 0 0 0
Condition0%0/3
not $self->{"SERVER"}{"allow_register"} or $args{"register"} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->{"SERVER"}{"allow_register"} or $args{"register"} == 0
not $self->{"SERVER"}{"allow_register"} $args{"register"} == 0
Truth table0%0/3
not(A) or B
A= not $self->{"SERVER"}{"allow_register"}B= $args{"register"} == 0
ABresult
1X1
011
000
309 {
310 0 $self->{DEBUG}->Log1("Execute: Register turned off. Exiting.");
311 0 $self->Disconnect();
312 0 &{$self->{CB}->{ondisconnect}}()
313 0 ▶ if exists($self->{CB}->{ondisconnect});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"ondisconnect"} 0 0 0
314 0 $connectAttempt = 0;
315 }
316 else
317 {
318 0 @result = $self->_register(%args);
319  
320 0 ▶ if ($result[0] ne "ok")
Branch: 1 branch
BranchTrueFalseTotal
if ($result[0] ne 'ok') { } 0 0 0
321 {
322 0 $self->{DEBUG}->Log1("Execute: Register failed. Exiting.");
323 0 &{$self->{CB}->{onregisterfail}}()
324 0 ▶ if exists($self->{CB}->{onregisterfail});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"onregisterfail"} 0 0 0
325  
326 0 $self->Disconnect();
327 0 &{$self->{CB}->{ondisconnect}}()
328 0 ▶ if exists($self->{CB}->{ondisconnect});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"ondisconnect"} 0 0 0
329 0 $connectAttempt = 0;
330 }
331 else
332 {
333 0 &{$self->{CB}->{onauth}}()
334 0 ▶ if exists($self->{CB}->{onauth});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"onauth"} 0 0 0
335 }
336 }
337 }
338 else
339 {
340 0 &{$self->{CB}->{onauth}}()
341 0 ▶ if exists($self->{CB}->{onauth});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"onauth"} 0 0 0
342 }
343  
344 0 ▶ while($self->Connected())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->Connected) 0 0 0
345 {
346  
347 0 ▶ while(defined($status = $self->Process($args{processtimeout})))
Branch: 1 branch
BranchTrueFalseTotal
if (defined($status = $self->Process($args{"processtimeout"}))) 0 0 0
348 {
349 0 &{$self->{CB}->{onprocess}}()
350 0 ▶ if exists($self->{CB}->{onprocess});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"onprocess"} 0 0 0
351 }
352  
353 0 ▶ if (!defined($status))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $status) 0 0 0
354 {
355 0 $self->Disconnect();
356 0 $self->{RECONNECTING} = 1;
357 0 delete($self->{PROCESSERROR});
358 0 $self->{DEBUG}->Log1("Execute: Connection to server lost...");
359 0 &{$self->{CB}->{ondisconnect}}()
360 0 ▶ if exists($self->{CB}->{ondisconnect});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"ondisconnect"} 0 0 0
361  
362 0 $connectAttempt = $args{connectattempts};
363 0 next;
364 }
365 }
366  
367 0 ▶ last if (!$self->{RECONNECTING} && $self->{DISCONNECTED});
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"RECONNECTING"} and $self->{"DISCONNECTED"} 0 0 0
Condition0%0/3
not $self->{"RECONNECTING"} and $self->{"DISCONNECTED"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"RECONNECTING"} and $self->{"DISCONNECTED"}
not $self->{"RECONNECTING"} $self->{"DISCONNECTED"}
Truth table0%0/3
not(A) and B
A= not $self->{"RECONNECTING"}B= $self->{"DISCONNECTED"}
ABresult
0X0
100
111
368 }
369  
370 0 $self->{DEBUG}->Log1("Execute: end");
371 0 ▶ &{$self->{CB}->{onexit}}() if exists($self->{CB}->{onexit});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"CB"}{"onexit"} 0 0 0
372 }
373  
374  
375 ##############################################################################
376 #
377 # InitCallbacks - initialize the callbacks
378 #
379 ##############################################################################
380 sub InitCallbacks
381 {
382 4 ▶ my $self = shift;
Subroutine InitCallbacks: called CC=1 SCAR=0.0
Pod undocumented
383  
384 4 $self->xmppCallbackInit();
385 }
386  
387 ###############################################################################
388 #
389 # Process - If a timeout value is specified then the function will wait
390 # that long before returning. This is useful for apps that
391 # need to handle other processing while still waiting for
392 # packets. If no timeout is listed then the function waits
393 # until a packet is returned. Either way the function exits
394 # as soon as a packet is returned.
395 #
396 ###############################################################################
397 sub Process
398 {
399 1 ▶ my $self = shift;
Subroutine Process: called CC=9 SCAR=36.1
Pod documented
400 1 my ($timeout) = @_;
401 1 my %status;
402  
403 1 ▶ if (exists($self->{PROCESSERROR}) && ($self->{PROCESSERROR} == 1))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"PROCESSERROR"} and $self->{"PROCESSERROR"} == 1) 0 1 1
Condition33%1/3
exists $self->{"PROCESSERROR"} and $self->{"PROCESSERROR"} == 1
!ll&&!rl&&r
100
MC/DC0%0/2
exists $self->{"PROCESSERROR"} and $self->{"PROCESSERROR"} == 1
exists $self->{"PROCESSERROR"} $self->{"PROCESSERROR"} == 1
Truth table33%1/3
A and B
A= exists $self->{"PROCESSERROR"}B= $self->{"PROCESSERROR"} == 1
ABresult
0X0
100
111
404 {
405 0 croak("There was an error in the last call to Process that you did not check for and\nhandle. You should always check the output of the Process call. If it was\nundef then there was a fatal error that you need to check. There is an error\nin your program");
406 }
407  
408 1 ▶ $self->{DEBUG}->Log1("Process: timeout($timeout)") if defined($timeout);
Branch: 1 branch
BranchTrueFalseTotal
if defined $timeout 1 0 1
409  
410 1 ▶ if (!defined($timeout) || ($timeout eq ""))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $timeout or $timeout eq '') { } 0 1 1
Condition33%1/3
not defined $timeout or $timeout eq ""
l!l&&r!l&&!r
001
MC/DC0%0/2
not defined $timeout or $timeout eq ""
not defined $timeout $timeout eq ""
Truth table33%1/3
not(A) or B
A= not defined $timeoutB= $timeout eq ""
ABresult
1X1
011
000
411 {
412 0 while(1)
413 {
414 0 %status = $self->{STREAM}->Process();
415 0 $self->{DEBUG}->Log1("Process: status($status{$self->{SESSION}->{id}})");
416 0 ▶ last if ($status{$self->{SESSION}->{id}} != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $status{$self->{"SESSION"}{"id"}} != 0 0 0 0
417 0 select(undef,undef,undef,.25);
418 }
419 0 $self->{DEBUG}->Log1("Process: return($status{$self->{SESSION}->{id}})");
420 0 ▶ if ($status{$self->{SESSION}->{id}} == -1)
Branch: 1 branch
BranchTrueFalseTotal
if ($status{$self->{'SESSION'}{'id'}} == -1) { } 0 0 0
421 {
422 0 $self->{PROCESSERROR} = 1;
423 0 return;
424 }
425 else
426 {
427 0 return $status{$self->{SESSION}->{id}};
428 }
429 }
430 else
431 {
432 1 %status = $self->{STREAM}->Process($timeout);
433 0 ▶ if ($status{$self->{SESSION}->{id}} == -1)
Branch: 1 branch
BranchTrueFalseTotal
if ($status{$self->{'SESSION'}{'id'}} == -1) { } 0 0 0
434 {
435 0 $self->{PROCESSERROR} = 1;
436 0 return;
437 }
438 else
439 {
440 0 return $status{$self->{SESSION}->{id}};
441 }
442 }
443 }
444  
445  
446  
447  
448 ##############################################################################
449 #+----------------------------------------------------------------------------
450 #|
451 #| Overloadable Methods
452 #|
453 #+----------------------------------------------------------------------------
454 ##############################################################################
455  
456 ##############################################################################
457 #
458 # _auth - Overload this method to provide the authentication method for your
459 # type of connection.
460 #
461 ##############################################################################
462 sub _auth
463 {
464 0 ▶ my $self = shift;
Subroutine _auth: not called CC=1 SCAR=6.9
465 0 croak("You must override the _auth method.");
466 }
467  
468  
469 ##############################################################################
470 #
471 # _connect_args - The Connect function that the Execute loop uses needs
472 # certain args. This method lets you map the Execute args
473 # into the Connect args for your Connection type.
474 #
475 ##############################################################################
476 sub _connect_args
477 {
478 0 ▶ my $self = shift;
Subroutine _connect_args: not called CC=1 SCAR=6.9
479 0 my (%args) = @_;
480  
481 0 return %args;
482 }
483  
484  
485 ##############################################################################
486 #
487 # _register - overload this method if you need your connection to register
488 # with the server.
489 #
490 ##############################################################################
491 sub _register
492 {
493 0 ▶ my $self = shift;
Subroutine _register: not called CC=1 SCAR=6.9
494 0 return ( "ok" ,"" );
495 }
496  
497  
498  
499  
500 ##############################################################################
501 #+----------------------------------------------------------------------------
502 #|
503 #| Private Helpers
504 #|
505 #+----------------------------------------------------------------------------
506 ##############################################################################
507  
508 sub _arg
509 {
510 24 ▶ my $self = shift;
Subroutine _arg: called CC=2 SCAR=7.0
511 24 my $arg = shift;
512 24 my $default = shift;
513  
514 24 ▶ return exists($self->{ARGS}->{$arg}) ? $self->{ARGS}->{$arg} : $default;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'ARGS'}{$arg} ? : 0 24 24
515 }
516  
517  
518 15 1;
« blib/lib/Net/XMPP/Protocol.pm ↑ Summary blib/lib/Net/XMPP/Stanza.pm »