debianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since a1a2036 was
a1a2036,
checked in by Geoffrey Thomas <geofft@mit.edu>, 17 years ago
|
THIS IS AN ANGRY COMMIT
|
-
Property mode set to
100644
|
File size:
1.9 KB
|
Line | |
---|
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} }; |
---|
22 | sub subject { shift->{subject} }; |
---|
23 | sub status { shift->{status} } |
---|
24 | |
---|
25 | sub login_type { |
---|
26 | my $self = shift; |
---|
27 | my $type = $self->jtype; |
---|
28 | return " ($type)" if $type; |
---|
29 | } |
---|
30 | |
---|
31 | sub login_extra { |
---|
32 | my $self = shift; |
---|
33 | my $show = $self->{show}; |
---|
34 | my $status = $self->status; |
---|
35 | my $s = ""; |
---|
36 | $s .= $show if $show; |
---|
37 | $s .= ", $status" if $status; |
---|
38 | return $s; |
---|
39 | } |
---|
40 | |
---|
41 | sub long_sender { |
---|
42 | my $self = shift; |
---|
43 | return $self->from; |
---|
44 | } |
---|
45 | |
---|
46 | sub context { |
---|
47 | return shift->room; |
---|
48 | } |
---|
49 | |
---|
50 | sub subcontext { |
---|
51 | return shift->subject || ""; |
---|
52 | } |
---|
53 | |
---|
54 | sub smartfilter { |
---|
55 | my $self = shift; |
---|
56 | my $inst = shift; |
---|
57 | |
---|
58 | my ($filter, $ftext); |
---|
59 | |
---|
60 | if($self->jtype eq 'chat') { |
---|
61 | my $user; |
---|
62 | if($self->direction eq 'in') { |
---|
63 | $user = $self->from; |
---|
64 | } else { |
---|
65 | $user = $self->to; |
---|
66 | } |
---|
67 | return smartfilter_user($user, $inst); |
---|
68 | } elsif ($self->jtype eq 'groupchat') { |
---|
69 | my $room = $self->room; |
---|
70 | $filter = "jabber-room-$room"; |
---|
71 | $ftext = qq{type ^jabber\$ and room ^$room\$}; |
---|
72 | BarnOwl::filter("$filter $ftext"); |
---|
73 | return $filter; |
---|
74 | } elsif ($self->login ne 'none') { |
---|
75 | return smartfilter_user($self->from, $inst); |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | sub smartfilter_user { |
---|
80 | my $user = shift; |
---|
81 | my $inst = shift; |
---|
82 | |
---|
83 | $user = Net::Jabber::JID->new($user)->GetJID( $inst ? 'full' : 'base' ); |
---|
84 | my $filter = "jabber-user-$user"; |
---|
85 | my $ftext = |
---|
86 | qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) } |
---|
87 | . qq{or ( direction ^out\$ and to ^$user ) ) }; |
---|
88 | BarnOwl::filter("$filter $ftext"); |
---|
89 | return $filter; |
---|
90 | |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | =head1 SEE ALSO |
---|
95 | |
---|
96 | L<BarnOwl::Message> |
---|
97 | |
---|
98 | =cut |
---|
99 | |
---|
100 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.