Index: README
===================================================================
--- README	(revision 69330820edcbdc4bc68417408d46168f9aad7cda)
+++ README	(revision 6824a761650618e2ebf99d9beab3f0e2ac156a8f)
@@ -28,2 +28,7 @@
 We plan to soon add targets to the Makefile to check for and install
 these for you.
+
+The IRC module requires:
+
+Net::IRC
+Class::Accessor
Index: editwin.c
===================================================================
--- editwin.c	(revision fac5463dbde789ec17cf1e7b828366dd7911806f)
+++ editwin.c	(revision cc6f009750d9fa16a07d5f504a57c299f6a1d646)
@@ -198,4 +198,5 @@
   int dotsend=e->dotsend;
   char *locktext=NULL;
+  char echochar=e->echochar;
 
   lock=0;
@@ -216,4 +217,7 @@
   if (dotsend) {
     owl_editwin_set_dotsend(e);
+  }
+  if (echochar) {
+    owl_editwin_set_echochar(e, echochar);
   }
 
Index: owl.c
===================================================================
--- owl.c	(revision 0b7082c1518be8fb8e173d6702a8f51fa1a89535)
+++ owl.c	(revision f2d72128d54fe0a3466422505e2ae01e3b137498)
@@ -262,7 +262,4 @@
   owl_style_create_internal(s, "basic", &owl_stylefunc_basic, "Basic message formatting.");
   owl_global_add_style(&g, s);
-  s=owl_malloc(sizeof(owl_style));
-  owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline, "Formats for one-line-per-message");
-  owl_global_add_style(&g, s);
 
   /* setup the default filters */
Index: perl/modules/IRC/lib/BarnOwl/Message/IRC.pm
===================================================================
--- perl/modules/IRC/lib/BarnOwl/Message/IRC.pm	(revision 2fb58e45694a11ffa70ef1d19cc3dfd7918b329b)
+++ perl/modules/IRC/lib/BarnOwl/Message/IRC.pm	(revision 1fd5041b7e56c0c359ddbe5704c89317a1f877f0)
@@ -56,4 +56,9 @@
 sub long_sender {shift->{from} || ""};
 
+sub login_type {
+    my $self = shift;
+    return " (" . ($self->is_login ? "JOIN" : "PART") . ")";
+}
+
 sub login_extra { shift->channel; }
 
Index: perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
===================================================================
--- perl/modules/IRC/lib/BarnOwl/Module/IRC.pm	(revision fe8cad8a54b6d52e321b40cc805adfc2522af7a5)
+++ perl/modules/IRC/lib/BarnOwl/Module/IRC.pm	(revision 56e72d52601116f990fcc6a15f4e71f51adfd238)
@@ -104,4 +104,5 @@
     BarnOwl::new_command('irc-names'      => \&cmd_names);
     BarnOwl::new_command('irc-whois'      => \&cmd_whois);
+    BarnOwl::new_command('irc-motd'       => \&cmd_motd);
 }
 
@@ -245,4 +246,10 @@
 }
 
+sub cmd_motd {
+    my $cmd = shift;
+    my $conn = get_connection(\@_);
+    $conn->motd;
+}
+
 ################################################################################
 ########################### Utilities/Helpers ##################################
@@ -256,5 +263,6 @@
     }
     my $channel = $args->[-1];
