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 | use Net::OSCAR::Utility qw(millitime); |
---|
6 | |
---|
7 | sub { |
---|
8 | |
---|
9 | $connection->unpause(); |
---|
10 | |
---|
11 | if($session->{rate_manage_mode} != OSCAR_RATE_MANAGE_NONE) { |
---|
12 | $connection->{rate_limits} ||= {classmap => {}}; |
---|
13 | |
---|
14 | my $rinfo = $connection->{rate_limits}; |
---|
15 | my $time = millitime(); |
---|
16 | foreach my $class (@{$data{classes}}) { |
---|
17 | $class->{time_offset} = $time - $class->{last_time}; |
---|
18 | $rinfo->{$class->{class_id}} = $class; |
---|
19 | } |
---|
20 | |
---|
21 | my $map = $rinfo->{classmap}; |
---|
22 | foreach my $class (@{$data{classmembers}}) { |
---|
23 | my $id = $class->{class_id}; |
---|
24 | foreach my $snacfam (@{$class->{snacs}}) { |
---|
25 | my $key = pack("nn", $snacfam->{family}, $snacfam->{subtype}); |
---|
26 | $map->{$key} = $id; |
---|
27 | } |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | $connection->proto_send(protobit => "rate_acknowledgement", |
---|
32 | classes => [map {$_->{class_id}} @{$data{classes}}]); |
---|
33 | $connection->log_print(OSCAR_DBG_NOTICE, "BOS handshake complete!"); |
---|
34 | |
---|
35 | if($conntype == CONNTYPE_BOS) { |
---|
36 | $connection->log_print(OSCAR_DBG_SIGNON, "Signon BOS handshake complete!"); |
---|
37 | |
---|
38 | $connection->proto_send(protobit => "personal_info_request"); |
---|
39 | $session->set_stealth(1) if $session->{stealth}; |
---|
40 | |
---|
41 | $connection->proto_send(protobit => "buddylist_rights_request"); |
---|
42 | $connection->proto_send(protobit => "buddylist_request"); |
---|
43 | $connection->proto_send(protobit => "locate_rights_request"); |
---|
44 | $connection->proto_send(protobit => "buddy_rights_request"); |
---|
45 | $connection->proto_send(protobit => "IM_parameter_request"); |
---|
46 | $connection->proto_send(protobit => "BOS_rights_request"); |
---|
47 | } elsif($conntype == CONNTYPE_CHAT) { |
---|
48 | $connection->ready(); |
---|
49 | |
---|
50 | $session->callback_chat_joined($connection->name, $connection) unless $connection->{sent_joined}++; |
---|
51 | } else { |
---|
52 | if($conntype == CONNTYPE_CHATNAV) { |
---|
53 | $connection->proto_send(protobit => "chat_navigator_rights_request"); |
---|
54 | } |
---|
55 | |
---|
56 | $session->{services}->{$conntype} = $connection; |
---|
57 | $connection->ready(); |
---|
58 | |
---|
59 | if($session->{svcqueues}->{$conntype}) { |
---|
60 | foreach my $proto_item(@{$session->{svcqueues}->{$conntype}}) { |
---|
61 | $connection->proto_send(%$proto_item); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | delete $session->{svcqueues}->{$conntype}; |
---|
66 | } |
---|
67 | |
---|
68 | }; |
---|