barnowl_perlaimdebianrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since 81312e4 was
693c8f2,
checked in by Alejandro R. Sedeño <asedeno@mit.edu>, 16 years ago
|
Jabber tweaks:
BarnOwl::Message::Jabber now defines subcontext as subject, much as
BarnOwl::Message::Zephyr maps instance to it.
BarnOwl::Module::Jabber now preserves subjects through replies to
MUCs. Also, fixed a typo in which ``jwrite ... -s foo'' showed up as
``jwrite ... -t foo'' when echoed back to the terminal.
|
-
Property mode set to
100644
|
File size:
1.8 KB
|
Rev | Line | |
---|
[2cedb7a] | 1 | use warnings; |
---|
| 2 | use strict; |
---|
| 3 | |
---|
| 4 | =head1 NAME |
---|
| 5 | |
---|
| 6 | BarnOwl::Message::Jabber |
---|
| 7 | |
---|
| 8 | =head1 DESCRIPTION |
---|
| 9 | |
---|
| 10 | A subclass of BarnOwl::Message for Jabber messages |
---|
| 11 | |
---|
| 12 | =cut |
---|
| 13 | |
---|
| 14 | package BarnOwl::Message::Jabber; |
---|
| 15 | |
---|
| 16 | use base qw( BarnOwl::Message ); |
---|
| 17 | |
---|
| 18 | sub jtype { shift->{jtype} }; |
---|
| 19 | sub from { shift->{from} }; |
---|
| 20 | sub to { shift->{to} }; |
---|
| 21 | sub room { shift->{room} }; |
---|
[693c8f2] | 22 | sub subject { shift->{subject} }; |
---|
[2cedb7a] | 23 | sub status { shift->{status} } |
---|
| 24 | |
---|
| 25 | sub login_extra { |
---|
| 26 | my $self = shift; |
---|
| 27 | my $show = $self->{show}; |
---|
| 28 | my $status = $self->status; |
---|
| 29 | my $s = ""; |
---|
| 30 | $s .= $show if $show; |
---|
| 31 | $s .= ", $status" if $status; |
---|
| 32 | return $s; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | sub long_sender { |
---|
| 36 | my $self = shift; |
---|
| 37 | return $self->from; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | sub context { |
---|
| 41 | return shift->room; |
---|
| 42 | } |
---|
| 43 | |
---|
[693c8f2] | 44 | sub subcontext { |
---|
| 45 | return shift->subject || ""; |
---|
| 46 | } |
---|
| 47 | |
---|
[2cedb7a] | 48 | sub smartfilter { |
---|
| 49 | my $self = shift; |
---|
| 50 | my $inst = shift; |
---|
| 51 | |
---|
| 52 | my ($filter, $ftext); |
---|
| 53 | |
---|
| 54 | if($self->jtype eq 'chat') { |
---|
| 55 | my $user; |
---|
| 56 | if($self->direction eq 'in') { |
---|
| 57 | $user = $self->from; |
---|
| 58 | } else { |
---|
| 59 | $user = $self->to; |
---|
| 60 | } |
---|
| 61 | return smartfilter_user($user, $inst); |
---|
| 62 | } elsif ($self->jtype eq 'groupchat') { |
---|
| 63 | my $room = $self->room; |
---|
| 64 | $filter = "jabber-room-$room"; |
---|
| 65 | $ftext = qq{type ^jabber\$ and room ^$room\$}; |
---|
| 66 | BarnOwl::filter("$filter $ftext"); |
---|
| 67 | return $filter; |
---|
| 68 | } elsif ($self->login ne 'none') { |
---|
| 69 | return smartfilter_user($self->from, $inst); |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | sub smartfilter_user { |
---|
| 74 | my $user = shift; |
---|
| 75 | my $inst = shift; |
---|
| 76 | |
---|
| 77 | $user = Net::Jabber::JID->new($user)->GetJID( $inst ? 'full' : 'base' ); |
---|
| 78 | my $filter = "jabber-user-$user"; |
---|
| 79 | my $ftext = |
---|
| 80 | qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) } |
---|
| 81 | . qq{or ( direction ^out\$ and to ^$user ) ) }; |
---|
| 82 | BarnOwl::filter("$filter $ftext"); |
---|
| 83 | return $filter; |
---|
| 84 | |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | =head1 SEE ALSO |
---|
| 89 | |
---|
| 90 | L<BarnOwl::Message> |
---|
| 91 | |
---|
| 92 | =cut |
---|
| 93 | |
---|
| 94 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.