source: perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm @ 2cedb7a

barnowl_perlaimdebianrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 2cedb7a was 2cedb7a, checked in by Nelson Elhage <nelhage@mit.edu>, 14 years ago
Adding the new M::Iified jabber module. There isn't a target to build the PAR yet.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1use warnings;
2use strict;
3
4=head1 NAME
5
6BarnOwl::Message::Jabber
7
8=head1 DESCRIPTION
9
10A subclass of BarnOwl::Message for Jabber messages
11
12=cut
13
14package BarnOwl::Message::Jabber;
15
16use base qw( BarnOwl::Message );
17
18sub jtype { shift->{jtype} };
19sub from { shift->{from} };
20sub to { shift->{to} };
21sub room { shift->{room} };
22sub status { shift->{status} }
23
24sub login_extra {
25    my $self = shift;
26    my $show = $self->{show};
27    my $status = $self->status;
28    my $s = "";
29    $s .= $show if $show;
30    $s .= ", $status" if $status;
31    return $s;
32}
33
34sub long_sender {
35    my $self = shift;
36    return $self->from;
37}
38
39sub context {
40    return shift->room;
41}
42
43sub smartfilter {
44    my $self = shift;
45    my $inst = shift;
46
47    my ($filter, $ftext);
48
49    if($self->jtype eq 'chat') {
50        my $user;
51        if($self->direction eq 'in') {
52            $user = $self->from;
53        } else {
54            $user = $self->to;
55        }
56        return smartfilter_user($user, $inst);
57    } elsif ($self->jtype eq 'groupchat') {
58        my $room = $self->room;
59        $filter = "jabber-room-$room";
60        $ftext = qq{type ^jabber\$ and room ^$room\$};
61        BarnOwl::filter("$filter $ftext");
62        return $filter;
63    } elsif ($self->login ne 'none') {
64        return smartfilter_user($self->from, $inst);
65    }
66}
67
68sub smartfilter_user {
69    my $user = shift;
70    my $inst = shift;
71
72    $user   = Net::Jabber::JID->new($user)->GetJID( $inst ? 'full' : 'base' );
73    my $filter = "jabber-user-$user";
74    my $ftext  =
75        qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) }
76      . qq{or ( direction ^out\$ and to ^$user ) ) };
77    BarnOwl::filter("$filter $ftext");
78    return $filter;
79
80}
81
82
83=head1 SEE ALSO
84
85L<BarnOwl::Message>
86
87=cut
88
891;
Note: See TracBrowser for help on using the repository browser.