Changeset 625802a for perl/modules


Ignore:
Timestamp:
Jan 28, 2008, 1:41:55 PM (16 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
ee310eb
Parents:
6fe806a (diff), 10e3963 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merged revisions 882-908 via svnmerge from 
file:///afs/sipb.mit.edu/project/barnowl/src/svn/trunk

........
  r889 | nelhage | 2008-01-16 22:03:00 -0500 (Wed, 16 Jan 2008) | 4 lines
  
  
  Rewrite ::Connection to not subclass Net::IRC::Connection to avoid
  stupid namespace conflicts
........
  r890 | nelhage | 2008-01-16 22:07:42 -0500 (Wed, 16 Jan 2008) | 2 lines
  
  svn:ignore for great justice
........
  r894 | asedeno | 2008-01-17 02:13:44 -0500 (Thu, 17 Jan 2008) | 2 lines
  
  dropping one unnecessary time(NULL) call.
........
  r898 | geofft | 2008-01-18 08:58:53 -0500 (Fri, 18 Jan 2008) | 4 lines
  
  * minor changes to IRC
  * run ./svkversion only once rather than at every cc
  * fix one-line style to format logouts, not just logins
........
  r900 | nelhage | 2008-01-23 23:20:12 -0500 (Wed, 23 Jan 2008) | 3 lines
  
  Fix the error messages sending to users who don't exist or aren't
  signed on.
........
Location:
perl/modules
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r56e72d5 r5ff830a  
    6565sub shutdown {
    6666    for my $conn (values %ircnets) {
    67         $conn->disconnect();
     67        $conn->conn->disconnect();
    6868    }
    6969}
     
    162162       );
    163163
    164     $ircnets{$alias} = $conn;
     164    if ($conn->connected) {
     165        BarnOwl::admin_message("IRC", "Connected to $alias as $nick");
     166        $ircnets{$alias} = $conn;
     167    } else {
     168        die("IRC::Connection->connect failed: $!");
     169    }
     170
    165171    return;
    166172}
     
    169175    my $cmd = shift;
    170176    my $conn = get_connection(\@_);
    171     $conn->disconnect;
     177    $conn->conn->disconnect;
    172178    delete $ircnets{$conn->alias};
    173179}
     
    191197    # Strip whitespace. In the future -- send one message/line?
    192198    $body =~ tr/\n\r/  /;
    193     $conn->privmsg($to, $body);
     199    $conn->conn->privmsg($to, $body);
    194200    my $msg = BarnOwl::Message->new(
    195201        type        => 'IRC',
     
    214220    $channels{$chan} ||= [];
    215221    push @{$channels{$chan}}, $conn;
    216     $conn->join($chan);
     222    $conn->conn->join($chan);
    217223}
    218224
     
    222228    my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
    223229    $channels{$chan} = [grep {$_ ne $conn} @{$channels{$chan} || []}];
    224     $conn->part($chan);
     230    $conn->conn->part($chan);
    225231}
    226232
     
    229235    my $conn = get_connection(\@_);
    230236    my $nick = shift or die("Usage: $cmd <new nick>\n");
    231     $conn->nick($nick);
     237    $conn->conn->nick($nick);
    232238}
    233239
     
    236242    my $conn = get_connection(\@_);
    237243    my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
    238     $conn->names($chan);
     244    $conn->conn->names($chan);
    239245}
    240246
     
    243249    my $conn = get_connection(\@_);
    244250    my $who = shift || die("Usage: $cmd <user>\n");
    245     $conn->whois($who);
     251    $conn->conn->whois($who);
    246252}
    247253
     
    249255    my $cmd = shift;
    250256    my $conn = get_connection(\@_);
    251     $conn->motd;
     257    $conn->conn->motd;
    252258}
    253259
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    reab7a4c r5ff830a  
    1010=head1 DESCRIPTION
    1111
    12 This module is a Net::IRC::Connection subclass for BarnOwl's IRC
     12This module is a wrapper around Net::IRC::Connection for BarnOwl's IRC
    1313support
    1414
    1515=cut
    1616
    17 use base qw(Net::IRC::Connection Class::Accessor Exporter);
    18 __PACKAGE__->mk_accessors(qw(alias channels owl_connected owl_motd));
     17use Net::IRC::Connection;
     18
     19use base qw(Class::Accessor Exporter);
     20__PACKAGE__->mk_accessors(qw(conn alias channels connected motd));
    1921our @EXPORT_OK = qw(&is_private);
    2022
    2123use BarnOwl;
     24
     25BEGIN {
     26    no strict 'refs';
     27    my @delegate = qw(nick server);
     28    for my $meth (@delegate) {
     29        *{"BarnOwl::Module::IRC::Connection::$meth"} = sub {
     30            shift->conn->$meth(@_);
     31        }
     32    }
     33};
    2234
    2335sub new {
     
    2638    my $alias = shift;
    2739    my %args = (@_);
    28     my $self = $class->SUPER::new($irc, %args);
     40    my $conn = Net::IRC::Connection->new($irc, %args);
     41    my $self = bless({}, $class);
     42    $self->conn($conn);
    2943    $self->alias($alias);
    3044    $self->channels([]);
    31     $self->owl_motd("");
    32     $self->owl_connected(0);
    33     bless($self, $class);
    34 
    35     $self->add_default_handler(sub { goto &on_event; });
    36     $self->add_handler(['msg', 'notice', 'public', 'caction'],
    37             sub { goto &on_msg });
    38     $self->add_handler(['welcome', 'yourhost', 'created',
    39             'luserclient', 'luserop', 'luserchannels', 'luserme'],
    40             sub { goto &on_admin_msg });
    41     $self->add_handler(['myinfo', 'map', 'n_local', 'n_global',
     45    $self->motd("");
     46    $self->connected(0);
     47
     48    $self->conn->add_handler(376 => sub { shift; $self->on_connect(@_) });
     49    $self->conn->add_default_handler(sub { shift; $self->on_event(@_) });
     50    $self->conn->add_handler(['msg', 'notice', 'public', 'caction'],
     51            sub { shift; $self->on_msg(@_) });
     52    $self->conn->add_handler(['welcome', 'yourhost', 'created',
     53            'luserclient', 'luserop', 'luserchannels', 'luserme',
     54            'notice', 'error'],
     55            sub { shift; $self->on_admin_msg(@_) });
     56    $self->conn->add_handler(['myinfo', 'map', 'n_local', 'n_global',
    4257            'luserconns'],
    4358            sub { });
    44     $self->add_handler(motdstart => sub { goto &on_motdstart });
    45     $self->add_handler(motd      => sub { goto &on_motd });
    46     $self->add_handler(endofmotd => sub { goto &on_endofmotd });
    47     $self->add_handler(join      => sub { goto &on_join });
    48     $self->add_handler(part      => sub { goto &on_part });
    49     $self->add_handler(disconnect => sub { goto &on_disconnect });
    50     $self->add_handler(nicknameinuse => sub { goto &on_nickinuse });
    51     $self->add_handler(cping     => sub { goto &on_ping });
     59    $self->conn->add_handler(motdstart => sub { shift; $self->on_motdstart(@_) });
     60    $self->conn->add_handler(motd      => sub { shift; $self->on_motd(@_) });
     61    $self->conn->add_handler(endofmotd => sub { shift; $self->on_endofmotd(@_) });
     62    $self->conn->add_handler(join      => sub { shift; $self->on_join(@_) });
     63    $self->conn->add_handler(part      => sub { shift; $self->on_part(@_) });
     64    $self->conn->add_handler(disconnect => sub { shift; $self->on_disconnect(@_) });
     65    $self->conn->add_handler(nicknameinuse => sub { shift; $self->on_nickinuse(@_) });
     66    $self->conn->add_handler(cping     => sub { shift; $self->on_ping(@_) });
    5267
    5368    return $self;
     
    97112sub on_ping {
    98113    my ($self, $evt) = @_;
    99     $self->ctcp_reply($evt->nick, join (' ', ($evt->args)));
     114    $self->conn->ctcp_reply($evt->nick, join (' ', ($evt->args)));
    100115}
    101116
     
    110125sub on_motdstart {
    111126    my ($self, $evt) = @_;
    112     $self->owl_motd(join "\n", cdr $evt->args);
     127    $self->motd(join "\n", cdr $evt->args);
    113128}
    114129
    115130sub on_motd {
    116131    my ($self, $evt) = @_;
    117     $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
     132    $self->motd(join "\n", $self->motd, cdr $evt->args);
    118133}
    119134
    120135sub on_endofmotd {
    121136    my ($self, $evt) = @_;
    122     $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
    123     if(!$self->owl_connected) {
     137    $self->motd(join "\n", $self->motd, cdr $evt->args);
     138    if(!$self->connected) {
    124139        BarnOwl::admin_message("IRC", "Connected to " .
    125140                               $self->server . " (" . $self->alias . ")");
    126         $self->owl_connected(1);
     141        $self->connected(1);
    127142       
    128143    }
    129144    BarnOwl::admin_message("IRC",
    130145            BarnOwl::Style::boldify('MOTD for ' . $self->alias) . "\n"
    131             . strip_irc_formatting($self->owl_motd));
     146            . strip_irc_formatting($self->motd));
    132147}
    133148
     
    163178                           "[" . $self->alias . "] " .
    164179                           [$evt->args]->[1] . ": Nick already in use");
    165     unless($self->owl_connected) {
    166         $self->disconnect;
     180    unless($self->connected) {
     181        $self->conn->disconnect;
    167182    }
    168183}
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r05f0061 r81312e4  
    2525use Net::DNS;
    2626use Getopt::Long;
     27
     28use utf8;
    2729
    2830our $VERSION = 0.1;
     
    373375                    $vars{jlogin_havepass} = 1;
    374376                    $conn->removeConnection($jidStr);
    375                     BarnOwl::start_password( "Password for $jidStr: ", \&do_login );
     377                    BarnOwl::start_password("Password for $jidStr: ", \&do_login );
    376378                    return "";
    377379                }
     
    477479    }
    478480    else {
    479         $to = shift @ARGV;
     481      $to = shift @ARGV;
    480482    }
    481483
     
    521523    $cmd .= " -t $jwrite_thread" if $jwrite_thread;
    522524    $cmd .= " -s $jwrite_subject" if $jwrite_subject;
    523     BarnOwl::start_edit_win( $cmd, \&process_owl_jwrite );
     525
     526    BarnOwl::start_edit_win($cmd, \&process_owl_jwrite );
    524527}
    525528
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm

    r892568b re0ffe77  
    11use warnings;
    22use strict;
     3use utf8;
    34
    45=head1 NAME
  • perl/modules/Jabber/lib/Net/XMPP/Debug.pm

    rc2bed55 rb7b2a76  
    189189                        {
    190190                            $self->{HANDLE}->autoflush(1);
     191                            binmode $self->{HANDLE}, ":utf8";
    191192                            $Net::XMPP::Debug::HANDLES{$args{file}} = $self->{HANDLE};
    192193                        }
  • perl/modules/Jabber/lib/Net/XMPP/Message.pm

    rc2bed55 r8574801  
    135135                            $Mess->SetMessage(TO=>"bob\@jabber.org",
    136136                                              Subject=>"Lunch",
    137                                               BoDy=>"Let's do lunch!");
     137                                              Body=>"Let's do lunch!");
    138138                            $Mess->SetMessage(to=>"bob\@jabber.org",
    139139                                              from=>"jabber.org",
  • perl/modules/Jabber/lib/XML/Stream.pm

    r5073972 ra8d5a39  
    16591659    {
    16601660        $self->debug(3,"Send: can_write");
    1661        
     1661
    16621662        $self->{SENDSTRING} = Encode::encode_utf8(join("",@_));
    16631663
Note: See TracChangeset for help on using the changeset viewer.