-    if ($channel =~ /^#/ and $channels{$channel} and @{$channels{$channel}} == 1) {
+    if (defined($channel) && $channel =~ /^#/
+        and $channels{$channel} and @{$channels{$channel}} == 1) {
         return $channels{$channel}[0];
     }
Index: perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
===================================================================
--- perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm	(revision 9e02bb78fcc7ee5c63918ba55134a43b1b1266e4)
+++ perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm	(revision eab7a4c4530c5e21dfa6a88f13259657fb19949a)
@@ -16,5 +16,5 @@
 
 use base qw(Net::IRC::Connection Class::Accessor Exporter);
-__PACKAGE__->mk_accessors(qw(alias channels motd));
+__PACKAGE__->mk_accessors(qw(alias channels owl_connected owl_motd));
 our @EXPORT_OK = qw(&is_private);
 
@@ -29,9 +29,9 @@
     $self->alias($alias);
     $self->channels([]);
-    $self->motd("");
+    $self->owl_motd("");
+    $self->owl_connected(0);
     bless($self, $class);
 
     $self->add_default_handler(sub { goto &on_event; });
-    $self->add_handler(376 => sub { goto &on_connect });
     $self->add_handler(['msg', 'notice', 'public', 'caction'],
             sub { goto &on_msg });
@@ -57,9 +57,4 @@
 ############################### IRC callbacks ##################################
 ################################################################################
-
-sub on_connect {
-    my ($self, $evt) = @_;
-    BarnOwl::admin_message("IRC", "Connected to " . $self->server . " (" . $self->alias . ")");
-}
 
 sub new_message {
@@ -115,18 +110,24 @@
 sub on_motdstart {
     my ($self, $evt) = @_;
-    $self->motd(join "\n", cdr $evt->args);
+    $self->owl_motd(join "\n", cdr $evt->args);
 }
 
 sub on_motd {
     my ($self, $evt) = @_;
-    $self->motd(join "\n", $self->motd, cdr $evt->args);
+    $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
 }
 
 sub on_endofmotd {
     my ($self, $evt) = @_;
-    $self->motd(join "\n", $self->motd, cdr $evt->args);
-    BarnOwl::admin_message("IRC",
-            BarnOwl::Style::boldify('MOTD for ' . $evt->alias) . "\n"
-            . strip_irc_formatting($self->motd));
+    $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
+    if(!$self->owl_connected) {
+        BarnOwl::admin_message("IRC", "Connected to " .
+                               $self->server . " (" . $self->alias . ")");
+        $self->owl_connected(1);
+        
+    }
+    BarnOwl::admin_message("IRC",
+            BarnOwl::Style::boldify('MOTD for ' . $self->alias) . "\n"
+            . strip_irc_formatting($self->owl_motd));
 }
 
@@ -162,4 +163,7 @@
                            "[" . $self->alias . "] " .
                            [$evt->args]->[1] . ": Nick already in use");
+    unless($self->owl_connected) {
+        $self->disconnect;
+    }
 }
 
Index: perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
===================================================================
--- perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	(revision 892568bf6e3ceea8724cef719078e5f6c2455b16)
+++ perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	(revision 05f0061e58c81a1d32a1a1385b05b75d0b73360e)
@@ -370,5 +370,5 @@
 
             if ( !@result || $result[0] ne 'ok' ) {
-                if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' ) ) {
+                if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' || $result[0] eq 'error') ) {
                     $vars{jlogin_havepass} = 1;
                     $conn->removeConnection($jidStr);
Index: perlconfig.c
===================================================================
--- perlconfig.c	(revision 5376a95c0ff753a89c734d966bf048447b90f3db)
+++ perlconfig.c	(revision ff13a6f4c60b5298ed361b690905db36a382fe26)
@@ -482,5 +482,5 @@
 void owl_perlconfig_cmd_free(owl_cmd *cmd)
 {
-  SvREFCNT_dec(cmd);
+  SvREFCNT_dec(cmd->cmd_perl);
 }
 
Index: perlwrap.pm
===================================================================
--- perlwrap.pm	(revision b0c8011c53aca2ee3a18f07e779400df969cbdb3)
+++ perlwrap.pm	(revision f2d72128d54fe0a3466422505e2ae01e3b137498)
@@ -831,8 +831,108 @@
     # newline plus four spaces and that thing.
     $body =~ s/\n(.)/\n    $1/g;
-
+    # Trim trailing newlines.
+    $body =~ s/\n*$//;
     return "    ".$body;
 }
 
