source: perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm @ 4789b17

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 4789b17 was 693c8f2, checked in by Alejandro R. Sedeño <asedeno@mit.edu>, 17 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
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 subject { shift->{subject} };
23sub status { shift->{status} }
24
25sub 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
35sub long_sender {
36    my $self = shift;
37    return $self->from;
38}
39
40sub context {
41    return shift->room;
42}
43
44sub subcontext {
45    return shift->subject || "";
46}
47
48sub 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
73sub 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
90L<BarnOwl::Message>
91
92=cut
93
941;
Note: See TracBrowser for help on using the repository browser.