Changes in / [c55ad84:b7b4565]


Ignore:
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • README

    r6933082 r6824a76  
    2828We plan to soon add targets to the Makefile to check for and install
    2929these for you.
     30
     31The IRC module requires:
     32
     33Net::IRC
     34Class::Accessor
  • editwin.c

    rfac5463 rcc6f009  
    198198  int dotsend=e->dotsend;
    199199  char *locktext=NULL;
     200  char echochar=e->echochar;
    200201
    201202  lock=0;
     
    216217  if (dotsend) {
    217218    owl_editwin_set_dotsend(e);
     219  }
     220  if (echochar) {
     221    owl_editwin_set_echochar(e, echochar);
    218222  }
    219223
  • owl.c

    r0b7082c rf2d72128  
    262262  owl_style_create_internal(s, "basic", &owl_stylefunc_basic, "Basic message formatting.");
    263263  owl_global_add_style(&g, s);
    264   s=owl_malloc(sizeof(owl_style));
    265   owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline, "Formats for one-line-per-message");
    266   owl_global_add_style(&g, s);
    267264
    268265  /* setup the default filters */
  • perl/modules/IRC/lib/BarnOwl/Message/IRC.pm

    r2fb58e4 r1fd5041b  
    5656sub long_sender {shift->{from} || ""};
    5757
     58sub login_type {
     59    my $self = shift;
     60    return " (" . ($self->is_login ? "JOIN" : "PART") . ")";
     61}
     62
    5863sub login_extra { shift->channel; }
    5964
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    rfe8cad8 r56e72d5  
    104104    BarnOwl::new_command('irc-names'      => \&cmd_names);
    105105    BarnOwl::new_command('irc-whois'      => \&cmd_whois);
     106    BarnOwl::new_command('irc-motd'       => \&cmd_motd);
    106107}
    107108
     
    245246}
    246247
     248sub cmd_motd {
     249    my $cmd = shift;
     250    my $conn = get_connection(\@_);
     251    $conn->motd;
     252}
     253
    247254################################################################################
    248255########################### Utilities/Helpers ##################################
     
    256263    }
    257264    my $channel = $args->[-1];
    258     if ($channel =~ /^#/ and $channels{$channel} and @{$channels{$channel}} == 1) {
     265    if (defined($channel) && $channel =~ /^#/
     266        and $channels{$channel} and @{$channels{$channel}} == 1) {
    259267        return $channels{$channel}[0];
    260268    }
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r9e02bb7 reab7a4c  
    1616
    1717use base qw(Net::IRC::Connection Class::Accessor Exporter);
    18 __PACKAGE__->mk_accessors(qw(alias channels motd));
     18__PACKAGE__->mk_accessors(qw(alias channels owl_connected owl_motd));
    1919our @EXPORT_OK = qw(&is_private);
    2020
     
    2929    $self->alias($alias);
    3030    $self->channels([]);
    31     $self->motd("");
     31    $self->owl_motd("");
     32    $self->owl_connected(0);
    3233    bless($self, $class);
    3334
    3435    $self->add_default_handler(sub { goto &on_event; });
    35     $self->add_handler(376 => sub { goto &on_connect });
    3636    $self->add_handler(['msg', 'notice', 'public', 'caction'],
    3737            sub { goto &on_msg });
     
    5757############################### IRC callbacks ##################################
    5858################################################################################
    59 
    60 sub on_connect {
    61     my ($self, $evt) = @_;
    62     BarnOwl::admin_message("IRC", "Connected to " . $self->server . " (" . $self->alias . ")");
    63 }
    6459
    6560sub new_message {
     
    115110sub on_motdstart {
    116111    my ($self, $evt) = @_;
    117     $self->motd(join "\n", cdr $evt->args);
     112    $self->owl_motd(join "\n", cdr $evt->args);
    118113}
    119114
    120115sub on_motd {
    121116    my ($self, $evt) = @_;
    122     $self->motd(join "\n", $self->motd, cdr $evt->args);
     117    $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
    123118}
    124119
    125120sub on_endofmotd {
    126121    my ($self, $evt) = @_;
    127     $self->motd(join "\n", $self->motd, cdr $evt->args);
    128     BarnOwl::admin_message("IRC",
    129             BarnOwl::Style::boldify('MOTD for ' . $evt->alias) . "\n"
    130             . strip_irc_formatting($self->motd));
     122    $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
     123    if(!$self->owl_connected) {
     124        BarnOwl::admin_message("IRC", "Connected to " .
     125                               $self->server . " (" . $self->alias . ")");
     126        $self->owl_connected(1);
     127       
     128    }
     129    BarnOwl::admin_message("IRC",
     130            BarnOwl::Style::boldify('MOTD for ' . $self->alias) . "\n"
     131            . strip_irc_formatting($self->owl_motd));
    131132}
    132133
     
    162163                           "[" . $self->alias . "] " .
    163164                           [$evt->args]->[1] . ": Nick already in use");
     165    unless($self->owl_connected) {
     166        $self->disconnect;
     167    }
    164168}
    165169
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r892568b r05f0061  
    370370
    371371            if ( !@result || $result[0] ne 'ok' ) {
    372                 if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' ) ) {
     372                if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' || $result[0] eq 'error') ) {
    373373                    $vars{jlogin_havepass} = 1;
    374374                    $conn->removeConnection($jidStr);
  • perlconfig.c

    r5376a95 rff13a6f  
    482482void owl_perlconfig_cmd_free(owl_cmd *cmd)
    483483{
    484   SvREFCNT_dec(cmd);
     484  SvREFCNT_dec(cmd->cmd_perl);
    485485}
    486486
  • perlwrap.pm

    rb0c8011 rf2d72128  
    831831    # newline plus four spaces and that thing.
    832832    $body =~ s/\n(.)/\n    $1/g;
    833 
     833    # Trim trailing newlines.
     834    $body =~ s/\n*$//;
    834835    return "    ".$body;
    835836}
    836837
     838package BarnOwl::Style::OneLine;
     839################################################################################
     840# Branching point for various formatting functions in this style.
     841################################################################################
     842use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s ';
     843sub format_message($) {
     844  my $m = shift;
     845
     846#  if ( $m->is_zephyr ) {
     847#    return format_zephyr($m);
     848#  }
     849  if ( $m->is_login ) {
     850    return format_login($m);
     851  }
     852  elsif ( $m->is_ping) {
     853    return format_ping($m);
     854  }
     855  elsif ( $m->is_admin || $m->is_loopback) {
     856    return format_local($m);
     857  }
     858  else {
     859    return format_chat($m);
     860  }
     861}
     862
     863BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine::format_message", "Formats for one-line-per-message");
     864
     865################################################################################
     866
     867sub format_login($) {
     868  my $m = shift;
     869  return sprintf(
     870    BASE_FORMAT,
     871    '<',
     872    $m->type,
     873    uc( $m->login ),
     874    $m->pretty_sender)
     875    . ($m->login_extra ? "at ".$m->login_extra : '');
     876}
     877
     878sub format_ping($) {
     879  my $m = shift;
     880  return sprintf(
     881    BASE_FORMAT,
     882    '<',
     883    $m->type,
     884    'PING',
     885    $m->pretty_sender)
     886}
     887
     888sub format_chat($)
     889{
     890  my $m = shift;
     891  my $dir = lc($m->{direction});
     892  my $dirsym = '-';
     893  if ($dir eq 'in') {
     894    $dirsym = '<';
     895  }
     896  elsif ($dir eq 'out') {
     897    $dirsym = '>';
     898  }
     899
     900  my $line;
     901  if ($m->is_personal) {
     902    $line= sprintf(BASE_FORMAT,
     903                   $dirsym,
     904                   $m->type,
     905                   '',
     906                   ($dir eq 'out'
     907                      ? $m->pretty_recipient
     908                      : $m->pretty_sender));
     909  }
     910  else {
     911    $line = sprintf(BASE_FORMAT,
     912                    $dirsym,
     913                    $m->context,
     914                    $m->subcontext,
     915                    ($dir eq 'out'
     916                       ? $m->pretty_recipient
     917                       : $m->pretty_sender));
     918  }
     919
     920  my $body = $m->{body};
     921  $body =~ tr/\n/ /;
     922  $line .= $body;
     923  $line = BarnOwl::Style::boldify($line) if ($m->is_personal && lc($m->direction) eq 'in');
     924  return $line;
     925}
     926
     927# Format locally generated messages
     928sub format_local($)
     929{
     930  my $m = shift;
     931  my $type = uc($m->{type});
     932  my $line = sprintf(BASE_FORMAT, '<', $type, '', '');
     933  my $body = $m->{body};
     934  $body =~ tr/\n/ /;
     935  return $line.$body;
     936}
    837937
    838938package BarnOwl::Style;
  • stylefunc.c

    r0b7082c rf2d72128  
    220220  }
    221221}
    222 
    223 void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
    224 {
    225   char *tmp;
    226   char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
    227   char *sender, *recip;
    228 #ifdef HAVE_LIBZEPHYR
    229   ZNotice_t *n;
    230 #endif
    231 
    232   sender=short_zuser(owl_message_get_sender(m));
    233   recip=short_zuser(owl_message_get_recipient(m));
    234  
    235   if (owl_message_is_type_zephyr(m)) {
    236 #ifdef HAVE_LIBZEPHYR
    237     n=owl_message_get_notice(m);
    238    
    239     owl_fmtext_append_spaces(fm, OWL_TAB);
    240 
    241     if (owl_message_is_loginout(m)) {
    242       char *host, *tty;
    243      
    244       host=owl_message_get_attribute_value(m, "loginhost");
    245       tty=owl_message_get_attribute_value(m, "logintty");
    246 
    247       if (owl_message_is_login(m)) {
    248         tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender);
    249         owl_fmtext_append_normal(fm, tmp);
    250         owl_free(tmp);
    251       } else if (owl_message_is_logout(m)) {
    252         tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender);
    253         owl_fmtext_append_normal(fm, tmp);
    254         owl_free(tmp);
    255       }
    256 
    257       owl_fmtext_append_normal(fm, "at ");
    258       owl_fmtext_append_normal(fm, host ? host : "");
    259       owl_fmtext_append_normal(fm, " ");
    260       owl_fmtext_append_normal(fm, tty ? tty : "");
    261       owl_fmtext_append_normal(fm, "\n");
    262 
    263     } else if (owl_message_is_ping(m)) {
    264       tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
    265       owl_fmtext_append_normal(fm, tmp);
    266       owl_fmtext_append_normal(fm, "\n");
    267       owl_free(tmp);
    268 
    269     } else {
    270       if (owl_message_is_direction_in(m)) {
    271         tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
    272       } else if (owl_message_is_direction_out(m)) {
    273         tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
    274       } else {
    275         tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
    276       }
    277       owl_fmtext_append_normal(fm, tmp);
    278       if (tmp) owl_free(tmp);
    279      
    280       tmp=owl_strdup(owl_message_get_body(m));
    281       owl_text_tr(tmp, '\n', ' ');
    282       owl_fmtext_append_ztext(fm, tmp);
    283       owl_fmtext_append_normal(fm, "\n");
    284       if (tmp) owl_free(tmp);
    285     }
    286      
    287     /* make personal messages bold for smaat users */
    288     if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
    289         owl_message_is_personal(m) &&
    290         owl_message_is_direction_in(m)) {
    291       owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    292     }
    293 
    294     owl_free(sender);
    295     owl_free(recip);
    296 #endif
    297   } else if (owl_message_is_type_aim(m)) {
    298     owl_fmtext_append_spaces(fm, OWL_TAB);
    299     if (owl_message_is_login(m)) {
    300       tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
    301       owl_fmtext_append_normal(fm, tmp);
    302       owl_fmtext_append_normal(fm, "\n");
    303       if (tmp) owl_free(tmp);
    304     } else if (owl_message_is_logout(m)) {
    305       tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
    306       owl_fmtext_append_normal(fm, tmp);
    307       owl_fmtext_append_normal(fm, "\n");
    308       if (tmp) owl_free(tmp);
    309     } else {
    310       if (owl_message_is_direction_in(m)) {
    311         tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
    312         owl_fmtext_append_normal(fm, tmp);
    313         if (tmp) owl_free(tmp);
    314       } else if (owl_message_is_direction_out(m)) {
    315         tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
    316         owl_fmtext_append_normal(fm, tmp);
    317         if (tmp) owl_free(tmp);
    318       }
    319      
    320       tmp=owl_strdup(owl_message_get_body(m));
    321       owl_text_tr(tmp, '\n', ' ');
    322       owl_fmtext_append_normal(fm, tmp);
    323       owl_fmtext_append_normal(fm, "\n");
    324       if (tmp) owl_free(tmp);
    325 
    326       /* make personal messages bold for smaat users */
    327       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
    328         owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    329       }
    330     }
    331   } else if (owl_message_is_type_admin(m)) {
    332     owl_fmtext_append_spaces(fm, OWL_TAB);
    333     owl_fmtext_append_normal(fm, "< ADMIN                                  ");
    334    
    335     tmp=owl_strdup(owl_message_get_body(m));
    336     owl_text_tr(tmp, '\n', ' ');
    337     owl_fmtext_append_normal(fm, tmp);
    338     owl_fmtext_append_normal(fm, "\n");
    339     if (tmp) owl_free(tmp);
    340   } else {
    341     owl_fmtext_append_spaces(fm, OWL_TAB);
    342     owl_fmtext_append_normal(fm, "< LOOPBACK                               ");
    343    
    344     tmp=owl_strdup(owl_message_get_body(m));
    345     owl_text_tr(tmp, '\n', ' ');
    346     owl_fmtext_append_normal(fm, tmp);
    347     owl_fmtext_append_normal(fm, "\n");
    348     if (tmp) owl_free(tmp);
    349   }   
    350 
    351 }
Note: See TracChangeset for help on using the changeset viewer.