+package BarnOwl::Style::OneLine;
+################################################################################
+# Branching point for various formatting functions in this style.
+################################################################################
+use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s ';
+sub format_message($) {
+  my $m = shift;
+
+#  if ( $m->is_zephyr ) {
+#    return format_zephyr($m);
+#  }
+  if ( $m->is_login ) {
+    return format_login($m);
+  }
+  elsif ( $m->is_ping) {
+    return format_ping($m);
+  }
+  elsif ( $m->is_admin || $m->is_loopback) {
+    return format_local($m);
+  }
+  else {
+    return format_chat($m);
+  }
+}
+
+BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine::format_message", "Formats for one-line-per-message");
+
+################################################################################
+
+sub format_login($) {
+  my $m = shift;
+  return sprintf(
+    BASE_FORMAT,
+    '<',
+    $m->type,
+    uc( $m->login ),
+    $m->pretty_sender)
+    . ($m->login_extra ? "at ".$m->login_extra : '');
+}
+
+sub format_ping($) {
+  my $m = shift;
+  return sprintf(
+    BASE_FORMAT,
+    '<',
+    $m->type,
+    'PING',
+    $m->pretty_sender)
+}
+
+sub format_chat($)
+{
+  my $m = shift;
+  my $dir = lc($m->{direction});
+  my $dirsym = '-';
+  if ($dir eq 'in') {
+    $dirsym = '<';
+  }
+  elsif ($dir eq 'out') {
+    $dirsym = '>';
+  }
+
+  my $line;
+  if ($m->is_personal) {
+    $line= sprintf(BASE_FORMAT,
+		   $dirsym,
+		   $m->type,
+		   '',
+		   ($dir eq 'out'
+		      ? $m->pretty_recipient
+		      : $m->pretty_sender));
+  }
+  else {
+    $line = sprintf(BASE_FORMAT,
+		    $dirsym,
+		    $m->context,
+		    $m->subcontext,
+		    ($dir eq 'out'
+		       ? $m->pretty_recipient
+		       : $m->pretty_sender));
+  }
+
+  my $body = $m->{body};
+  $body =~ tr/\n/ /;
+  $line .= $body;
+  $line = BarnOwl::Style::boldify($line) if ($m->is_personal && lc($m->direction) eq 'in');
+  return $line;
+}
+
+# Format locally generated messages
+sub format_local($)
+{
+  my $m = shift;
+  my $type = uc($m->{type});
+  my $line = sprintf(BASE_FORMAT, '<', $type, '', '');
+  my $body = $m->{body};
+  $body =~ tr/\n/ /;
+  return $line.$body;
+}
 
 package BarnOwl::Style;
Index: stylefunc.c
===================================================================
--- stylefunc.c	(revision 0b7082c1518be8fb8e173d6702a8f51fa1a89535)
+++ stylefunc.c	(revision f2d72128d54fe0a3466422505e2ae01e3b137498)
@@ -220,132 +220,2 @@
   }
 }
