DELTA 689 25273 610
SVN  òMòw( ´[ ¨ Yë| ½µ2    $self->{DEBUG}->GetHandle()->close()ENDREP
DELTA 799 658 1155
SVN  ’H´<1¬  €F J†@ .‡€v VŠn iŒ(€—N J†@ _$€D )‘€Kwrapper around Net::IRC::Connection for BarnOwl's IRC
support

=cut

use Net::IRC::Connection;

use base qw(Class::Accessor Exporter);
__PACKAGE__->mk_accessors(qw(conn alias channels connected motd));
our @EXPORT_OK = qw(&is_private);

use BarnOwl;

BEGIN {
    no strict 'refs';
    my @delegate = qw(nick server);
    for my $meth (@delegate) {
        *{"BarnOwl::Module::IRC::Connection::$meth"} = sub {
            shift->conn->$meth(@_);
        }
    }
};

sub new {
    my $class = shift;
    my $irc = shift;
    my $alias = shift;
    my %args = (@_);
    my $conn = Net::IRC::Connection->new($irc, %args);
    my $self = bless({}, $class);
    $self->conn($conn);
    $self->alias($alias);
    $self->channels([]);
    $self->motd("");
    $self->connected(0);

    $self->conn->add_handler(376 => sub { shift; $self->on_connect(@_) });
    $self->conn->add_default_handler(sub { shift; $self->on_event(@_) });
    $self->conn->add_handler(['msg', 'notice', 'public', 'caction'],
            sub { shift; $self->on_msg(@_) });
    $self->conn->add_handler(['welcome', 'yourhost', 'created',
            'luserclient', 'luserop', 'luserchannels', 'luserme',
            'notice', 'error'],
            sub { shift; $self->on_admin_msg(@_) });
    $self->conn->add_handler(['myinfo', 'map', 'n_local', 'n_global',
            'luserconns'],
            sub { });
    $self->conn->add_handler(motdstart => sub { shift; $self->on_motdstart(@_) });
    $self->conn->add_handler(motd      => sub { shift; $self->on_motd(@_) });
    $self->conn->add_handler(endofmotd => sub { shift; $self->on_endofmotd(@_) });
    $self->conn->add_handler(join      => sub { shift; $self->on_join(@_) });
    $self->conn->add_handler(part      => sub { shift; $self->on_part(@_) });
    $self->conn->add_handler(disconnect => sub { shift; $self->on_disconnect(@_) });
    $self->conn->add_handler(nicknameinuse => sub { shift; $self->on_nickinuse(@_) });
    $self->conn->add_handler(cping     => sub { shift; $self->on_ping(@_) });

    return $self;
}

sub getSocket
{
    my $self = shift;
    return $self->conn->socket;
}

new_message {
    my $self = shift;
    my $evt = shift;
    return BarnOwl::Message->new(
        type        => 'IRC@_
       );
}

sub on_msg {
    my ($self, $evt) = @_;
    my ($recipient) = $evt->to;
    my $body = strip_irc_formatting([$evt->args]->[0]);
    my $nick = $self->nick;
    BarnOwl::beep() if $body =~ /\b\Q$nick\E\b/;
    $body = BarnOwl::Style::boldify($evt->nick.' '.$body) if $evt->type eq 'caction';
    my $msg = $self->new_message($evt,
        direction   => 'in',
        recipient   => $recipient,
        body => $body,
        $evt->type eq 'notice' ?
          (notice     => 'true') : (),
        is_private($recipient) ?
          (isprivate  => 'true') : (channel => $recipient),
        replycmd    => 'irc-msg ' .
            (is_private($recipient) ? $evt->nick : $recipient),
        replysendercmd => 'irc-msg ' . $evt->nick
       );

    BarnOwl::queue_message($msg);
}

sub on_ping {
    my ($self, $evt) = @_;
    $self->conn->ctcp_reply($evt->nick, join (' ', ($evt->args)));
}

sub on_admin_msg {
    my ($self, $evt) = @_;
    BarnOwl::admin_message("IRC",
            BarnOwl::Style::boldify('IRC ' . $evt->type . ' message from '
                . $self->alias) . "\n"
            . strip_irc_formatting(join '\n', $evt->args));
}

sub on_motdstart {
    my ($self, $evt) = @_;
    $self->motd(join "\n", cdr($evt->args));
}

sub on_motd {
    my ($self, $evt) = @_;
    $self->motd(join "\n", $self->motd, cdr($evt->args));
}

sub on_endofmotd {
    my ($self, $evt) = @_;
    $self->motd(join "\n", $self->motd, cdr($evt->args));
    if(!$self->connected) {
        BarnOwl::admin_message("IRC", "Connected to " .
                               $self->server . " (" . $self->alias . ")");
        $self->connected(1);
        
    }
    BarnOwl::admin_message("IRC",
            BarnOwl::Style::boldify('MOTD for ' . $self->alias) . "\n"
            . strip_irc_formatting($self->motd));
}

sub on_join {
    my ($self, $evt) = @_;
    my $msg = $self->new_message($evt,
        loginout   => 'login',
        channel    => $evt->to,
        );
    BarnOwl::queue_message($msg);
}

sub on_part {
    my ($self, $evt) = @_;
    my $msg = $self->new_message($evt,
        loginout   => 'logout',
        channel    => $evt->to,
        );
    BarnOwl::queue_message($msg);
}

sub on_disconnect {
    my $self = shift;
    delete $BarnOwl::Module::IRC::ircnets{$self->alias};
    BarnOwl::remove_dispatch($self->{FD});
    BarnOwl::admin_message('IRC',
                           "[" . $self->alias . "] Disconnected from server");
}

sub on_nickinuse {
    my ($self, $evt) = @_;
    BarnOwl::admin_message("IRC",
                           "[" . $self->alias . "] " .
                           [$evt->args]->[1] . ": Nick already in use");
    unless($self->connected) {
        $self->conn->disconnect;
    }
}

sub on_event {
    my ($self, $evt) = @_;
    BarnOwl::admin_message("IRC",
            "[" . $self->alias . "] Unhandled IRC event of type " . $evt->type . ":\n"
            . strip_irc_formatting(join("\n", $evt->args)))
        if BarnOwl::getvar('irc:spew') eq 'on';
}


# Strip mIRC colors. If someone wants to write code to convert
    # these to zephyr colors, be my guest.
    $body =~ s/\cC\d+(?:,\d+)?//g;
    $body =~ s/\cO//g;
    
    my @pieces = split /\cB# Determines if the given message recipient is a username, as opposed to
# a channel that starts with # or &.
sub is_private {
    return shift !~ /^[\#\&]/;
}

sub cdr {
    shift;
    return @_;
}

1;
ENDREP
id: 51.1z.r975/5836
type: file
pred: 51.1s.r689/54853
count: 3
text: 975 0 65 14711 158ef70ad6dc1a8229377ee289546136
cpath: /branches/barnowl_unicode/owl/perl/modules/Jabber/lib/Net/XMPP/Connection.pm
copyroot: 689 /trunk/owl/perl/modules/Jabber/lib/Net

PLAIN
K 9
Client.pm
V 21
file 50.1s.r689/54382
K 13
Connection.pm
V 20
file 51.1z.r975/5836
K 8
Debug.pm
V 19
file 52.1z.r885/135
K 5
IQ.pm
V 21
file 53.1s.r689/54149
K 6
JID.pm
V 21
file 54.1s.r689/53914
K 10
Message.pm
V 20
file 55.1z.r883/1690
K 13
Namespaces.pm
V 21
file 56.0.r448/256543
K 11
Presence.pm
V 21
file 57.1s.r689/53439
K 15
PrivacyLists.pm
V 21
file 58.0.r448/255886
K 11
Protocol.pm
V 20
file 59.1s.r694/2114
K 9
Roster.pm
V 21
file 5a.1s.r689/54618
K 9
Stanza.pm
V 21
file 5b.1s.r689/55091
END
ENDREP
id: 4z.1z.r975/6612
type: dir
pred: 4z.1z.r885/904
count: 13
text: 975 6091 508 508 9e2afddb937d96f4abec74b7a9fb67d6
cpath: /branches/barnowl_unicode/owl/perl/modules/Jabber/lib/Net/XMPP
copyroot: 689 /trunk/owl/perl/modules/Jabber/lib/Net

PLAIN
K 6
Jabber
V 20
dir 4e.1z.r777/39474
K 9
Jabber.pm
V 21
file 4y.1s.r689/52969
K 4
XMPP
V 19
dir 4z.1z.r975/6612
K 7
XMPP.pm
V 21
file 5c.1s.r689/52739
END
ENDREP
id: 4d.1z.r975/7021
type: dir
pred: 4d.1z.r885/1310
count: 18
text: 975 6853 155 155 98872d35d3ea395e657b9c291d8d44eb
cpath: /branches/barnowl_unicode/owl/perl/modules/Jabber/lib/Net
copyroot: 689 /trunk/owl/perl/modules/Jabber/lib/Net

PLAIN
K 7
BarnOwl
V 20
dir 7d.1t.r952/13402
K 3
Net
V 19
dir 4d.1z.r975/7021
K 3
XML
V 18
dir 5d.20.r888/520
END
ENDREP
id: 7c.1t.r975/7378
type: dir
pred: 7c.1t.r952/13751
count: 23
text: 975 7258 107 107 23d13295bc401ff2459b1f569c2a0f33
cpath: /branches/barnowl_unicode/owl/perl/modules/Jabber/lib
copyroot: 734 /branches/barnowl_unicode

PLAIN
K 11
Makefile.PL
V 20
file 7l.0.r689/61684
K 3
inc
V 19
dir 7m.0.r689/64277
K 3
lib
V 19
dir 7c.1t.r975/7378
END
ENDREP
id: 7b.1t.r975/7725
type: dir
pred: 7b.1t.r952/14101
count: 24
text: 975 7599 113 113 7d805e0065dad8e34657b24e579fd579
props: 715 291 36 0 c99a04e888ce19b39116b15dc82c3a1a
cpath: /branches/barnowl_unicode/owl/perl/modules/Jabber
copyroot: 734 /branches/barnowl_unicode

id: 8a.23.r975/7995
type: file
pred: 8a.23.r972/588
count: 8
text: 975 92 5718 6716 ea6b892f983368ed4badbed3a51817cd
cpath: /branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
copyroot: 803 /branches/barnowl_unicode/owl/perl/modules/IRC

PLAIN
K 13
Connection.pm
V 20
file 8a.23.r975/7995
END
ENDREP
id: 89.23.r975/8327
type: dir
pred: 89.23.r972/917
count: 8
text: 975 8265 49 49 14666f836944d7685f35580bf5424ae4
cpath: /branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC
copyroot: 803 /branches/barnowl_unicode/owl/perl/modules/IRC

PLAIN
K 3
IRC
V 19
dir 89.23.r975/8327
K 6
IRC.pm
V 21
file 8b.23.r952/14373
END
ENDREP
id: 88.23.r975/8668
type: dir
pred: 88.23.r972/1256
count: 10
text: 975 8580 75 75 405b16a59b70f3cf1a44370c0f4d375a
cpath: /branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module
copyroot: 803 /branches/barnowl_unicode/owl/perl/modules/IRC

PLAIN
K 7
Message
V 20
dir 86.23.r882/12700
K 6
Module
V 19
dir 88.23.r975/8668
END
ENDREP
id: 85.23.r975/9010
type: dir
pred: 85.23.r972/1597
count: 10
text: 975 8919 78 78 74660459e222cad2fd3105b5352110ce
cpath: /branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl
copyroot: 803 /branches/barnowl_unicode/owl/perl/modules/IRC

PLAIN
K 7
BarnOwl
V 19
dir 85.23.r975/9010
END
ENDREP
id: 84.23.r975/9308
type: dir
pred: 84.23.r972/1894
count: 10
text: 975 9254 41 41 91e2c79f57a30b7435e90bebafcd5f95
cpath: /branches/barnowl_unicode/owl/perl/modules/IRC/lib
copyroot: 803 /branches/barnowl_unicode/owl/perl/modules/IRC

PLAIN
K 11
Makefile.PL
V 19
file 83.0.r799/5757
K 3
lib
V 19
dir 84.23.r975/9308
END
ENDREP
id: 82.23.r975/9636
type: dir
pred: 82.23.r972/2221
count: 11
text: 975 9544 79 79 33a89209d9669ee1fd1f713aa8c1753d
props: 909 18473 72 0 01f51dd7f7b5d4f3e04c1d64e0d8fadc
cpath: /branches/barnowl_unicode/owl/perl/modules/IRC
copyroot: 803 /branches/barnowl_unicode/owl/perl/modules/IRC

PLAIN
K 3
IRC
V 19
dir 82.23.r975/9636
K 6
Jabber
V 19
dir 7b.1t.r975/7725
END
ENDREP
id: 4c.1t.r975/10009
type: dir
pred: 4c.1t.r972/2595
count: 97
text: 975 9923 73 73 1eeb8f5e9a5db6b9dd15777836bc3b3e
cpath: /branches/barnowl_unicode/owl/perl/modules
copyroot: 734 /branches/barnowl_unicode

PLAIN
K 3
lib
V 20
dir 4b.1t.r952/11645
K 7
modules
V 20
dir 4c.1t.r975/10009
END
ENDREP
id: 4a.1t.r975/10306
type: dir
pred: 4a.1t.r972/2890
count: 111
text: 975 10217 76 76 d22cf400b913c2853cba20d910d672dc
cpath: /branches/barnowl_unicode/owl/perl
copyroot: 734 /branches/barnowl_unicode

PLAIN
K 4
BUGS
V 20
file 5u.0.r689/48450
K 9
ChangeLog
V 18
file h.0.r393/2438
K 11
Makefile.in
V 19
file i.1t.r952/9993
K 4
NEWS
V 16
file j.0.r5/8251
K 6
README
V 21
file 5r.1t.r882/16745
K 4
TODO
V 18
file 5s.0.r619/324
K 5
aim.c
V 20
file 22.1t.r776/6355
K 9
athstatic
V 18
file 1x.0.r533/117
K 7
buddy.c
V 20
file 3o.0.r234/19726
K 11
buddylist.c
V 20
file 3d.0.r238/12168
K 5
cmd.c
V 19
file k.1t.r776/7389
K 11
codelist.pl
V 19
file l.0.r212/11814
K 10
commands.c
V 20
file m.1t.r791/14749
K 11
config.h.in
V 18
file n.1t.r794/391
K 12
configure.ac
V 16
file p.28.r938/0
K 9
context.c
V 18
file q.0.r209/8754
K 6
debian
V 20
dir 63.1t.r777/33079
K 6
dict.c
V 20
file r.1t.r924/33214
K 3
doc
V 18
dir 1n.0.r589/1227
K 9
editwin.c
V 17
file s.1t.r961/84
K 14
encapsulate.pl
V 20
file 3l.0.r225/44724
K 10
errqueue.c
V 20
file 3p.0.r242/19206
K 8
examples
V 17
dir 1s.0.r226/477
K 8
filter.c
V 20
file t.1t.r924/37519
K 15
filterelement.c
V 20
file u.1t.r924/32423
K 8
fmtext.c
V 19
file v.1t.r929/3665
K 11
functions.c
V 20
file w.1t.r952/10255
K 13
glib_compat.c
V 19
file 81.1t.r793/825
K 8
global.c
V 18
file x.1t.r964/709
K 6
help.c
V 17
file y.0.r712/145
K 9
history.c
V 17
file z.0.r283/439
K 10
install.sh
V 19
file 21.0.r122/7916
K 12
keybinding.c
V 18
file 10.0.r640/656
K 8
keymap.c
V 20
file 11.1t.r811/2997
K 10
keypress.c
V 20
file 12.1t.r811/2738
K 6
keys.c
V 21
file 13.1t.r952/10522
K 7
libfaim
V 16
dir 23.0.r716/87
K 6
list.c
V 17
file 14.0.r635/59
K 9
logging.c
V 21
file 15.1t.r924/38844
K 9
mainwin.c
V 20
file 16.0.r693/11667
K 9
message.c
V 20
file 17.1t.r958/2875
K 13
messagelist.c
V 18
file 18.0.r558/539
K 13
mkinstalldirs
V 19
file 3v.0.r346/1232
K 11
muxevents.c
V 18
file 3w.0.r359/781
K 9
obarray.c
V 21
file 62.1t.r924/33473
K 5
owl.c
V 20
file 19.1t.r958/3139
K 5
owl.h
V 21
file 1a.1t.r952/17970
K 6
pair.c
V 18
file 1z.0.r102/270
K 4
perl
V 20
dir 4a.1t.r975/10306
K 12
perlconfig.c
V 21
file 3n.1t.r952/17438
K 11
perlglue.xs
V 21
file 1v.1t.r952/17172
K 11
perlwrap.pm
V 21
file 3m.1t.r909/16023
K 9
popexec.c
V 19
file 3x.0.r364/1658
K 8
popwin.c
V 18
file 1b.0.r373/263
K 7
regex.c
V 19
file 1c.0.r597/1404
K 8
select.c
V 19
file 8l.2a.r955/747
K 10
stubgen.pl
V 17
file 1d.0.r5/8659
K 7
style.c
V 19
file 3f.0.r280/1095
K 11
stylefunc.c
V 21
file 3g.1t.r882/16479
K 10
svkversion
V 18
file 6d.0.r660/834
K 1
t
V 20
dir 7y.1y.r777/43781
K 6
test.h
V 21
file 3y.1t.r777/41418
K 8
tester.c
V 21
file 1e.1t.r777/43522
K 6
text.c
V 19
file 1f.1t.r972/333
K 7
timer.c
V 20
file 3e.0.r143/11961
K 6
util.c
V 21
file 1g.1t.r924/32953
K 10
variable.c
V 19
file 1h.1t.r928/585
K 6
view.c
V 19
file 1i.0.r586/9731
K 9
viewwin.c
V 21
file 1j.1t.r792/45814
K 9
wcwidth.c
V 21
file 80.1t.r792/46341
K 12
zbuddylist.c
V 18
file 3u.0.r330/561
K 8
zcrypt.c
V 20
file 1y.1t.r776/6613
K 8
zephyr.c
V 21
file 1k.1t.r952/18429
K 8
zwrite.c
V 20
file 1l.1t.r788/3211
END
ENDREP
id: g.1t.r975/13409
type: dir
pred: g.1t.r972/5990
count: 727
text: 975 10508 2888 2888 d80c8cb336596d6bb939e1181fe5f22d
props: 964 6382 508 0 000a49fe022dfbf0d61c1b737956e1d2
cpath: /branches/barnowl_unicode/owl
copyroot: 734 /branches/barnowl_unicode

PLAIN
K 7
CVSROOT
V 16
dir 4.0.r112/895
K 11
conf.alexmv
V 20
dir 5z.1t.r791/14548
K 12
conf.asedeno
V 18
dir 3z.0.r617/2908
K 3
owl
V 19
dir g.1t.r975/13409
END
ENDREP
PLAIN
K 9
svk:merge
V 181
bb873fd7-8e23-0410-944a-99ec44c633eb:/branches/owl/filter-rewrite:15925
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h/trunk:19588
fe09232e-8620-0410-8e36-e6b4839e121d:/trunk:598
K 19
svnmerge-integrated
V 12
/trunk:1-974
END
ENDREP
id: 1.1t.r975/14094
type: dir
pred: 1.1t.r972/6672
count: 760
text: 975 13663 156 156 c29c0af986ee6265ffba3755541a62a9
props: 975 13832 249 0 789771b6a4483c3e3c59b8076d406372
cpath: /branches/barnowl_unicode
copyroot: 734 /branches/barnowl_unicode

PLAIN
K 14
barnowl_sqlite
V 18
dir 1.1u.r970/3767
K 15
barnowl_unicode
V 19
dir 1.1t.r975/14094
K 14
barnowl_unisql
V 17
dir 1.27.r919/325
K 7
owl-1_2
V 15
dir 1.4.r116/49
K 7
owl-2_0
V 18
dir 1.5.r306/13541
K 14
owl-2_0-branch
V 18
dir 1.1f.r317/6751
END
ENDREP
id: 2.0.r975/14606
type: dir
pred: 2.0.r972/7180
count: 170
text: 975 14343 250 250 7aa47ba9d9d1cd852c3e5af39db5260c
cpath: /branches
copyroot: 0 /

PLAIN
K 8
branches
V 18
dir 2.0.r975/14606
K 4
tags
V 16
dir 3.0.r391/435
K 5
trunk
V 17
dir 1.0.r974/5709
END
ENDREP
id: 0.0.r975/14873
type: dir
pred: 0.0.r974/6025
count: 975
text: 975 14755 105 105 8d40f9a27afe1a2d8e82abf3c2218c38
props: 814 5811 257 0 1bba3ff3b0bec5c44a6f38be0d2645e9
cpath: /
copyroot: 0 /

51.1z.t974-1 modify true false /branches/barnowl_unicode/owl/perl/modules/Jabber/lib/Net/XMPP/Connection.pm

8a.23.t974-1 modify true false /branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

1.1t.t974-1 modify false true /branches/barnowl_unicode


14873 15069
