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 | my $reqdesc = ""; |
---|
8 | $data{subrequest} ||= 0; |
---|
9 | if($data{request_type} == 2) { |
---|
10 | $reqdesc = ADMIN_TYPE_PASSWORD_CHANGE; |
---|
11 | } elsif($data{request_type} == 3) { |
---|
12 | if(exists($data{new_email})) { |
---|
13 | $reqdesc = ADMIN_TYPE_EMAIL_CHANGE; |
---|
14 | } else { |
---|
15 | $reqdesc = ADMIN_TYPE_SCREENNAME_FORMAT; |
---|
16 | } |
---|
17 | } elsif($data{request_type} == 0x1E) { |
---|
18 | $reqdesc = ADMIN_TYPE_ACCOUNT_CONFIRM; |
---|
19 | } |
---|
20 | delete $session->{adminreq}->{0+$reqdesc} if $reqdesc; |
---|
21 | $reqdesc ||= sprintf "unknown admin reply type 0x%04X/0x%04X", $data{request_type}, $data{subrequest}; |
---|
22 | |
---|
23 | my $errdesc = ""; |
---|
24 | if(exists($data{error_code})) { |
---|
25 | if($reqdesc eq "account confirm") { |
---|
26 | $errdesc = "Your account is already confirmed."; |
---|
27 | } else { |
---|
28 | if($data{error_code} == 1) { |
---|
29 | $errdesc = ADMIN_ERROR_DIFFSN; |
---|
30 | } elsif($data{error_code} == 2) { |
---|
31 | $errdesc = ADMIN_ERROR_BADPASS; |
---|
32 | } elsif($data{error_code} == 6) { |
---|
33 | $errdesc = ADMIN_ERROR_BADINPUT; |
---|
34 | } elsif($data{error_code} == 0xB or $data{error_code} == 0xC) { |
---|
35 | $errdesc = ADMIN_ERROR_BADLENGTH; |
---|
36 | } elsif($data{error_code} == 0x13) { |
---|
37 | $errdesc = ADMIN_ERROR_TRYLATER; |
---|
38 | } elsif($data{error_code} == 0x1D) { |
---|
39 | $errdesc = ADMIN_ERROR_REQPENDING; |
---|
40 | } elsif($data{error_code} == 0x21) { |
---|
41 | $errdesc = ADMIN_ERROR_EMAILLIM; |
---|
42 | } elsif($data{error_code} == 0x23) { |
---|
43 | $errdesc = ADMIN_ERROR_EMAILBAD; |
---|
44 | } else { |
---|
45 | $errdesc = sprintf("Unknown error 0x%04X.", $data{error_code}); |
---|
46 | } |
---|
47 | } |
---|
48 | $session->callback_admin_error($reqdesc, $errdesc, $data{error_url}); |
---|
49 | } else { |
---|
50 | if($reqdesc eq "screenname format") { |
---|
51 | $session->{screenname} = Net::OSCAR::Screenname->new(\$data{new_screenname}); |
---|
52 | } elsif($reqdesc eq "email change") { |
---|
53 | $session->{email} = $data{new_email}; |
---|
54 | } |
---|
55 | $session->callback_admin_ok($reqdesc); |
---|
56 | } |
---|
57 | |
---|
58 | }; |
---|