-
-void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
-{
-  char *tmp;
-  char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
-  char *sender, *recip;
-#ifdef HAVE_LIBZEPHYR
-  ZNotice_t *n;
-#endif
-
-  sender=short_zuser(owl_message_get_sender(m));
-  recip=short_zuser(owl_message_get_recipient(m));
-  
-  if (owl_message_is_type_zephyr(m)) {
-#ifdef HAVE_LIBZEPHYR
-    n=owl_message_get_notice(m);
-    
-    owl_fmtext_append_spaces(fm, OWL_TAB);
-
-    if (owl_message_is_loginout(m)) {
-      char *host, *tty;
-      
-      host=owl_message_get_attribute_value(m, "loginhost");
-      tty=owl_message_get_attribute_value(m, "logintty");
-
-      if (owl_message_is_login(m)) {
-	tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender);
-	owl_fmtext_append_normal(fm, tmp);
-	owl_free(tmp);
-      } else if (owl_message_is_logout(m)) {
-	tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender);
-	owl_fmtext_append_normal(fm, tmp);
-	owl_free(tmp);
-      }
-
-      owl_fmtext_append_normal(fm, "at ");
-      owl_fmtext_append_normal(fm, host ? host : "");
-      owl_fmtext_append_normal(fm, " ");
-      owl_fmtext_append_normal(fm, tty ? tty : "");
-      owl_fmtext_append_normal(fm, "\n");
-
-    } else if (owl_message_is_ping(m)) {
-      tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
-      owl_fmtext_append_normal(fm, tmp);
-      owl_fmtext_append_normal(fm, "\n");
-      owl_free(tmp);
-
-    } else {
-      if (owl_message_is_direction_in(m)) {
-	tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
-      } else if (owl_message_is_direction_out(m)) {
-	tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
-      } else {
-	tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
-      }
-      owl_fmtext_append_normal(fm, tmp);
-      if (tmp) owl_free(tmp);
-      
-      tmp=owl_strdup(owl_message_get_body(m));
-      owl_text_tr(tmp, '\n', ' ');
-      owl_fmtext_append_ztext(fm, tmp);
-      owl_fmtext_append_normal(fm, "\n");
-      if (tmp) owl_free(tmp);
-    }
-      
-    /* make personal messages bold for smaat users */
-    if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
-	owl_message_is_personal(m) &&
-	owl_message_is_direction_in(m)) {
-      owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
-    }
-
-    owl_free(sender);
-    owl_free(recip);
-#endif
-  } else if (owl_message_is_type_aim(m)) {
-    owl_fmtext_append_spaces(fm, OWL_TAB);
-    if (owl_message_is_login(m)) {
-      tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
-      owl_fmtext_append_normal(fm, tmp);
-      owl_fmtext_append_normal(fm, "\n");
-      if (tmp) owl_free(tmp);
-    } else if (owl_message_is_logout(m)) {
-      tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
-      owl_fmtext_append_normal(fm, tmp);
-      owl_fmtext_append_normal(fm, "\n");
-      if (tmp) owl_free(tmp);
-    } else {
-      if (owl_message_is_direction_in(m)) {
-	tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
-	owl_fmtext_append_normal(fm, tmp);
-	if (tmp) owl_free(tmp);
-      } else if (owl_message_is_direction_out(m)) {
-	tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
-	owl_fmtext_append_normal(fm, tmp);
-	if (tmp) owl_free(tmp);
-      }
-      
-      tmp=owl_strdup(owl_message_get_body(m));
-      owl_text_tr(tmp, '\n', ' ');
-      owl_fmtext_append_normal(fm, tmp);
-      owl_fmtext_append_normal(fm, "\n");
-      if (tmp) owl_free(tmp);
-
-      /* make personal messages bold for smaat users */
-      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
-	owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
-      }
-    }
-  } else if (owl_message_is_type_admin(m)) {
-    owl_fmtext_append_spaces(fm, OWL_TAB);
-    owl_fmtext_append_normal(fm, "< ADMIN                                  ");
-    
-    tmp=owl_strdup(owl_message_get_body(m));
-    owl_text_tr(tmp, '\n', ' ');
-    owl_fmtext_append_normal(fm, tmp);
-    owl_fmtext_append_normal(fm, "\n");
-    if (tmp) owl_free(tmp);
-  } else {
-    owl_fmtext_append_spaces(fm, OWL_TAB);
-    owl_fmtext_append_normal(fm, "< LOOPBACK                               ");
-    
-    tmp=owl_strdup(owl_message_get_body(m));
-    owl_text_tr(tmp, '\n', ' ');
-    owl_fmtext_append_normal(fm, tmp);
-    owl_fmtext_append_normal(fm, "\n");
-    if (tmp) owl_free(tmp);
-  }    
-
-}
