File Coverage

blib/lib/Net/OSCAR/Callbacks/21/ICQ_meta_response.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   8 use strict;
  1         3  
  1         32  
6 1     1   8 use warnings;
  1         2  
  1         45  
7 1     1   6 use vars qw($connection $snac $conntype $family $subtype $data $reqid $reqdata $session $protobit %data);
  1         2  
  1         697  
8             sub {
9              
10             my $uin = $data{our_uin};
11              
12             if($data{type} == 2010) {
13             $session->{icq_meta_info_cache}->{$uin} ||= {};
14              
15             (%data) = protoparse($session, "ICQ_meta_info_response")->unpack($data{typedata});
16             if($data{status} != 10) {
17             delete $session->{icq_meta_info_cache}->{$uin};
18              
19             my $error = "Bad ICQ meta info response";
20             if($data{status} == 20) {
21             $error = "Could not get ICQ info for $uin.";
22             }
23              
24             send_error($session, $connection, $data{status}, $error, 0, $reqdata);
25             return;
26             }
27              
28             if(!exists(ICQ_META_INFO_INVERSE()->{$data{subtype}})) {
29             $session->log_printf(OSCAR_DBG_WARN, "Bad ICQ meta response subtype %d", $data{subtype});
30             return;
31             }
32             my $subtype = ICQ_META_INFO_INVERSE()->{$data{subtype}};
33              
34             (%data) = protoparse($session, "ICQ_meta_info_response:_$subtype")->unpack($data{response_data});
35             if($subtype eq "basic") {
36             $session->{icq_meta_info_cache}->{$uin}->{home} = delete $data{home};
37             $session->{icq_meta_info_cache}->{$uin}->{basic} = \%data;
38             } elsif($subtype eq "office") {
39             $session->{icq_meta_info_cache}->{$uin}->{office} = \%data;
40             } elsif($subtype eq "background") {
41             $session->{icq_meta_info_cache}->{$uin}->{background} = \%data;
42             $session->{icq_meta_info_cache}->{$uin}->{background}->{spoken_languages} =
43             [delete @data{qw(language_1 language_2 language_3)}];
44             } elsif($subtype eq "notes") {
45             $session->{icq_meta_info_cache}->{$uin}->{notes} = $data{notes};
46             } elsif($subtype eq "email") {
47             $session->{icq_meta_info_cache}->{$uin}->{email_addresses} = $data{addresses};
48             } elsif($subtype eq "interests") {
49             $session->{icq_meta_info_cache}->{$uin}->{interests} = $data{interests};
50             } elsif($subtype eq "affiliations") {
51             $session->{icq_meta_info_cache}->{$uin}->{past_affiliations} = $data{past_affilations};
52             $session->{icq_meta_info_cache}->{$uin}->{present_affiliations} = $data{affiliations};
53             } elsif($subtype eq "homepage") {
54             $session->{icq_meta_info_cache}->{$uin}->{email_addresses} = $data{homepage};
55             }
56              
57             if(!$snac->{flags2}) {
58             $session->callback_buddy_icq_info($uin, delete $session->{icq_meta_info_cache}->{$uin});
59             }
60             } else {
61             $session->log_printf(OSCAR_DBG_WARN, "Unknown ICQ meta response %d", $data{type});
62             }
63              
64             };