XMPP/Roster.pm

filter: Statementstmt 78.9% 214 / 271 Branchbran 54.2% 90 / 166 Conditioncond 36.1% 26 / 72 MC/DCmcdc 10.8% 5 / 46 Subroutinesub 75.7% 25 / 33 Podpod 52.0% 13 / 25 totaltotal 60.8% 373 / 613 CC 118 SCAR 31.4
CC
118
Cov
65%
handlePresence
182.0
jids
14.3
removeResource
12.1
CRAP 23.1
« XMPP/Stanza.pm ↑ Summary XMPP/JID.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::Roster;
23  
24 =head1 NAME
25  
26 Net::XMPP::Roster - XMPP Roster Object
27  
28 =head1 SYNOPSIS
29  
30 Net::XMPP::Roster is a module that provides a developer an easy
31 interface to an XMPP roster. It provides high level functions to
32 query, update, and manage a user's roster.
33  
34 =head1 DESCRIPTION
35  
36 The Roster object seeks to provide an easy to use API for interfacing
37 with a user's roster. When you instantiate it, it automatically
38 registers with the connection to receivce the correct packets so
39 that it can track all roster updates, and presence packets.
40  
41 =head2 Basic Functions
42  
43 my $Client = Net::XMPP::Client->new(...);
44  
45 my $Roster = Net::XMPP::Roster->new(connection=>$Client);
46 or
47 my $Roster = $Client->Roster();
48  
49 $Roster->clear();
50  
51 if ($Roster->exists('bob@jabber.org')) { ... }
52 if ($Roster->exists(Net::XMPP::JID)) { ... }
53  
54 if ($Roster->groupExists("Friends")) { ... }
55  
56 my @groups = $Roster->groups();
57  
58 my @jids = $Roster->jids();
59 my @friends = $Roster->jids("group","Friends");
60 my @unfiled = $Roster->jids("nogroup");
61  
62 if ($Roster->online('bob@jabber.org')) { ... }
63 if ($Roster->online(Net::XMPP::JID)) { ... }
64  
65 my %hash = $Roster->query('bob@jabber.org');
66 my %hash = $Roster->query(Net::XMPP::JID);
67  
68 my $name = $Roster->query('bob@jabber.org',"name");
69 my $ask = $Roster->query(Net::XMPP::JID,"ask");
70  
71 my $resource = $Roster->resource('bob@jabber.org');
72 my $resource = $Roster->resource(Net::XMPP::JID);
73  
74 my %hash = $Roster->resourceQuery('bob@jabber.org',"Home");
75 my %hash = $Roster->resourceQuery(Net::XMPP::JID,"Club");
76  
77 my $show = $Roster->resourceQuery('bob@jabber.org',"Home","show");
78 my $status = $Roster->resourceQuery(Net::XMPP::JID,"Work","status");
79  
80 my @resource = $Roster->resources('bob@jabber.org');
81 my @resource = $Roster->resources(Net::XMPP::JID);
82  
83 $Roster->resourceStore('bob@jabber.org',"Home","gpgkey",key);
84 $Roster->resourceStore(Net::XMPP::JID,"logged on","2004/04/07 ...");
85  
86 $Roster->store('bob@jabber.org',"avatar",avatar);
87 $Roster->store(Net::XMPP::JID,"display_name","Bob");
88  
89 =head2 Advanced Functions
90  
91 These functions are only needed if you want to manually control
92 the Roster.
93  
94 $Roster->add('bob@jabber.org',
95 name=>"Bob",
96 groups=>["Friends"]
97 );
98 $Roster->add(Net::XMPP::JID);
99  
100 $Roster->addResource('bob@jabber.org',
101 "Home",
102 show=>"dnd",
103 status=>"Working"
104 );
105 $Roster->addResource(Net::XMPP::JID,"Work");
106  
107 $Roster->remove('bob@jabber.org');
108 $Roster->remove(Net::XMPP::JID);
109  
110 $Roster->removeResource('bob@jabber.org',"Home");
111 $Roster->removeResource(Net::XMPP::JID,"Work");
112  
113 $Roster->handler(Net::XMPP::IQ);
114 $Roster->handler(Net::XMPP::Presence);
115  
116 =head1 METHODS
117  
118 =head2 Basic Functions
119  
120 =over 4
121  
122 =item new
123  
124 new(connection=>object)
125  
126 This creates and initializes the Roster
127 object. The connection object is required
128 so that the Roster can interact with the
129 main connection object. It needs to be an
130 object that inherits from L<Net::XMPP::Connection>.
131  
132 =item clear
133  
134 clear()
135  
136 removes everything from the database.
137  
138 =item exists
139  
140 exists(jid)
141  
142 return 1 if the JID exists in the database, undef
143 otherwise. The jid can either be a string, or a L<Net::XMPP::JID> object.
144  
145 =item groupExists
146  
147 groupExists(group)
148  
149 return 1 if the group exists in the database, undef otherwise.
150  
151 =item groups
152  
153 groups()
154  
155 Returns a list of all of the roster groups.
156  
157 =item jids
158  
159 jids([type, [group]])
160  
161 returns a list of all of the matching JIDs. The valid
162 types are:
163  
164 all - return all JIDs in the roster. (default)
165 nogroup - return all JIDs not in a roster group.
166 group - return all of the JIDs in the specified
167 roster group.
168  
169 =item online
170  
171 online(jid)
172  
173 return 1 if the JID is online, undef otherwise. The
174 jid can either be a string, or a L<Net::XMPP::JID> object.
175  
176 =item query
177  
178 query(jid, [key])
179  
180 return a hash representing all of the data in the
181 DB for this JID. The jid can either be a string,
182 or a Net::XMPP::JID object. If you specify a key,
183 then only the value for that key is returned.
184  
185 =item resource
186  
187 resource(jid)
188  
189 return the string representing the resource with the
190 highest priority for the JID. The jid can either be
191 a string, or a Net::XMPP::JID object.
192  
193 =item resourceQuery
194  
195 resourceQuery(jid,
196 resource,
197 [key])
198  
199 return a hash representing all of the data
200 the DB for the resource for this JID. The
201 jid can either be a string, or a
202 Net::XMPP::JID object. If you specify a
203 key, then only the value for that key is
204 returned.
205  
206 =item resources
207  
208 resources(jid)
209  
210 returns the list of resources for the JID in order
211 of highest priority to lowest priority. The jid can
212 either be a string, or a Net::XMPP::JID object.
213  
214 =item resourceStore
215  
216 resourceStore(jid,
217 resource,
218 key,
219 value)
220  
221 store the specified value in the DB under
222 the specified key for the resource for this
223 JID. The jid can either be a string, or a
224 Net::XMPP::JID object.
225  
226 =item store
227  
228 store(jid, key, value)
229  
230 store the specified value in the DB under the
231 specified key for this JID. The jid can either
232 be a string, or a Net::XMPP::JID object.
233  
234 =back
235  
236  
237 =head2 Advanced Functions
238  
239 add(jid, - Manually adds the JID to the Roster with the
240 ask=>string, specified roster item settings. This does not
241 groups=>arrayref handle subscribing to other users, only
242 name=>string, manipulating the Roster object. The jid
243 subscription=>string) can either be a string or a Net::XMPP::JID.
244  
245 addResource(jid, - Manually add the resource to the JID in the
246 resource, Roster with the specified presence settings.
247 priority=>int, This does not handle subscribing to other
248 show=>string, users, only manipulating the Roster object.
249 status=>string) The jid can either be a string or a
250 Net::XMPP::JID.
251  
252 remove(jid) - Removes all reference to the JID from the Roster object.
253 The jid can either be a string or a Net::XMPP::JID.
254  
255 removeResource(jid, - Removes the resource from the jid in the
256 resource) Roster object. The jid can either be a string
257 or a Net::XMPP::JID.
258  
259 handler(packet) - Take either a Net::XMPP::IQ or Net::XMPP::Presence
260 packet and parse them according to the rules of the
261 Roster object. Note, that it will only waste CPU time
262 if you pass in IQs or Presences that are not roster
263 related.
264  
265 =head1 AUTHOR
266  
267 Originally authored by Ryan Eatmon.
268  
269 Previously maintained by Eric Hacker.
270  
271 Currently maintained by Darian Anthony Patrick.
272  
273 =head1 COPYRIGHT
274  
275 This module is free software, you can redistribute it and/or modify it
276 under the LGPL 2.1.
277  
278 =cut
279  
280 15 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
281 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
282 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
283  
284 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
285  
286 15 ▶use Net::XMPP::JID;
Subroutine BEGIN: called CC=1 SCAR=0.0
287  
288 15 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
289  
290 sub new
291 1 ▶{
Subroutine new: called CC=4 SCAR=14.3
Pod documented
292 1 my $proto = shift;
293 1 my $self = { };
294  
295 1 my %args;
296 1 ▶ while($#_ >= 0) { $args{ lc(pop(@_)) } = pop(@_); }
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 1 1 2
297  
298 1 ▶ if (!exists($args{connection}) ||
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"connection"} and $args{"connection"}->isa("Net::XMPP::Connection")) 0 1 1
Condition33%1/3
exists $args{"connection"} and $args{"connection"}->isa("Net::XMPP::Connection")
!ll&&!rl&&r
001
MC/DC0%0/2
exists $args{"connection"} and $args{"connection"}->isa("Net::XMPP::Connection")
exists $args{"connection"} $args{"connection"}->isa("Net::XMPP::Connection")
Truth table33%1/3
A and B
A= exists $args{"connection"}B= $args{"connection"}->isa("Net::XMPP::Connection")
ABresult
0X0
100
111
299 !$args{connection}->isa("Net::XMPP::Connection"))
300 {
301 0 croak("You must pass Net::XMPP::Roster a valid connection object.");
302 }
303  
304 1 $self->{CONNECTION} = $args{connection};
305  
306 1 bless($self, $proto);
307  
308 1 $self->init();
309  
310 1 return $self;
311 }
312  
313  
314 ##############################################################################
315 #
316 # init - initialize the module to use the roster database
317 #
318 ##############################################################################
319 sub init
320 1 ▶{
Subroutine init: called CC=1 SCAR=0.2
Pod undocumented
321 1 my $self = shift;
322  
323 1 my $weak = $self;
324 1 weaken $weak;
325 0 ▶ $self->{CONNECTION}-> SetXPathCallBacks('/iq[@type="result" or @type="set"]/query[@xmlns="jabber:iq:roster"]'=>sub{ $weak->handler(@_) });
Subroutine __ANON__: not called CC=1 SCAR=1.2
326 0 ▶ $self->{CONNECTION}-> SetXPathCallBacks('/presence'=>sub{ $weak->handler(@_) });
Subroutine __ANON__: not called CC=1 SCAR=1.2
327 }
328  
329  
330 ##############################################################################
331 #
332 # add - adds the entry to the Roster DB.
333 #
334 ##############################################################################
335 sub add
336 2 ▶{
Subroutine add: called CC=5 SCAR=16.5
Pod undocumented
337 2 my $self = shift;
338 2 my ($jid,%item) = @_;
339  
340 2 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 2 2
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
200
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
341  
342 2 $self->{JIDS}->{$jid} = \%item;
343  
344 2 ▶ if (exists($item{groups}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item{"groups"}) 1 1 2
345 {
346 1 foreach my $group (@{$item{groups}})
347 {
348 2 $self->{GROUPS}->{$group}->{$jid} = 1;
349 }
350 }
351 }
352  
353  
354  
355 ##############################################################################
356 #
357 # addResource - adds the resource to the JID in the Roster DB.
358 #
359 ##############################################################################
360 sub addResource
361 2 ▶{
Subroutine addResource: called CC=10 SCAR=24.1
Pod undocumented
362 2 my $self = shift;
363 2 my $jid = shift;
364 2 my $resource = shift;
365 2 my (%item) = @_;
366  
367 2 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 2 2
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
200
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
368  
369 2 my $priority = $item{priority};
370 2 ▶ $priority = 0 unless defined($priority);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $priority 1 1 2
371  
372 2 $self->{CONNECTION}->{DEBUG}->Log3("Roster::addResource: add $jid/$resource with priority $priority to the DB");
373  
374 2 my $loc = -1;
375 $self->{JIDS}->{$jid}->{priorities}->{$priority} = []
376 2 ▶ unless exists($self->{JIDS}->{$jid}->{priorities}->{$priority});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid}{"priorities"}{$priority} 2 0 2
377 2 foreach my $index (0..$#{$self->{JIDS}->{$jid}->{priorities}->{$priority}})
378 {
379 $loc = $index
380 0 ▶ if ($self->{JIDS}->{$jid}->{priorities}->{$priority}->[$index]->{resource} eq $resource);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"JIDS"}{$jid}{"priorities"}{$priority}[$index]{"resource"} eq $resource 0 0 0
381 }
382 2 ▶ $loc = $#{$self->{JIDS}->{$jid}->{priorities}->{$priority}} + 1 if ($loc == -1);
Branch: 1 branch
BranchTrueFalseTotal
if $loc == -1 2 0 2
383  
384 2 $self->{JIDS}->{$jid}->{resources}->{$resource}->{priority} = $priority;
385 $self->{JIDS}->{$jid}->{resources}->{$resource}->{status} = $item{status}
386 2 ▶ if exists($item{status});
Branch: 1 branch
BranchTrueFalseTotal
if exists $item{"status"} 1 1 2
387 $self->{JIDS}->{$jid}->{resources}->{$resource}->{show} = $item{show}
388 2 ▶ if exists($item{show});
Branch: 1 branch
BranchTrueFalseTotal
if exists $item{"show"} 1 1 2
389 2 $self->{JIDS}->{$jid}->{priorities}->{$priority}->[$loc]->{resource} = $resource;
390 }
391  
392  
393 ###############################################################################
394 #
395 # clear - delete all of the JIDs from the DB completely.
396 #
397 ###############################################################################
398 sub clear
399 1 ▶{
Subroutine clear: called CC=2 SCAR=6.9
Pod documented
400 1 my $self = shift;
401  
402 1 $self->{CONNECTION}->{DEBUG}->Log3("Roster::clear: clearing the database");
403 1 foreach my $jid ($self->jids())
404 {
405 1 $self->remove($jid);
406 }
407 1 $self->{CONNECTION}->{DEBUG}->Log3("Roster::clear: database is empty");
408 }
409  
410  
411 ##############################################################################
412 #
413 # exists - allows you to query if the JID exists in the Roster DB.
414 #
415 ##############################################################################
416 sub exists
417 68 ▶{
Subroutine exists: called CC=5 SCAR=16.5
Pod documented
418 68 my $self = shift;
419 68 my ($jid) = @_;
420  
421 68 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 68 68
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
6800
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
422  
423 68 ▶ return unless exists($self->{JIDS});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"} 4 64 68
424 64 ▶ return unless exists($self->{JIDS}->{$jid});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid} 2 62 64
425 62 return 1;
426 }
427  
428  
429 sub fetch
430 0 ▶{
Subroutine fetch: not called CC=1 SCAR=6.9
Pod undocumented
431 0 my $self = shift;
432  
433 0 my %newroster = $self->{CONNECTION}->RosterGet();
434  
435 0 $self->handleRoster(\%newroster);
436 }
437  
438  
439 ##############################################################################
440 #
441 # groupExists - allows you to query if the group exists in the Roster
442 # DB.
443 #
444 ##############################################################################
445 sub groupExists
446 8 ▶{
Subroutine groupExists: called CC=3 SCAR=11.0
Pod documented
447 8 my $self = shift;
448 8 my ($group) = @_;
449  
450 8 ▶ return unless exists($self->{GROUPS});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"GROUPS"} 4 4 8
451 4 ▶ return unless exists($self->{GROUPS}->{$group});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"GROUPS"}{$group} 0 4 4
452 4 return 1;
453 }
454  
455  
456 ##############################################################################
457 #
458 # groups - returns a list of the current groups in your roster.
459 #
460 ##############################################################################
461 sub groups
462 0 ▶{
Subroutine groups: not called CC=3 SCAR=24.8
Pod documented
463 0 my $self = shift;
464  
465 0 ▶ return () unless exists($self->{GROUPS});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"GROUPS"} 0 0 0
466 0 ▶ return () if (scalar(keys(%{$self->{GROUPS}})) == 0);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %{$$self{"GROUPS"};} == 0 0 0 0
467 0 return keys(%{$self->{GROUPS}});
468 }
469  
470  
471 ##############################################################################
472 #
473 # handler - takes a packet and calls the correct handler.
474 #
475 ##############################################################################
476 sub handler
477 0 ▶{
Subroutine handler: not called CC=3 SCAR=24.8
Pod undocumented
478 0 my $self = shift;
479 0 my $sid = shift;
480 0 my $packet = shift;
481  
482 0 ▶ $self->handleIQ($packet) if ($packet->GetTag() eq "iq");
Branch: 1 branch
BranchTrueFalseTotal
if $packet->GetTag eq "iq" 0 0 0
483 0 ▶ $self->handlePresence($packet) if ($packet->GetTag() eq "presence");
Branch: 1 branch
BranchTrueFalseTotal
if $packet->GetTag eq "presence" 0 0 0
484 }
485  
486  
487 ##############################################################################
488 #
489 # handleIQ - takes an iq packet that contains roster, parses it, and puts
490 # the roster into the Roster DB.
491 #
492 ##############################################################################
493 sub handleIQ
494 0 ▶{
Subroutine handleIQ: not called CC=3 SCAR=24.8
Pod undocumented
495 0 my $self = shift;
496 0 my $iq = shift;
497  
498 0 $self->{CONNECTION}->{DEBUG}->Log3('handleIQ: iq(' . $iq->GetXML() . ')');
499  
500 0 my $type = $iq->GetType();
501 0 ▶ return unless (($type eq "set") || ($type eq "result"));
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "set" or $type eq "result" 0 0 0
Condition0%0/3
$type eq "set" or $type eq "result"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "set" or $type eq "result"
$type eq "set" $type eq "result"
Truth table0%0/3
A or B
A= $type eq "set"B= $type eq "result"
ABresult
1X1
011
000
502  
503 0 my %newroster = $self->{CONNECTION}->RosterParse($iq);
504  
505 0 $self->handleRoster(\%newroster);
506 }
507  
508  
509 sub handleRoster
510 0 ▶{
Subroutine handleRoster: not called CC=3 SCAR=24.8
Pod undocumented
511 0 my $self = shift;
512 0 my $roster = shift;
513  
514 0 foreach my $jid (keys(%{$roster}))
515 {
516 0 $self->remove($jid);
517  
518 0 ▶ if ($roster->{$jid}->{subscription} ne "remove")
Branch: 1 branch
BranchTrueFalseTotal
if ($roster->{$jid}{"subscription"} ne "remove") 0 0 0
519 {
520 0 $self->add($jid, %{$roster->{$jid}});
521 }
522 }
523 }
524  
525  
526 ##############################################################################
527 #
528 # handlePresence - takes a presence packet and groks the presence.
529 #
530 ##############################################################################
531 sub handlePresence
532 0 ▶{
Subroutine handlePresence: not called CC=13 SCAR=52.0
Pod undocumented
533 0 my $self = shift;
534 0 my $presence = shift;
535  
536 0 $self->{CONNECTION}->{DEBUG}->Log3('handlePresence: presence(' . $presence->GetXML() . ')');
537  
538 0 my $type = $presence->GetType();
539 0 ▶ $type = "" unless defined($type);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 0 0
540 0 ▶ return unless (($type eq "") ||
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "" or $type eq "available" or $type eq "unavailable" 0 0 0
Condition0%0/6
$type eq "" or $type eq "available" or $type eq "unavailable"
l!l&&r!l&&!r
000
$type eq "" or $type eq "available"
l!l&&r!l&&!r
000
MC/DC0%0/3
$type eq "" or $type eq "available" or $type eq "unavailable"
$type eq "" $type eq "available" $type eq "unavailable"
Truth table0%0/4
A or B or C
A= $type eq ""B= $type eq "available"C= $type eq "unavailable"
ABCresult
1XX1
01X1
0011
0000
541 ($type eq "available") ||
542 ($type eq "unavailable"));
543  
544 0 my $jid = $presence->GetFrom("jid");
545  
546 0 my $resource = $jid->GetResource();
547 0 ▶ $resource = " " unless ($resource ne "");
Branch: 1 branch
BranchTrueFalseTotal
unless $resource ne "" 0 0 0
548  
549 0 $jid = $jid->GetJID();
550 0 ▶ $jid = "" unless defined($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $jid 0 0 0
551  
552 0 ▶ return unless $self->exists($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exists($jid) 0 0 0
553 #XXX if it doesn't exist... is it us?
554 #XXX is this a presence based roster?
555  
556 0 $self->{CONNECTION}->{DEBUG}->Log3("Roster::PresenceDBParse: fromJID(",$presence->GetFrom(),") resource($resource) type($type)");
557 0 $self->{CONNECTION}->{DEBUG}->Log4("Roster::PresenceDBParse: xml(",$presence->GetXML(),")");
558  
559 0 $self->removeResource($jid,$resource);
560  
561 0 ▶ if (($type eq "") || ($type eq "available"))
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "" or $type eq "available") 0 0 0
Condition0%0/3
$type eq "" or $type eq "available"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "" or $type eq "available"
$type eq "" $type eq "available"
Truth table0%0/3
A or B
A= $type eq ""B= $type eq "available"
ABresult
1X1
011
000
562 {
563 0 my %item;
564  
565 0 $item{priority} = $presence->GetPriority();
566 0 ▶ $item{priority} = 0 unless defined($item{priority});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item{"priority"} 0 0 0
567  
568 0 $item{show} = $presence->GetShow();
569 0 ▶ $item{show} = "" unless defined($item{show});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item{"show"} 0 0 0
570  
571 0 $item{status} = $presence->GetStatus();
572 0 ▶ $item{status} = "" unless defined($item{status});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item{"status"} 0 0 0
573  
574 0 $self->addResource($jid,$resource,%item);
575 }
576 }
577  
578  
579 ##############################################################################
580 #
581 # jids - returns a list of all of the JIDs in your roster.
582 #
583 ##############################################################################
584 sub jids
585 8 ▶{
Subroutine jids: called CC=14 SCAR=26.6
Pod documented
586 8 my $self = shift;
587 8 my $type = shift;
588 8 my $group = shift;
589  
590 8 ▶ $type = "all" unless defined($type);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 1 7 8
591  
592 8 my @jids;
593  
594 8 ▶ if (($type eq "all") || ($type eq "nogroup"))
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "all" or $type eq "nogroup") 6 2 8
Condition100%3/3
$type eq "all" or $type eq "nogroup"
l!l&&r!l&&!r
512
MC/DC100%2/2
$type eq "all" or $type eq "nogroup"
$type eq "all" $type eq "nogroup"
Truth table100%3/3
A or B
A= $type eq "all"B= $type eq "nogroup"
ABresult
1X1
011
000
595 {
596 6 ▶ return () unless exists($self->{JIDS});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"} 1 5 6
597 5 foreach my $jid (keys(%{$self->{JIDS}}))
598 {
599 next if (($type eq "nogroup") &&
600 exists($self->{JIDS}->{$jid}->{groups}) &&
601 8 ▶ ($#{$self->{JIDS}->{$jid}->{groups}} > -1));
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "nogroup" and exists $self->{"JIDS"}{$jid}{"groups"} and $#{$$self{"JIDS"}{$jid}{"groups"};} > -1 1 7 8
Condition83%5/6
$type eq "nogroup" and exists $self->{"JIDS"}{$jid}{"groups"} and $#{$$self{"JIDS"}{$jid}{"groups"};} > -1
!ll&&!rl&&r
701
$type eq "nogroup" and exists $self->{"JIDS"}{$jid}{"groups"}
!ll&&!rl&&r
611
MC/DC66%2/3
$type eq "nogroup" and exists $self->{"JIDS"}{$jid}{"groups"} and $#{$$self{"JIDS"}{$jid}{"groups"};} > -1
$type eq "nogroup" exists $self->{"JIDS"}{$jid}{"groups"} $#{$$self{"JIDS"}{$jid}{"groups"};} > -1
Truth table75%3/4
A and B and C
A= $type eq "nogroup"B= exists $self->{"JIDS"}{$jid}{"groups"}C= $#{$$self{"JIDS"}{$jid}{"groups"};} > -1
ABCresult
0XX0
10X0
1100
1111
602  
603 7 push(@jids, Net::XMPP::JID->new($jid));
604 }
605 }
606  
607 7 ▶ if ($type eq "group")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "group") 2 5 7
608 {
609 2 ▶ return () unless exists($self->{GROUPS});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"GROUPS"} 0 2 2
610 2 ▶ if (defined($group) && $self->groupExists($group))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group and $self->groupExists($group)) 2 0 2
Condition33%1/3
defined $group and $self->groupExists($group)
!ll&&!rl&&r
002
MC/DC0%0/2
defined $group and $self->groupExists($group)
defined $group $self->groupExists($group)
Truth table33%1/3
A and B
A= defined $groupB= $self->groupExists($group)
ABresult
0X0
100
111
611 {
612 2 foreach my $jid (keys(%{$self->{GROUPS}->{$group}}))
613 {
614 2 push(@jids, Net::XMPP::JID->new($jid));
615 }
616 }
617 }
618  
619 7 return @jids;
620 }
621  
622  
623 ###############################################################################
624 #
625 # online - returns if the jid is online or not.
626 #
627 ###############################################################################
628 sub online
629 12 ▶{
Subroutine online: called CC=4 SCAR=15.0
Pod documented
630 12 my $self = shift;
631 12 my $jid = shift;
632  
633 12 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 12 12
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
1200
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
634  
635 12 ▶ return unless $self->exists($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exists($jid) 0 12 12
636  
637 12 my @resources = $self->resources($jid);
638  
639 12 return ($#resources > -1);
640 }
641  
642  
643 ##############################################################################
644 #
645 # priority - return the highest priority for the jid, or for the specified
646 # resource.
647 #
648 ##############################################################################
649 sub priority
650 6 ▶{
Subroutine priority: called CC=7 SCAR=20.3
Pod undocumented
651 6 my $self = shift;
652 6 my $jid = shift;
653 6 my $resource = shift;
654  
655 6 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 6 6
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
600
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
656  
657 6 ▶ if (defined($resource))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $resource) 2 4 6
658 {
659 2 ▶ return unless $self->resourceExists($jid,$resource);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->resourceExists($jid, $resource) 0 2 2
660 2 ▶ return unless exists($self->{JIDS}->{$jid}->{resources}->{$resource}->{priority});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid}{"resources"}{$resource}{"priority"} 0 2 2
661 2 return $self->{JIDS}->{$jid}->{resources}->{$resource}->{priority};
662 }
663  
664 4 ▶ return unless exists($self->{JIDS}->{$jid}->{priorities});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid}{"priorities"} 0 4 4
665 4 my @priorities = sort{ $b <=> $a } keys(%{$self->{JIDS}->{$jid}->{priorities}});
666 4 return $priorities[0];
667 }
668  
669  
670 ##############################################################################
671 #
672 # query - allows you to get one of the pieces of info from the Roster DB.
673 #
674 ##############################################################################
675 sub query
676 9 ▶{
Subroutine query: called CC=6 SCAR=18.3
Pod documented
677 9 my $self = shift;
678 9 my $jid = shift;
679 9 my $key = shift;
680  
681 9 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 9 9
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
900
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
682  
683 9 ▶ return unless $self->exists($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exists($jid) 0 9 9
684 9 ▶ if (defined($key))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 7 2 9
685 {
686 7 ▶ return unless exists($self->{JIDS}->{$jid}->{$key});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid}{$key} 2 5 7
687 5 return $self->{JIDS}->{$jid}->{$key};
688 }
689 2 return %{$self->{JIDS}->{$jid}};
690 }
691  
692  
693 ##############################################################################
694 #
695 # remove - removes the JID from the Roster DB.
696 #
697 ##############################################################################
698 sub remove
699 2 ▶{
Subroutine remove: called CC=9 SCAR=22.1
Pod undocumented
700 2 my $self = shift;
701 2 my $jid = shift;
702  
703 2 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 1 1 2
Condition66%2/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
101
MC/DC50%1/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table66%2/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
704  
705 2 ▶ if ($self->exists($jid))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->exists($jid)) 2 0 2
706 {
707 2 $self->{CONNECTION}->{DEBUG}->Log3("Roster::remove: deleting $jid from the DB");
708  
709 2 ▶ if (defined($self->query($jid,"groups")))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->query($jid, "groups")) 1 1 2
710 {
711 1 foreach my $group (@{$self->query($jid,"groups")})
712 {
713 2 delete($self->{GROUPS}->{$group}->{$jid});
714 delete($self->{GROUPS}->{$group})
715 2 ▶ if (scalar(keys(%{$self->{GROUPS}->{$group}})) == 0);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %{$$self{"GROUPS"}{$group};} == 0 2 0 2
716 delete($self->{GROUPS})
717 2 ▶ if (scalar(keys(%{$self->{GROUPS}})) == 0);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %{$$self{"GROUPS"};} == 0 1 1 2
718 }
719 }
720  
721 2 delete($self->{JIDS}->{$jid});
722 2 ▶ delete($self->{JIDS}) if (scalar(keys(%{$self->{JIDS}})) == 0);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %{$$self{"JIDS"};} == 0 1 1 2
723 }
724 }
725  
726  
727 ##############################################################################
728 #
729 # removeResource - removes the resource from the JID from the Roster DB.
730 #
731 ##############################################################################
732 sub removeResource
733 2 ▶{
Subroutine removeResource: called CC=10 SCAR=25.0
Pod undocumented
734 2 my $self = shift;
735 2 my $jid = shift;
736 2 my $resource = shift;
737  
738 2 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 2 2
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
200
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
739  
740 2 ▶ if ($self->resourceExists($jid,$resource))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->resourceExists($jid, $resource)) 2 0 2
741 {
742 2 $self->{CONNECTION}->{DEBUG}->Log3("Roster::removeResource: remove $jid/$resource from the DB");
743  
744 2 my $oldPriority = $self->priority($jid,$resource);
745 2 ▶ $oldPriority = "" unless defined($oldPriority);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $oldPriority 0 2 2
746  
747 2 ▶ if (exists($self->{JIDS}->{$jid}->{priorities}->{$oldPriority}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"JIDS"}{$jid}{"priorities"}{$oldPriority}) 2 0 2
748 {
749 2 my $loc = 0;
750 2 foreach my $index (0..$#{$self->{JIDS}->{$jid}->{priorities}->{$oldPriority}})
751 {
752 $loc = $index
753 2 ▶ if ($self->{JIDS}->{$jid}->{priorities}->{$oldPriority}->[$index]->{resource} eq $resource);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"JIDS"}{$jid}{"priorities"}{$oldPriority}[$index]{"resource"} eq $resource 2 0 2
754 }
755  
756 2 splice(@{$self->{JIDS}->{$jid}->{priorities}->{$oldPriority}},$loc,1);
757  
758 delete($self->{JIDS}->{$jid}->{priorities}->{$oldPriority})
759 if (exists($self->{JIDS}->{$jid}->{priorities}->{$oldPriority}) &&
760 2 ▶ ($#{$self->{JIDS}->{$jid}->{priorities}->{$oldPriority}} == -1));
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"JIDS"}{$jid}{"priorities"}{$oldPriority} and $#{$$self{"JIDS"}{$jid}{"priorities"}{$oldPriority};} == -1 2 0 2
Condition33%1/3
exists $self->{"JIDS"}{$jid}{"priorities"}{$oldPriority} and $#{$$self{"JIDS"}{$jid}{"priorities"}{$oldPriority};} == -1
!ll&&!rl&&r
002
MC/DC0%0/2
exists $self->{"JIDS"}{$jid}{"priorities"}{$oldPriority} and $#{$$self{"JIDS"}{$jid}{"priorities"}{$oldPriority};} == -1
exists $self->{"JIDS"}{$jid}{"priorities"}{$oldPriority} $#{$$self{"JIDS"}{$jid}{"priorities"}{$oldPriority};} == -1
Truth table33%1/3
A and B
A= exists $self->{"JIDS"}{$jid}{"priorities"}{$oldPriority}B= $#{$$self{"JIDS"}{$jid}{"priorities"}{$oldPriority};} == -1
ABresult
0X0
100
111
761 }
762  
763 2 delete($self->{JIDS}->{$jid}->{resources}->{$resource});
764  
765 }
766 }
767  
768  
769 ###############################################################################
770 #
771 # resource - retrieve the resource with the highest priority.
772 #
773 ###############################################################################
774 sub resource
775 4 ▶{
Subroutine resource: called CC=5 SCAR=16.8
Pod documented
776 4 my $self = shift;
777 4 my $jid = shift;
778  
779 4 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 4 4
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
400
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
780  
781 4 ▶ return unless $self->exists($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exists($jid) 0 4 4
782  
783 4 my $priority = $self->priority($jid);
784  
785 4 ▶ return unless defined($priority);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $priority 1 3 4
786  
787 3 return $self->{JIDS}->{$jid}->{priorities}->{$priority}->[0]->{resource};
788 }
789  
790  
791 ##############################################################################
792 #
793 # resourceExists - check that the specified resource exists.
794 #
795 ##############################################################################
796 sub resourceExists
797 12 ▶{
Subroutine resourceExists: called CC=6 SCAR=19.9
Pod undocumented
798 12 my $self = shift;
799 12 my $jid = shift;
800 12 my $resource = shift;
801  
802 12 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 12 12
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
1200
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
803  
804 12 ▶ return unless $self->exists($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exists($jid) 0 12 12
805 12 ▶ return unless exists($self->{JIDS}->{$jid}->{resources});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid}{"resources"} 0 12 12
806 12 ▶ return unless exists($self->{JIDS}->{$jid}->{resources}->{$resource});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid}{"resources"}{$resource} 0 12 12
807 }
808  
809  
810 ##############################################################################
811 #
812 # resourceQuery - allows you to get one of the pieces of info from the Roster
813 # DB.
814 #
815 ##############################################################################
816 sub resourceQuery
817 7 ▶{
Subroutine resourceQuery: called CC=6 SCAR=18.3
Pod documented
818 7 my $self = shift;
819 7 my $jid = shift;
820 7 my $resource = shift;
821 7 my $key = shift;
822  
823 7 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 7 7
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
700
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
824  
825 7 ▶ return unless $self->resourceExists($jid,$resource);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->resourceExists($jid, $resource) 0 7 7
826 7 ▶ if (defined($key))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 4 3 7
827 {
828 4 ▶ return unless exists($self->{JIDS}->{$jid}->{resources}->{$resource}->{$key});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"JIDS"}{$jid}{"resources"}{$resource}{$key} 1 3 4
829 3 return $self->{JIDS}->{$jid}->{resources}->{$resource}->{$key};
830 }
831 3 return %{$self->{JIDS}->{$jid}->{resources}->{$resource};}
832 }
833  
834  
835 ###############################################################################
836 #
837 # resources - returns a list of the resources from highest priority to lowest.
838 #
839 ###############################################################################
840 sub resources
841 16 ▶{
Subroutine resources: called CC=7 SCAR=20.2
Pod documented
842 16 my $self = shift;
843 16 my $jid = shift;
844  
845 16 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 16 16
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
1600
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
846  
847 16 ▶ return () unless $self->exists($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exists($jid) 0 16 16
848  
849 16 my @resources;
850  
851 16 foreach my $priority (sort {$b cmp $a} keys(%{$self->{JIDS}->{$jid}->{priorities}}))
852 {
853 9 foreach my $index (0..$#{$self->{JIDS}->{$jid}->{priorities}->{$priority}})
854 {
855 9 ▶ next if ($self->{JIDS}->{$jid}->{priorities}->{$priority}->[$index]->{resource} eq " ");
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"JIDS"}{$jid}{"priorities"}{$priority}[$index]{"resource"} eq " " 0 9 9
856 9 push(@resources,$self->{JIDS}->{$jid}->{priorities}->{$priority}->[$index]->{resource});
857 }
858 }
859 16 return @resources;
860 }
861  
862  
863 ##############################################################################
864 #
865 # resourceStore - allows you to store anything on the item that you want to.
866 # The only drawback is that when the item is removed, the data
867 # is not kept. You must restore it in the DB.
868 #
869 ##############################################################################
870 sub resourceStore
871 1 ▶{
Subroutine resourceStore: called CC=6 SCAR=19.2
Pod documented
872 1 my $self = shift;
873 1 my $jid = shift;
874 1 my $resource = shift;
875 1 my $key = shift;
876 1 my $value = shift;
877  
878 1 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 1 1
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
100
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
879  
880 1 ▶ return unless defined($key);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 1 1
881 1 ▶ return unless defined($value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 1 1
882 1 ▶ return unless $self->resourceExists($jid,$resource);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->resourceExists($jid, $resource) 0 1 1
883  
884 1 $self->{JIDS}->{$jid}->{resources}->{$resource}->{$key} = $value;
885 }
886  
887  
888 ##############################################################################
889 #
890 # store - allows you to store anything on the item that you want to. The
891 # only drawback is that when the item is removed, the data is not
892 # kept. You must restore it in the DB.
893 #
894 ##############################################################################
895 sub store
896 1 ▶{
Subroutine store: called CC=6 SCAR=19.4
Pod documented
897 1 my $self = shift;
898 1 my $jid = shift;
899 1 my $key = shift;
900 1 my $value = shift;
901  
902 1 ▶ $jid = $jid->GetJID() if (ref $jid && $jid->isa('Net::XMPP::JID'));
Branch: 1 branch
BranchTrueFalseTotal
if ref $jid and $jid->isa("Net::XMPP::JID") 0 1 1
Condition33%1/3
ref $jid and $jid->isa("Net::XMPP::JID")
!ll&&!rl&&r
100
MC/DC0%0/2
ref $jid and $jid->isa("Net::XMPP::JID")
ref $jid $jid->isa("Net::XMPP::JID")
Truth table33%1/3
A and B
A= ref $jidB= $jid->isa("Net::XMPP::JID")
ABresult
0X0
100
111
903  
904 1 ▶ return unless defined($key);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 1 1
905 1 ▶ return unless defined($value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 1 1
906 1 ▶ return unless $self->exists($jid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exists($jid) 0 1 1
907  
908 1 $self->{JIDS}->{$jid}->{$key} = $value;
909 }
910  
911  
912 15 1;
913  
« XMPP/Stanza.pm ↑ Summary XMPP/JID.pm »