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