source: perl/modules/AIM/lib/Net/OSCAR/Callbacks/21/ICQ_meta_response.pm @ 3dcccba

barnowl_perlaim
Last change on this file since 3dcccba was 7a1c90d, checked in by Geoffrey Thomas <geofft@mit.edu>, 16 years ago
Skeleton AIM module, and Net::OSCAR 1.925
  • Property mode set to 100644
File size: 2.3 KB
Line 
1package Net::OSCAR::Callbacks;
2use strict;
3use warnings;
4use vars qw($connection $snac $conntype $family $subtype $data $reqid $reqdata $session $protobit %data);
5sub {
6
7my $uin = $data{our_uin};
8
9if($data{type} == 2010) {
10        $session->{icq_meta_info_cache}->{$uin} ||= {};
11
12        (%data) = protoparse($session, "ICQ_meta_info_response")->unpack($data{typedata});
13        if($data{status} != 10) {
14                delete $session->{icq_meta_info_cache}->{$uin};
15
16                my $error = "Bad ICQ meta info response";
17                if($data{status} == 20) {
18                        $error = "Could not get ICQ info for $uin.";
19                }
20
21                send_error($session, $connection, $data{status}, $error, 0, $reqdata);
22                return;
23        }
24
25        if(!exists(ICQ_META_INFO_INVERSE()->{$data{subtype}})) {
26                $session->log_printf(OSCAR_DBG_WARN, "Bad ICQ meta response subtype %d", $data{subtype});
27                return;
28        }
29        my $subtype = ICQ_META_INFO_INVERSE()->{$data{subtype}};
30
31        (%data) = protoparse($session, "ICQ_meta_info_response:_$subtype")->unpack($data{response_data});
32        if($subtype eq "basic") {
33                $session->{icq_meta_info_cache}->{$uin}->{home} = delete $data{home};
34                $session->{icq_meta_info_cache}->{$uin}->{basic} = \%data;
35        } elsif($subtype eq "office") {
36                $session->{icq_meta_info_cache}->{$uin}->{office} = \%data;
37        } elsif($subtype eq "background") {
38                $session->{icq_meta_info_cache}->{$uin}->{background} = \%data;
39                $session->{icq_meta_info_cache}->{$uin}->{background}->{spoken_languages} =
40                        [delete @data{qw(language_1 language_2 language_3)}];
41        } elsif($subtype eq "notes") {
42                $session->{icq_meta_info_cache}->{$uin}->{notes} = $data{notes};
43        } elsif($subtype eq "email") {
44                $session->{icq_meta_info_cache}->{$uin}->{email_addresses} = $data{addresses};
45        } elsif($subtype eq "interests") {
46                $session->{icq_meta_info_cache}->{$uin}->{interests} = $data{interests};
47        } elsif($subtype eq "affiliations") {
48                $session->{icq_meta_info_cache}->{$uin}->{past_affiliations} = $data{past_affilations};
49                $session->{icq_meta_info_cache}->{$uin}->{present_affiliations} = $data{affiliations};
50        } elsif($subtype eq "homepage") {
51                $session->{icq_meta_info_cache}->{$uin}->{email_addresses} = $data{homepage};
52        }
53
54        if(!$snac->{flags2}) {
55                $session->callback_buddy_icq_info($uin, delete $session->{icq_meta_info_cache}->{$uin});
56        }
57} else {
58        $session->log_printf(OSCAR_DBG_WARN, "Unknown ICQ meta response %d", $data{type});
59}
60
61};
Note: See TracBrowser for help on using the repository browser.