File Coverage

blib/lib/Net/OSCAR/Callbacks/3/buddy_status_update.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 14 100.0


line stmt bran cond sub pod time code
1             package Net::OSCAR::Callbacks;
2             BEGIN {
3 1     1   22 $Net::OSCAR::Callbacks::VERSION = '1.928';
4             }
5 1     1   6 use strict;
  1         1  
  1         25  
6 1     1   5 use warnings;
  1         2  
  1         27  
7 1     1   5 use vars qw($connection $snac $conntype $family $subtype $data $reqid $reqdata $session $protobit %data);
  1         1  
  1         434  
8             sub {
9              
10             $connection->log_print(OSCAR_DBG_DEBUG, "Incoming bogey - er, I mean buddy - $data{screenname}");
11             $session->postprocess_userinfo(\%data);
12             my $screenname = $data{screenname};
13              
14             my($grpname, $group) = $session->findbuddy($screenname);
15             return unless $grpname; # Without this, remove_buddy screws things up until signoff/signon
16             my $budinfo = $group->{members}->{$screenname};
17              
18             $data{buddyid} = $budinfo->{buddyid};
19             $data{online} = 1;
20             foreach my $key(keys %data) {
21             next if $key eq "__UNKNOWN";
22             $budinfo->{$key} = delete $data{$key};
23             }
24             if(exists($budinfo->{idle}) and !exists($data{idle})) {
25             delete $budinfo->{idle};
26             delete $budinfo->{idle_since};
27             }
28              
29             # Sync $session->{userinfo}->{$foo} with buddylist entry
30             if(exists($session->{userinfo}->{$screenname})) {
31             if($session->{userinfo}->{$screenname} != $budinfo) {
32             my $info = $session->{userinfo}->{$screenname};
33             foreach my $key(keys %$info) {
34             $budinfo->{$key} = $info->{$key};
35             }
36             $session->{userinfo}->{$screenname} = $budinfo;
37             }
38             } else {
39             $session->{userinfo}->{$screenname} = $budinfo;
40             }
41             $session->callback_buddy_in($screenname, $grpname, $budinfo);
42              
43             };