source: perl/modules/AIM/lib/Net/OSCAR/ServerCallbacks.pm @ 3dcccba

barnowl_perlaim
Last change on this file since 3dcccba was 7a1c90d, checked in by Geoffrey Thomas <geofft@mit.edu>, 13 years ago
Skeleton AIM module, and Net::OSCAR 1.925
  • Property mode set to 100644
File size: 2.1 KB
Line 
1=pod
2
3Net::OSCAR::ServerCallbacks -- Process responses from OSCAR client
4
5=cut
6
7package Net::OSCAR::ServerCallbacks;
8
9$VERSION = '1.925';
10$REVISION = '$Revision: 1.8 $';
11
12use strict;
13use vars qw($VERSION);
14use Carp;
15
16use Net::OSCAR::Common qw(:all);
17use Net::OSCAR::Constants;
18use Net::OSCAR::Utility;
19use Net::OSCAR::TLV;
20use Net::OSCAR::Buddylist;
21use Net::OSCAR::_BLInternal;
22use Net::OSCAR::XML;
23
24use Digest::MD5 qw(md5);
25use POSIX qw(ctime);
26
27our %protohandlers;
28our $SESSIONS = bltie();
29our $SCREENNAMES = bltie();
30our %COOKIES;
31$SCREENNAMES->{somedude} = {sn => "Some Dude", pw => "somepass", email => 'some@dude.com', blist => [qw(SomeDude OtherDude)]};
32$SCREENNAMES->{otherdude} = {sn => "Other Dude", pw => "otherpass", email => 'other@dude.com', blist => [qw(SomeDude OtherDude)]};
33
34
35sub srv_send_error($$$) {
36        my($connection, $family, $errno) = @_;
37
38        $connection->proto_send(family => $family, protobit => "error", protodata => {errno => $errno});
39}
40
41sub process_snac($$) {
42        our($connection, $snac) = @_;
43        our($conntype, $family, $subtype, $data, $reqid) = ($connection->{conntype}, $snac->{family}, $snac->{subtype}, $snac->{data}, $snac->{reqid});
44        our $screenname = $connection->{screenname};
45
46        our $reqdata = delete $connection->{reqdata}->[$family]->{pack("N", $reqid)};
47        our $session = $connection->{session};
48
49        our $protobit = snac_to_protobit(%$snac);
50        if(!$protobit) {
51                return $session->callback_snac_unknown($connection, $snac, $data);
52        }
53
54        our %data = protoparse($session, $protobit)->unpack($data);
55        $connection->log_printf(OSCAR_DBG_DEBUG, "Got SNAC 0x%04X/0x%04X: %s", $snac->{family}, $snac->{subtype}, $protobit);
56
57        if(!exists($protohandlers{$protobit})) {
58                $protohandlers{$protobit} = eval {
59                        require "Net/OSCAR/ServerCallbacks/$family/$protobit.pm";
60                };
61                if($@) {
62                        my $olderr = $@;
63                        $protohandlers{$protobit} = eval {
64                                require "Net/OSCAR/ServerCallbacks/0/$protobit.pm";
65                        };
66                }
67        }
68
69        if($protohandlers{$protobit}) {
70                $protohandlers{$protobit}->();
71        } else {
72                #srv_send_error($connection, $family, 1);
73                print "Unhandled protobit: $protobit\n";
74        }
75}
76
771;
78
Note: See TracBrowser for help on using the repository browser.