1 | =pod |
---|
2 | |
---|
3 | Net::OSCAR::Connection::Chat -- OSCAR chat connections |
---|
4 | |
---|
5 | =cut |
---|
6 | |
---|
7 | package Net::OSCAR::Connection::Chat; |
---|
8 | |
---|
9 | $VERSION = '1.925'; |
---|
10 | $REVISION = '$Revision: 1.10 $'; |
---|
11 | |
---|
12 | use strict; |
---|
13 | use Carp; |
---|
14 | |
---|
15 | use Net::OSCAR::TLV; |
---|
16 | use Net::OSCAR::Callbacks; |
---|
17 | use vars qw(@ISA $VERSION); |
---|
18 | use Net::OSCAR::Common qw(:all); |
---|
19 | use Net::OSCAR::Constants; |
---|
20 | use Net::OSCAR::Utility; |
---|
21 | use Net::OSCAR::XML; |
---|
22 | @ISA = qw(Net::OSCAR::Connection); |
---|
23 | |
---|
24 | sub invite($$;$) { |
---|
25 | my($self, $who, $message) = @_; |
---|
26 | $message ||= "Join me in this Buddy Chat"; |
---|
27 | |
---|
28 | $self->log_print(OSCAR_DBG_DEBUG, "Inviting $who to join us."); |
---|
29 | |
---|
30 | my $svcdata = protoparse($self, "chat_invite_rendezvous_data")->pack( |
---|
31 | exchange => $self->{exchange}, |
---|
32 | url => $self->{url} |
---|
33 | ); |
---|
34 | |
---|
35 | my $cookie = randchars(8); |
---|
36 | my %rvdata = ( |
---|
37 | capability => OSCAR_CAPS()->{chat}->{value}, |
---|
38 | charset => "us-ascii", |
---|
39 | cookie => $cookie, |
---|
40 | invitation_msg => $message, |
---|
41 | push_pull => 1, |
---|
42 | status => "propose", |
---|
43 | svcdata => $svcdata |
---|
44 | ); |
---|
45 | |
---|
46 | return $self->{session}->send_message($who, 2, protoparse($self, "rendezvous_IM")->pack(%rvdata), 0, $cookie); |
---|
47 | } |
---|
48 | |
---|
49 | sub chat_send($$;$$) { |
---|
50 | my($self, $msg, $noreflect, $away) = @_; |
---|
51 | |
---|
52 | my %protodata = ( |
---|
53 | cookie => randchars(8), |
---|
54 | message => $msg |
---|
55 | ); |
---|
56 | $protodata{reflect} = "" unless $noreflect; |
---|
57 | $protodata{is_automatic} = "" if $away; |
---|
58 | |
---|
59 | $self->proto_send(protobit => "outgoing_chat_IM", protodata => \%protodata); |
---|
60 | } |
---|
61 | |
---|
62 | sub part($) { shift->disconnect(); } |
---|
63 | sub url($) { shift->{url}; } |
---|
64 | sub name($) { shift->{name}; } |
---|
65 | sub exchange($) { shift->{exchange}; } |
---|
66 | |
---|
67 | 1; |
---|