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